NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
September 23, 2019, 08:04:48 am

Discovery consists of seeing what everybody has seen and thinking what nobody has thought. ..."Albert von Szent-Gyorgyi(1893-1986, 1937 Nobel Prize for Medicine, Lived to 93)"

 Pages: [1]   Go Down
 Author Topic: Ejs Open Source Superposition of 2 Waves generated by equations  (Read 9843 times) 0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Moderator
Hero Member

Offline

Posts: 1792

http://weelookang.blogspot.com

 « Embed this message on: January 28, 2009, 10:15:07 pm »

Ejs Open Source Superposition of 2 Waves generated by equations

http://home.phy.ntnu.edu.tw/~lookang/EJS_4.1_090122/WaveFunctionPlotterSuperpositionwee.html

adapted from C:\EJS_4.1_090122\EJS_4.1\workspace\source\ModelingScience\Ch03_Basics\WaveFunctionPlotter.xml by Wolfgang Christian and Francisco Esquembre using the Easy Java Simulations (EJS) version 4.1 authoring and modeling tool.

Embed a running copy of this simulation

Embed a running copy link(show simulation in a popuped window)
Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
• Please feel free to post your ideas about how to use the simulation for better teaching and learning.
• Post questions to be asked to help students to think, to explore.
• Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!
 Ejs_Open_Source_Superposition_of_2_Waves_generated_by_equations_2012-08-13_1735.png (36.33 KB, 608x627 - viewed 468 times.) « Last Edit: August 14, 2012, 01:54:04 pm by lookang » Logged
lookang
Moderator
Hero Member

Offline

Posts: 1792

http://weelookang.blogspot.com

 « Embed this message Reply #1 on: June 11, 2010, 04:11:30 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

Remix Legally by lookang
1. added another function input and graphics
2. change color scheme function 1 = blue, function 2 = black, sum = RED
4. added pedagogical options equations in como dropdown menu "sin(x-t);0.5*sin(x-t);2*sin(x-t);sin(0.5*x-t);sin(2*x-t);sin(x-0.5*t);sin(x-2*t);sin(x-t-0.785);sin(x-t-1.57)" and "sin(x+t);0.5*sin(x+t);2*sin(x+t);sin(0.5*x+t);sin(2*x+t);sin(x+0.5*t);sin(x+2*t);sin(x+t+0.785);sin(x+t+1.57)"
5. slider bar for n number of points to plot inbetween the screen
7. added debug panel on the left set visible FALSE

Credits:
The Wave Function Plotter model was created by Wolfgang Christian and Francisco Esquembre using the Easy Java Simulations (EJS) version 4.1 authoring and modeling tool. You can examine and modify a compiled EJS model if you run the model (double click on the model's jar file), right-click within a plot, and select "Open Ejs Model" from the pop-up menu. You must, of course, have EJS installed on your computer. Information about Ejs is available at: and in the OSP ComPADRE collection .

Wave Function Plotter
A wave is a disturbance, such as sound, that propagates through space. For a wave propagating in one dimension, we use a wave function u(x,t) to represent the wave at position x and time t as shown in the screen shot. Although a sinusoidal wave function is a very common type type of disturbance, we should remember that there are many other wave functions, such as shock waves, that do not fit this functional form.
The model's fixed relations workpanel computes the data by evaluating the parser in the EJS Function element the using the following code:
double dx = (xmax-xmin)/n; // sample interval double x=xmin+dx/2; // position _view.trail.clear(); // clear old data for(int i=0; i
codes modified are

double dx = (xmax-xmin)/n; // sample interval
double x=xmin+dx/2; // position
_view.trail.clear(); // clear old data
_view.trail1.clear(); // need this else it will become a mess of points and make sure trail trail1 trail2 are names of the trail 2D element.
_view.trail2.clear(); // need this else it will become a mess of points

for(int i=0; i  double u = _view.waveFunction.evaluate(x,t); // evaluate wave function // make sure waveFunction is name of input function interface
_view.trail.addPoint(x,u) ; // add data to trace // make sure name trail is name of trail 2D to _view.trail.addPoint(x,u)
//type _view. for scaffolds super cool!

// added by wee for another functionplot1
double u1 = _view.waveFunction1.evaluate(x,t); // evaluate wave function

// added by wee for sum
//sum = u+ u1 ;
sum = _view.waveFunction.evaluate(x,t)+_view.waveFunction1.evaluate(x,t);
// summax = %sum_string%;
x += dx; // increment position
}

old code used for http://home.phy.ntnu.edu.tw/~lookang/

 « Last Edit: August 14, 2012, 01:24:41 pm by lookang » Logged
lookang
Moderator
Hero Member

Offline

Posts: 1792

http://weelookang.blogspot.com

 « Embed this message Reply #2 on: August 13, 2012, 04:28:55 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

discussion with teachers

1 create a 1/8 step of the period

2 make 8 squares for 2 waves

3 added two pointers on progressive waves.

 Ejs_Open_Source_Superposition_of_2_Waves_generated_by_equations_2012-08-13_1735.png (36.33 KB, 608x627 - viewed 524 times.) *** There are 1 more attached files. You need to login to acces it! « Last Edit: August 13, 2012, 04:31:58 pm by lookang » Logged
lookang
Moderator
Hero Member

Offline

Posts: 1792

http://weelookang.blogspot.com

 « Embed this message Reply #3 on: August 14, 2012, 01:24:26 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

discussion with teachers

1) I observed that when the new markers x-axis reach 4 units, the entire graph starts to shrink. If nothing can be done about it, then maybe we can remove the new markers?
done well autoscale false

2) The new "forward T/8" step function looks good. Sometimes there is a need to compare with the previous T/8 step. Do you think you could insert a "reverse T/8" step function too?
good idea done

3) The cyan colour looks nice but may not stand out. Can you pls help to change to say blue colour?
blue is good

Thanks man!

thanks to engrg1 for the coding for the dynamic selection of java string
public double cal_speed(String strTmp) {
double temp;
double coeff_x =1;
double coeff_t =1;

int tmp_start ;
int tmp_end;

// finding the constant x. Trying to extract coeff of x
tmp_start = strTmp.indexOf('(');
tmp_end = strTmp.indexOf("pi");

if ((tmp_end - tmp_start )!= 1) {
coeff_x = Double.parseDouble (strTmp.substring (tmp_start+1, tmp_end-1));

}
// finding the coeffient of t
tmp_start = strTmp.indexOf('+');
if (tmp_start == -1)
tmp_start = strTmp.indexOf('-');

tmp_end = strTmp.indexOf('t');

if ((tmp_end - tmp_start )!= 1) {

coeff_t = Double.parseDouble (strTmp.substring (tmp_start+1, tmp_end-1));
}

temp = coeff_t/coeff_x;

return temp;

}
 superposition_2012-08-14_1454.png (35.35 KB, 608x627 - viewed 503 times.) *** There are 1 more attached files. You need to login to acces it! « Last Edit: August 14, 2012, 01:53:37 pm by lookang » Logged
 Pages: [1]   Go Up
Discovery consists of seeing what everybody has seen and thinking what nobody has thought. ..."Albert von Szent-Gyorgyi(1893-1986, 1937 Nobel Prize for Medicine, Lived to 93)"