NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
October 18, 2017, 05:27:21 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  
Ask questions. Follow-up questions. ...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 view the valuesofvariables declared inside for ODE Evolution Page in EJS?  (Read 4967 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: November 28, 2008, 09:19:14 am » posted from:SINGAPORE,SINGAPORE,SINGAPORE

how to view the values of variables declared inside for ODE Evolution Page in EJS?

For example,
Code:
double deltax = x[1]-x[0], deltay = y[1]-y[0]; //
double deltaVx = vx[1]-vx[0], deltaVy = vy[1]-vy[0];
double distance = Math.sqrt(deltax*deltax+deltay*deltay)-diameter/2*2;  // 
if (deltax*deltaVx+deltay*deltaVy<0) {
 return distance;
}
return TOLERANCE;
Action:
Code:
double vcmx = (vx[1]+vx[0])/2;  // vcm is center of mass velocity in laboratory
double vcmy = (vy[1]+vy[0])/2;
double deltax = x[1]-x[0], deltay = y[1]-y[0];
double r=Math.sqrt(deltax*deltax+deltay*deltay);  // separation
deltax = deltax/r;  // normalized separation x component
deltay = deltay/r;  // normalized separation y component
// transform into CM system
vx[0]=vx[0]-vcmx;
vy[0]=vy[0]-vcmy;
vx[1]=vx[1]-vcmx;
vy[1]=vy[1]-vcmy;
// compute collisions
double dot=deltax*vx[0]+deltay*vy[0]; // particle 0 projection along line of centers
vx[0]=vx[0]-2*dot*deltax;
vy[0]=vy[0]-2*dot*deltay;
dot=deltax*vx[1]+deltay*vy[1];  // particle 1 projection along line of centers
vx[1]=vx[1]-2*dot*deltax;
vy[1]=vy[1]-2*dot*deltay;
// transform into laboratory
vx[0]=vx[0]+vcmx;
vy[0]=vy[0]+vcmy;
vx[1]=vx[1]+vcmx;
vy[1]=vy[1]+vcmy;


I normally recreate the variables in event in the main variable tab/page and copy and paste the relationship/equation in "fixed relations tab" to track the values as the simulation run.

Example of Fields: that i want to see what they are calculating
deltax = 0.00
deltay = 0.00
deltaVx = 0.00
deltaVy = 0.00
distance = 0.00


is there an easier way to do track variables declared inside the event and for the matter custom functions ?  Grin Thanks!
« Last Edit: November 28, 2008, 09:36:49 am by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: November 28, 2008, 11:03:57 am »

In the custom page, you declear variable as local scope:

double deltax = x[1]-x[0], deltay = y[1]-y[0]; //
double deltaVx = vx[1]-vx[0], deltaVy = vy[1]-vy[0];
double distance = Math.sqrt(deltax*deltax+deltay*deltay)-diameter/2*2;  // 

So deltax,deltaVx and distance are only available in the custom page.

If you want to use those variable (or any variable globally). Define variable in the Variable tabs.
And you can access all variables defined in the Variable tabs anywhere in the ejs program.

So you need to define deltax,deltaVx and distance , and change the above code to
deltax = x[1]-x[0], deltay = y[1]-y[0]; //
deltaVx = vx[1]-vx[0], deltaVy = vy[1]-vy[0];
distance = Math.sqrt(deltax*deltax+deltay*deltay)-diameter/2*2;  // 

And you can assign the above variables to any view element to find out their value!
Logged
Pages: [1]   Go Up
  Print  
Ask questions. Follow-up questions. ...Wisdom
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Experiencing molecular motion from inside a gas
Molecular Workbench
concord 0 8401 Last post May 31, 2007, 02:34:13 am
by concord
Event for ODE Evolution Page in EJS
Questions related to EJS
lookang 6 7169 Last post November 27, 2008, 07:42:23 am
by lookang
Free Fall modelling to understand the Event for ODE Evolution Page
Collaborative Community of EJS
lookang 2 8352 Last post August 03, 2009, 11:24:15 am
by lookang
Mirror sites in one page
Mirror sites and different language versions
Fu-Kwun Hwang 2 10098 Last post January 09, 2017, 02:26:22 pm
by smily
Doubt in Easy Java Simulation/board:11-100-
Questions related to EJS
dhasthagheer 1 2837 Last post August 20, 2011, 07:01:50 pm
by Fu-Kwun Hwang
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.056 seconds with 22 queries.since 2011/06/15