Enjoy the fun of physics with simulations!

Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/

Title: Ejs Open Source Superposition of 2 Waves generated by equationsPost by: lookang 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. Title: Re: Open Source Ejs Superposition of 2 Waves generated by equationsPost by: lookang on June 11, 2010, 04:11:30 pm
Remix Legally by lookang
1. added another function input and graphics 2. change color scheme function 1 = blue, function 2 = black, sum = RED 3. added drop down menu for scaffolds and ease of exploration 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 6. redesign interface to be bottom panel HORIZONTAL 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: 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 _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 _view.trail1.addPoint(x,u1); // add data to trace // added by wee for sum //sum = u+ u1 ; sum = _view.waveFunction.evaluate(x,t)+_view.waveFunction1.evaluate(x,t); _view.trail2.addPoint(x,sum); // summax = %sum_string%; x += dx; // increment position } old code used for http://home.phy.ntnu.edu.tw/~lookang/ Title: Re: Ejs Open Source Superposition of 2 Waves generated by equationsPost by: lookang on August 13, 2012, 04:28:55 pm
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. Title: Re: Ejs Open Source Superposition of 2 Waves generated by equationsPost by: lookang on August 14, 2012, 01:24:26 pm
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 false2) 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 done3) The cyan colour looks nice but may not stand out. Can you pls help to change to say blue colour? blue is goodThanks 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; } |