APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

SuperpositionWavesApp extends AbstractSimulation and doStep

Return to the General Comments forum
Login to post to this thread

SuperpositionWavesApp extends AbstractSimulation and doStep() - July 22, 2015 at 6:52
Adam S.
2 Posts

Hi,
I am trying to write a code for superposition of waves in textbook tobochnik,gould exercise 4.4.  using the SuperpositionWavesApp extends AbstractSimulation and doStep() because question states to use this method.

the doStep method draws a function when code within {} is completed.
public void doStep()  
  {
  plotFrame.append(0, wave.state[1], wave.state[0]);
  wave.step();
  }    
I have no problem plotting a sine wave in the graph y vs x using this method for x values however, I have to plot it moving in time.  When I try for loop using dt step  it will not work.   It just plots the final results.  How do I frame the doStep method so that it will shift/move the sine wave by dt?


OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book