NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
August 14, 2020, 04:10:29 am
 Welcome, Guest. Please login or register.Did you miss your activation email? 1 Hour 1 Day 1 Week 1 Month Forever Login with username, password and session length

 Home Help Search Login Register
Like what you dislike of those things are imortant. ...Wisdom

 Pages: [1]   Go Down
 Author Topic: how to view the valuesofvariables declared inside for ODE Evolution Page in EJS?  (Read 5739 times) 0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member

Offline

Posts: 1796

http://weelookang.blogspot.com

 « 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 ?  Thanks!
 « Last Edit: November 28, 2008, 09:36:49 am by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member

Offline

Posts: 3085

 « 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
Like what you dislike of those things are imortant. ...Wisdom
Jump to:

 Related Topics Subject Started by Replies Views Last post Experiencing molecular motion from inside a gas Molecular Workbench concord 0 9137 May 31, 2007, 02:34:13 am by concord Event for ODE Evolution Page in EJS Questions related to EJS lookang 6 8595 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 9358 August 03, 2009, 11:24:15 am by lookang Mirror sites in one page Mirror sites and different language versions Fu-Kwun Hwang 2 12501 January 09, 2017, 02:26:22 pm by smily Doubt in Easy Java Simulation/board:11-100- Questions related to EJS dhasthagheer 1 3986 August 20, 2011, 07:01:50 pm by Fu-Kwun Hwang
Page created in 0.048 seconds with 23 queries.since 2011/06/15