This is the web version of EJS interface
EJS version 4.3.7
  1. Title=Wave Machine
  2. Author=Wolfgang Christian - Davidson College
  3. Abstract=wochristian@davidson.edu
  4. CaptureTools=false
  5. DataTools=false
  6. LanguageTools=false
  7. EmersionSupport=false
  8. AppletColSupport=false
  9. UseInterpreter=true
  10. ImportStatements=org.opensourcephysics.numerics.*
  11. DetectedFiles=./WaveMachine/WaveMachine.html;
  12. AuxiliaryFiles=./WaveMachine/;

Wave Machine

    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension
    NameValueTypeDimension

    Position rods

    for(int i=0; i<n; i++){ m[i] = massslider; } if ( massslider >0) mtrue=true; else if (massslider ==0) mtrue=false; /* for(int i=0; i<n/2; i++){ I[i] = 2*m[i]*L[i]*L[i]+ 1; // 2 massess plus rod which is I = 1 } for(int i=n/2; i<n; i++){ I[i] = 1; // 2 massess plus rod which is I = 1 } */ resetTime();

    Torsion ODE

    Indep. Var. Increment
    d theta[] /dt=omega
    d omega[] /dt=alpha
    SolverRungeKuttaFehlberg AbsoluteTolerance=tol

    FixRel Page

    if(pulseSelector.equals("Mouse Drag")){ theta[0]=Math.PI/2-Math.atan2(zDriver,xDriver); omega[0]=0; }else{ double pulse=getPulse(t); theta[0]=Math.PI/2+pulse; zDriver=xDriver*Math.tan(-pulse); } if(fixed){ theta[n-1]=Math.PI/2; omega[n-1]=0; } for(int i=0; i<n; i++){ // setOrigin=(0,1,0); rotations[i] = Matrix3DTransformation.rotationY(theta[i]); // // added by lookang for mass //rotationsYaxis[i] = Matrix3DTransformation.rotationY(theta[i]); xm1[i] = L[i]/2*Math.sin(theta[i]); zm1[i] = L[i]/2*Math.cos(theta[i]); xm2[i] = - L[i]/2*Math.sin(theta[i]); zm2[i] = - L[i]/2*Math.cos(theta[i]); }
    public void resetTime () { t=0; xDriver=0.35*L1; xDriver=Math.min(1,xDriver); double yi=0, dy=D/(n-1); double Li=L1, dL=(L2-L1)/(n-1); for(int i=0; i<n; i++) { y[i]=yi; theta[i]= Math.PI/2; // + Math.sin(2*Math.PI*y0/D); omega[i]=0; L[i]=Li; I[i]=Li*Li/4 + 2*m[i]*Li/2*Li/2; // rod original plus 2 massess yi+=dy; // increase spacing Li+=dL; // increase length } }
    public void selectPulse () { if(pulseSelector.equals("One Pulse")) { } else if(pulseSelector.equals("One Cycle Shorter Wavelength")) { // added by lookang for shorter wavelength } else if(pulseSelector.equals("One Cycle Long Wavelength")) { // added by lookang for shorter wavelength } else if(pulseSelector.equals("Two Pulse")) { } else if(pulseSelector.equals("One Cycle")) { } else if(pulseSelector.equals("Two Cycle")) { } else if(pulseSelector.equals("Mouse Drag")) { } else{ // keep current } resetTime(); } public double getPulse(double t){ if(pulseSelector.equals("One Pulse")) { return -maxPulse*Math.exp(-(t-5)*(t-5)/6); /* // added by lookang for shorter wavelength } else if(pulseSelector.equals("One Pulse Short Wavelength")) { return -maxPulse*Math.exp(-(t-2.5)*(t-2.5)/6); // added by lookang for longer wavelength } else if(pulseSelector.equals("One Pulse Long Wavelength")) { return -maxPulse*Math.exp(-(t-10)*(t-10)/6); */ } else if(pulseSelector.equals("Two Pulse")) { return -maxPulse*Math.exp(-(t-5)*(t-5)/6)-maxPulse*Math.exp(-(t-45)*(t-45)/6); } else if(pulseSelector.equals("One Cycle")) { if(t>=16) return 0; return -maxPulse*Math.sin(Math.PI*t/8); // added } else if(pulseSelector.equals("One Cycle Shorter Wavelength")) { if(t>=8) return 0; return -maxPulse*Math.sin(2*Math.PI*t/8); } else if(pulseSelector.equals("One Cycle Shortest Wavelength")) { if(t>=4) return 0; return -maxPulse*Math.sin(2*Math.PI*t/4); // added } else if(pulseSelector.equals("Two Cycle")) { if(t>=32) return 0; return -maxPulse*Math.sin(Math.PI*t/8); } else if(pulseSelector.equals("Four Cycle")) { if(t>=64) return 0; return -maxPulse*Math.sin(Math.PI*t/8); } else{ return theta[0]; } }
    EJSVIEW: Click link to view it's content
    Control variables:(testing)
    double,double,double,double,double,double,double
    title="Wave Machine"
    layout=border
    visible=true
    location="188,200"
    size="886,408"
    position=center
    minimumX=-1
    maximumX=1
    minimumY=0
    maximumY=D
    minimumZ=-1
    maximumZ=1
    projectionMode=PERSPECTIVE_ON
    cameraAzimuth=-0.014295667070672381
    cameraAltitude=0.008851580194781883
    cameraFocusX=0.0
    cameraFocusY=9.699999999999998
    cameraFocusZ=-1.1
    cameraRotation=0.0
    cameraDistanceToScreen=178.9
    axesMapping=XYZ
    decorationType=CENTERED_AXES
    allowQuickRedraw=false
    numberOfElements=n
    x=0
    y=y
    z=0
    sizeX=2*r
    sizeY=2*r
    sizeZ=L
    transformation=%rotations%
    fillColor=RED
    resolution="3,3,4"
    x=0
    y=0
    z=0
    transformation=%rotations%
    visible=false
    numberOfElements=n
    x=xm1
    y=y
    z=zm1
    sizeX=r
    sizeY=5*r
    sizeZ=5*r
    transformation="x:90d"
    numberOfElements=n
    x=xm1
    y=y
    z=zm1
    radius=r*2*massslider
    transformation=%rotations%
    visible=mtrue==true
    numberOfElements=n
    x=xm2
    y=y
    z=zm2
    radius=r*2*massslider
    transformation=%rotations%
    visible=mtrue==true
    y=-1.5*dy
    z=-0.5
    sizeX=dy
    sizeY=dy
    sizeZ=1
    fillColor=200,220,208
    resolution="10,1,10"
    y=D+1.5*dy
    z=-0.5
    sizeX=dy
    sizeY=dy
    sizeZ=1
    fillColor=200,220,208
    resolution="10,1,10"
    x=0
    y=-dy
    sizeX=0
    sizeY=D+2*dy
    sizeZ=0
    lineColor=GRAY
    lineWidth=5
    resolution=360
    y=D/2
    z=-1.05
    sizeX=4
    sizeY=1.1*D
    fillColor=200,220,208
    drawingLines=false
    resolution="32,32"
    x=-L[n-1]/2
    y=D
    z=-0.5
    sizeX=dy
    sizeY=dy
    sizeZ=1
    visible=fixed
    fillColor=200,220,208
    resolution="10,1,10"
    x=L[n-1]/2
    y=D
    z=-0.5
    sizeX=dy
    sizeY=dy
    sizeZ=1
    visible=fixed
    fillColor=200,220,208
    resolution="10,1,10"
    x=xDriver
    y=0
    z=0
    x=0
    y=0
    z=-1
    sizeX=0
    sizeY=0
    sizeZ=1+zDriver
    lineColor=BLUE
    lineWidth=4
    x=0
    y=0
    z=-0.9
    sizeX=0.5
    sizeY=0.5
    sizeZ=0.2
    x=0
    y=0
    z=zDriver
    sizeX=0.15
    sizeY=0.15
    sizeZ=0.15
    visible=!pulseSelector.equals("Mouse Drag")
    fillColor=BLACK
    x=xDriver
    y=0
    z=zDriver
    sizeX=0.15
    sizeY=0.15
    sizeZ=0.15
    visible=pulseSelector.equals("Mouse Drag")
    measured=pulseSelector.equals("Mouse Drag")
    enabledPosition=ENABLED_Z
    dragAction=double max=xDriver*Math.sin(maxPulse); zDriver=Math.min(max,zDriver); zDriver=Math.max(-max,zDriver);
    fillColor=GREEN
    position=south
    layout=VBOX
    borderType=LOWERED_ETCHED
    position=center
    layout=HBOX
    layout=VBOX
    layout=HBOX
    text=" A = "
    background=RED
    tooltip="first rod amplitude"
    variable=maxPulse
    format="0.00"
    editable=_isPaused()
    action=maxPulse=Math.max(0,maxPulse); maxPulse=Math.min(pi/2,maxPulse); resetTime();
    columns=3
    size="0,24"
    text=" rad "
    background=RED
    variable=maxPulse
    minimum=0
    maximum=pi/2
    ticks=7
    closest=true
    enabled=_isPaused()
    dragaction=maxPulse=Math.max(0,maxPulse); maxPulse=Math.min(pi/2,maxPulse); resetTime();
    background=RED
    tooltip="maximum ampitude of the first rod in radian"
    layout=VBOX
    layout=HBOX
    text=" m = "
    background=BLUE
    foreground=WHITE
    tooltip="additional point masses added to the ends of the rods"
    variable=massslider
    format="0.00"
    editable=_isPaused()
    action=massslider=Math.max(0,massslider); massslider=Math.min(3,massslider); resetTime(); _initialize();
    columns=3
    size="0,24"
    text=" kg "
    background=BLUE
    foreground=WHITE
    variable=massslider
    value=0
    minimum=0
    maximum=3
    ticks=4
    closest=true
    enabled=_isPaused()
    dragaction=massslider=Math.max(0,massslider); massslider=Math.min(3,massslider); resetTime(); _initialize();
    background=BLUE
    foreground=WHITE
    tooltip="additional point masses added to the ends of the rods"
    layout=HBOX
    layout=VBOX
    layout=HBOX
    position=west
    text=" L1 = "
    background=BLUE
    foreground=WHITE
    tooltip="Length of first rod."
    position=center
    variable=L1
    format="0.0#"
    editable=_isPaused()
    action=L1=Math.min(4,L1); L1=Math.max(0.5,L1); resetTime ()
    columns=2
    size="0,24"
    tooltip="Length of first rod."
    position=north
    text=" m "
    background=BLUE
    foreground=WHITE
    tooltip="metre"
    variable=L1
    minimum=2
    maximum=4
    ticks=5
    closest=true
    enabled=_isPaused()
    dragaction=L1=Math.min(4,L1); L1=Math.max(0.5,L1); resetTime ()
    background=BLUE
    foreground=WHITE
    tooltip="Length of first rod."
    layout=VBOX
    layout=HBOX
    position=west
    text=" L2 = "
    background=CYAN
    tooltip="Length of last rod."
    position=center
    variable=L2
    format="0.0#"
    editable=_isPaused()
    action=L2=Math.min(4,L2); L2=Math.max(0.5,L2); resetTime ()
    columns=2
    size="0,24"
    tooltip="Length of last rod."
    text=" m "
    background=CYAN
    tooltip="metre"
    position=center
    variable=L2
    minimum=2
    maximum=4
    ticks=5
    closest=true
    enabled=_isPaused()
    dragaction=L2=Math.min(4,L2); L2=Math.max(0.5,L2); resetTime ()
    background=CYAN
    tooltip="Length of last rod."
    layout=VBOX
    layout=HBOX
    text=" $\\kappa$ = "
    background=GRAY
    tooltip="torsional coupling between bars k"
    variable=k
    format="0.#"
    editable=_isPaused()
    action=k=Math.max(0,k); k=Math.min(100,k); resetTime();
    columns=3
    size="0,24"
    variable=k
    minimum=0
    maximum=100
    ticks=5
    closest=true
    enabled=_isPaused()
    dragaction=k=Math.max(0,k); k=Math.min(100,k); resetTime();
    background=GRAY
    tooltip="torsional coupling between bars k"
    layout=VBOX
    layout=HBOX
    position=west
    text=" b = "
    tooltip="Damping constant."
    position=center
    variable=b
    format="0.00#"
    columns=3
    size="0,24"
    tooltip="Damping coefficient"
    variable=b
    minimum=0
    maximum=4
    ticks=5
    closest=true
    enabled=_isPaused()
    background=GRAY
    tooltip="Damping coefficient"
    layout=HBOX
    layout=FLOW:right,0,0
    options="One Cycle;One Cycle Shorter Wavelength;One Cycle Shortest Wavelength;One Pulse;Two Pulse;Two Cycle;Four Cycle;Mouse Drag"
    variable=%pulseSelector%
    editable=false
    action=selectPulse()
    tooltip="Sets the driver function."
    variable=fixed
    text="fixed end"
    action=resetTime ()
    background=200,220,208
    tooltip="Fixes the right hand side."
    layout=border
    position=west
    text=" $\Delta$t = "
    tooltip="Drive amplitude."
    position=center
    variable=dt
    format="0.00#"
    editable=_isPaused()
    action=dt=Math.max(dt,0.001);
    columns=3
    size="0,24"
    tooltip="Time step."
    layout=border
    position=west
    text=" t = "
    tooltip="Drive amplitude."
    position=center
    variable=t
    format="0.00#"
    editable=false
    columns=3
    size="0,24"
    tooltip="Time step."
    layout=HBOX
    position=center
    variable=_isPaused
    tooltip="Starts and stops 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/stepforward.gif
    action=_step()
    tooltip="Single steps the simulation."
    image=/org/opensourcephysics/resources/controls/images/reset1.gif
    action=_pause(); resetTime();
    tooltip="Resets the time."
    image=/org/opensourcephysics/resources/controls/images/reset.gif
    action=_reset()
    tooltip="Resets the simulation."
    position=west
    layout=border
    position=center
    variable=zDriver
    minimum=-xDriver*Math.tan(maxPulse)
    maximum=xDriver*Math.tan(maxPulse)
    orientation=VERTICAL
    enabled=pulseSelector.equals("Mouse Drag")