NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
October 22, 2017, 04:37:01 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  
Wisdom consists of the anticipation of consequences. ..."Norman Cousins(1913-1990, American author)"
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: Resonance applet by Prof. Wolfgang Christian  (Read 11124 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Moderator
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
on: December 14, 2008, 09:58:25 pm »

Harmonic Oscillator Resonance from F:\EasyJavaSimulation\EJS_4.1_081216\EJS_4.1\workspace\source\users\davidson\wochristian\osc\SHOResonance.xml

wochristian@davidson.edu

Plots the energy and phase of the simple harmonic oscillator after transients have decayed.

This is an applet that i tried to make a while back but didn't figure out how to.

i aim to allow b = 0 , 0.1 , 1 to show no damping, light damping , heavy damping on a single plot.

work in progress still.

Any help is appreciated Grin


source code
download the *.jar for using the applet on standalone without internet connection.
« Last Edit: December 24, 2008, 08:03:24 am by lookang » Logged
lookang
Moderator
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #1 on: December 17, 2008, 04:09:40 pm » posted from:Singapore,,Singapore

i can't figure out the codes in the xml, therefore not able to modify much.

any help ?
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #2 on: December 17, 2008, 09:07:13 pm »

Please post the code which you are in trouble. I will try to help!
Logged
lookang
Moderator
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #3 on: December 23, 2008, 12:42:02 pm » posted from:Singapore,,Singapore

i am puzzled by this code in the evolution
Record Data.

Code:
transientCounter--;  //  does this line do this? transientCounter = 0 ?
if(transientCounter<=0){
  double energy = 0.5*(m*v*v + k*x*x);  // assign TOTAL energy = 0.5*(m*v*v + k*x*x)
  double maxX = Math.sqrt(2*energy/k);  // maxX = maximum amplitude
  _view.resonanceTrace.addPoint(freq, maxX);//  what is this  _view.resonanceTrace.addPoint  command? where can i read about this line or where is the reference made to this resonanceTrace ?
  double phase= Math.atan2(x*omegaD,v);
  _view.phaseTrace.addPoint(freq, phase);
  freq += df;  // freq = freq +df;
  omegaD = 2*Math.PI*freq;  // formula
  dt=1.0/freq;  // dt = 1/ freq;
  transientCounter=transientCycles;  // not sure what this do
  t=x=v=0;  //  set to zero v = 0, x = 0. t = 0 guess to solve another resonance problem ?
  _resetSolvers();  // where did this come from? looks like it is to reset the ODE solvers but i don't see any codes about it, is it one of those command lines like _initialise(); etc
}
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #4 on: December 23, 2008, 04:56:06 pm » posted from:Taipei,T'ai-pei,Taiwan

Where is the above code coming from?
I guest it was not written by you.

_view.resonanceTrace.addPoint(freq, maxX);

it means that there is a GUI element in the view, it's name is resonanceTrace
and that element support build in function: addPoint.
I would guest it is a trace element.
There are web pages about all the  function for GUI elements.
Please check out http://fem.um.es/EjsWiki/index.php/Main/Elements
Logged
lookang
Moderator
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #5 on: December 23, 2008, 05:02:54 pm » posted from:Singapore,,Singapore

From
F:\EasyJavaSimulation\EJS_4.1_081216\EJS_4.1\workspace\source\users\davidson\wochristian\osc\SHOResonance.xml
wochristian@davidson.edu


One day i hope to be able to write codes like this, but not today. Grin

If Davidson use normal EJS function of trace, i will be able to follow how the trace was drawn.


« Last Edit: December 23, 2008, 05:07:35 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #6 on: December 23, 2008, 05:27:39 pm » posted from:Taipei,T'ai-pei,Taiwan

transientCounter--;  is equal to transientCounter=transientCounter-1;
The actual value determined by initial value when the variable was defined (1000).

_view.phaseTrace.addPoint(freq, phase);
I will not use the above code. It is easier to set (Input X, Input Y) to (freq , phase).
That is the way EJS was designed to do.
Prof. Wolfgang Christian is a very good programmer, so he like to use build in function directly.
But I will use the normal way.


if(transientCounter<=0){
...
}

The above part was used to reset everything to time t=0 when the evolution page has been run 1000 times.
It is similar to add those code (inside if) to initialization page and issue _initialize() in EJS.

I have never used "_resetSolvers(); " so I do not know what it is.
I did not find any difference when I comment out the above line (did not execute it).
Logged
lookang
Moderator
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #7 on: December 24, 2008, 08:03:12 am » posted from:SINGAPORE,SINGAPORE,SINGAPORE

thanks for reading the source xml file.

i will KIV this, until i can redesign the resonance modeling using EJS default functions.

i will work on this soon:)
Logged
Pages: [1]   Go Up
  Print  
Wisdom consists of the anticipation of consequences. ..."Norman Cousins(1913-1990, American author)"
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Electric Field Applet Physlets®, Wolfgang Christian.
Collaborative Community of EJS
lookang 3 25302 Last post September 09, 2010, 09:39:21 am
by Fu-Kwun Hwang
Free Fall Cartesian by Wolfgang Christian and Francisco Esquembre
Collaborative Community of EJS
lookang 2 7532 Last post August 03, 2009, 11:21:23 am
by lookang
Free Fall Cartesian with friction 2D Wolfgang Christian and Francisco Esquembre
Collaborative Community of EJS
lookang 0 5155 Last post November 27, 2008, 02:27:46 pm
by lookang
Ejs Open Source Ideal Hard Disk Gas Model by Wolfgang Christian
Simulations from other web sites
ahmedelshfie 1 5154 Last post April 27, 2010, 02:06:39 am
by ahmedelshfie
The Copernican Revolution by Prof Todd Timberlake
Ejs simulations from other web sites
lookang 1 4784 Last post July 21, 2010, 02:08:03 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.06 seconds with 23 queries.since 2011/06/15