NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
October 20, 2017, 08:40:48 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Like what you dislike of those things are imortant. ...Wisdom
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: how to make the text b always appear after the simulation is reset?  (Read 15321 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
on: July 10, 2007, 11:47:56 pm »

i making a inquiry based applet that allows user to reset the simulation
but the graph is constantly being updated and shows the Xmax for different driving frequency

so as to achieve the graph of maximum amplitude versus different driver frequencies ?

Thanks
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #1 on: July 10, 2007, 11:52:55 pm »



Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #2 on: July 11, 2007, 11:08:55 am »

If you want to create it with EJS. Use _initialize() function to change the initial value, instead of calling _reset().
_reset() will reset everything, including all the variables.
You can find similar example at Blackbody radiation curves for different temperatures
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #3 on: July 19, 2007, 03:57:08 pm » posted from:Singapore,,Singapore

Hi community of practice a.k.a. Prof. Hwang  Cheesy

i am trying to assign Xmodplot = Xmod; when pause button is pressed



if(_pause()){
 
Xmodplot = Xmod;
 }


The reason is i need the user to decide when is it that is maximum amplitude by clicking the pause button


Generating simulation file
  F:\EasyJavaSimulations\Ejs3.46_070428\Ejs\Simulations\_apps\_examples\weelookangresonance03.app\weelookangresonance03.java ...
F:\EasyJavaSimulations\Ejs3.46_070428\Ejs\Simulations\_apps\_examples\weelookangresonance03.app\weelookangresonance03.java:297: incompatible types
found  : void
required: boolean
  if(_pause()){
  ^
1 error
Compilation produced an error!
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #4 on: July 19, 2007, 04:48:22 pm » posted from:Singapore,,Singapore

public void playPause () {

 if(label=="play"){
  label="pause"; // to assign label="pause"
  _play();


 }else{
  label="play";
  _pause();

Xmodplot = Xmax; // to allow user to decide maximum amplitude
 }





}
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #5 on: July 20, 2007, 08:25:38 am » posted from:Singapore,,Singapore

Hi community of practice a.k.a. Prof. Hwang  Grin

i am trying to make graphing the user understand resonance


so everytime the button is pressed to determine the Xmaxplot and the graph will remember to plot

coordinates,

(Hertz ,Xmaxplot[0])
(Hertz ,Xmaxplot[1])
(Hertz ,Xmaxplot[2])
(Hertz ,Xmaxplot[3]) and on to achieve understand of resonance for a particular damping first.


can advise how to do that?
currently it just plot (Hertz ,Xmaxplot[1]) then it goes on to plot (Hertz ,Xmaxplot[2]) so i am missing the previous data.
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #6 on: July 20, 2007, 10:20:34 pm »

I am in Malaysia now.
For your previous question: You should use
if(_isPlaying()){
}
or if(_isPaused()){
}

For status of simulation. _pause() is an action to pause the simulation.
_play() us an action to start the simulation.

There are several ways to do what you want to do.
You can use polygon to plot the data
provide Hertz as x property, and Xmaxplot as y property.
Define ns=0 (interger) to record number of data point recorded.
When ever user click button, add action in the property field.
for example: Xmaxplot[ns]=xxx (name of the variable you want to save)
and ns=ns+1;
and set the number of polygon to ns;

Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #7 on: July 24, 2007, 01:34:08 pm » posted from:Singapore,,Singapore

A bit lost on that part

is there an example file to follow the logic and syntax Smiley




Quote:
"When ever user click button, add action in the property field.
for example: Xmaxplot[ns]=xxx (name of the variable you want to save)
and ns=ns+1;
and set the number of polygon to ns;"
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #8 on: July 24, 2007, 02:58:06 pm » posted from:Taipei,T'ai-pei,Taiwan

I can not give you detail example because I have no ideas about your model for the simulation.

I only know you want the simulation to remember a set of data points and you want to show those data points.
So you need to define variables to save those data points. For examples: npt=100 (maximum number of points to be saved), xs[npt],ys[npt], np=0;// number of points been saved
Add the following to the press action property for button
xs[np]=x;
ys[np]=y;
np=np+1;

And you can display it with polygon elements in GUI.
Set number of data to be shown as np;
x,y coordinates to xs,ys
Then EJS will take care of the rest for you!

If you can upload your ejs source files and describe in more detail what you want to do, I can try to modify your ejs code to suit your need.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #9 on: July 24, 2007, 10:00:20 pm » posted from:Singapore,,Singapore

i followed the idea from your post.

seems ok  Grin

it is able to compile

but i can't seems to understand the logic of

xs[np]=Hertz;  // i self improvised your 'x' to mean 'Hertz' in my xml
ys[np]=Xmodplot;  // your 'y' to mean 'Xmodplot'
np=np+1;


After clicking on the button on the extreme bottom right , np=np+1; is executed !!

but my variable xs[np] and ys[np] doesn't seems to be doing what i wanted to assign

xs[np]=Hertz;
ys[np]=Xmodplot;


The main thing i wanted is to give users a chance to manually plot out (using EJS) for a particular damping coeff. b

to plot maximum amplitude resonance (Xmodplot) versus frequency of driver (Hertz), so that the experience of experimenting with the system simulation allows a deeper sense of the graphs. (refer to previous post for the picture)

this is a really difficult concept to explain in real life ( i used a water bottle and my hand to act as the driver, to demonstrate resonance ). Cheesy

attached is the xml, thanks for taking time to help me
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #10 on: July 25, 2007, 08:37:22 am »

You have a very complicated model in the code. I did not understand them all.
However, I found some syntax error in the code.
1. xs,ys should be an array. So I would suggest you put [npt] in the dimension field for those variables.
2. I add xsp,ysp to display value in the textfield
3. I also modified the action in the Pause22 VIEW element.
I modified your code, however, I do not know how to change those parameters/values. ys always give me 1.
Please check out the modified code.


*** There are 1 more attached files. You need to login to acces it!
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #11 on: July 25, 2007, 11:23:46 am » posted from:Singapore,,Singapore

Hi Prof.Hwang

the mathematical model is a spring mass system with air resistance.

Lucky for the EJS manual from Prof. Paco, the evolution equation are given.

The complexity arises due to my attempt

1. to make it into a applet where users can conduct their own experiment
2. instructional design more friendly ( text etc)
3. greater control to study certain quantities alone or together ( checkbox etc)
4. my lack of knowledge in javascripts (i am learning by refering to examples for syntax and logic)
5. use of the fields to debug and make sense what they mean in xml codes

which is why i don't get what xsp and ysp do  Huh it is because i use the wrong field (old) 1.0 type ?

maybe i try to change to 2.0 type of field  Cheesy

Thanks to you and prof. paco, the learning journey is tough but i hope to be good enough some day.


Anyway, back to the xml file, i think the polygon is not what i wanted because the user need

To get one plot point:

1. wait for oscillation to be "steady";
2. change Xmax to zero;
3. wait for Xmax to become highest or steady;
4. pause simulation;
5. click on button to store Xmodplot = Xmax;
6. change frequency to another value
7. set Xo = 1 m again
8. click play

All these just to get one point to plot .

To get another data point:

repeat 1 to 8





Question of Choice of Polygon.
Is it better to be particleset ? i was thinking to show big dots (user has to conclude on their own) rather than a line which the user can conduct very few data points or in not increasing order of frequency.

I try to work on it at home later.

Thanks for help  Smiley
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #12 on: July 25, 2007, 04:44:11 pm »

You can use particleset or trace for your case.
"Particleset" only show points as small dots, however, trace will connect points with line.
You can play with it or look at the examples. You should be able to find examples for most of the GUI elements.
It is under Simulations/_examples/Elements/

If you have some background in programming, you should be able to pick up ejs in a short time.
I just went to University of Malaysia to for 3 days EJS workshop last week, to teach their faculty members how to create simulation with EJS. Please check out the examples in this forum. If you can understand Chinese language, there are more information about EJS at my online ejs course. You will find many step by step examples shown as flash movie.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #13 on: July 26, 2007, 01:35:11 pm » posted from:Singapore,,Singapore

It WORKS beautifully now!!

Thanks for your kind assistance. I won't have been able to accomplish without your help and prof. paco. 

reporting bug:

I change to 2.0 type of field  and it seems to work well now, i managed to understand the logic after using 2.0 type of field because now it displays correctly which 1.0 type had some "bug".

another "weird bug" is the trace marker shape work for ellipse but not wheel. Or i think it may be an interesting note, because i was stuck wondering why it didn't display the marker  Grin

Anyway these are small matters, important thing is EJS is COOL!!!!
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #14 on: July 26, 2007, 02:33:59 pm »

Would you like to upload your xml source so that you can share your simulations with others?
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #15 on: July 26, 2007, 06:14:51 pm » posted from:Singapore,,Singapore

Objective
9745 H2 PHYSICS (2008) 8. Oscillations Damped and forced oscillations: resonance (k) describe graphically how the amplitude of a forced oscillation changes with frequency near to the natural frequency of the system, and understand qualitatively the factors which determine the frequency response and sharpness of the resonance.

Make Learning Deep and Sense Making
Resonance
For a forced oscillation, when the driving frequency is equal to the natural frequency of the oscillating system, maximum energy is transferred from the periodic force (driver) to the oscillating system which will vibrate with maximum amplitude. This phenomenon is called resonance.

Frequency Response Graph (under different degrees of damping)
The Effect of Damping on Forced Oscillations
When damping is present, it reduces the amplitude (y-axis) of the forced oscillation for all driver frequencies (x-axis) and it causes the maximum amplitude to be reached when the driving frequency is a little less than the natural frequency.
This reduction in amplitude is more significant at the resonance frequency and frequencies close to it, so that we say damping reduces the sharpness of resonance -- that is, the oscillating system responses little (small change in the amplitude) over a wide range of frequencies.

This Interactive Resource was designed by: Wee Loo Kang 


Using Easy Java Simulation by : Francisco Esquembre
 
Thanks to Fu-Kwun Hwang & Francisco Esquembre for their expert advise in (EJS):
Using Forum on EJS:http://www.phy.ntnu.edu.tw/ntnujava/index.php
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #16 on: July 26, 2007, 11:40:25 pm »

I duplicate the simulation from your xml source, copy the above message and create a new topic at  Oscillations Damped and forced oscillations by Wee Loo Kang

Keep up the good work and share more simulations with us!  Roll Eyes
Logged
Pages: [1]   Go Up
  Print  
Like what you dislike of those things are imortant. ...Wisdom
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
how to make a slider time t that allows user to slide to replay simulation
Questions related to EJS
lookang 2 7854 Last post September 22, 2008, 02:36:43 pm
by lookang
how to make a slider remember previous value after reset simulation.
Questions related to EJS
lookang 2 5995 Last post January 20, 2009, 01:37:25 pm
by lookang
How come cannot assign yv[j] to POS Y of a text field?
Questions related to EJS
lookang 8 10663 Last post December 02, 2009, 09:20:06 am
by Fu-Kwun Hwang
how do make Ejs applet run forever unless the pause or reset
Questions related to EJS
lookang 3 4855 Last post June 21, 2010, 07:52:30 pm
by Fu-Kwun Hwang
How to make gravitational simulation ?
Physlet builder (Create your own simulation)
GwenArBreizhou 22 53946 Last post May 06, 2015, 12:49:02 pm
by lookang
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.075 seconds with 23 queries.since 2011/06/15