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

Login with username, password and session length
 
   Home   Help Search Login Register  
"It is not the strongest of the species that survive, but the one most responsive to change." ..."Darwin(1809-1882, English naturalist Evolution)"
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: Problem with Extra energy in vertical spring simulation  (Read 6014 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
mickey2times
Newbie
*
Offline Offline

Posts: 11


«
Embed this message
on: April 03, 2012, 06:41:25 pm »

I am creating a simulation that models a spring loaded launcher throwing a projectile straight up into the air, and then pauses at the top.  When creating graphs of the PEsp, PEg, KE and ME of the system I noticed that there is an increase in total energy when the projectile is launched.  After the launch everything seems to be fine, but I cannot figure out why there is an increase in energy in the beginning.  The PEg, should go up, the KE should go up and the PEsp should go down, but they should all balance out.

The only guess I have is that is might have something to do with the solver (I am using Euler-Richardson on 0.02 increments)  I tried lowering the increment to 0.01, 0.001 and it seemed to help but I could never get rid of the energy increase in the beginning.  Just not sure if this is a error in my programing, or something that it a limitation of how the DEq is being run.

I attached my .ejs file, so hopefully someone with different eyes might spot something.

thanks in advance,
Mike


*** There are 1 more attached files. You need to login to acces it!
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: April 05, 2012, 01:43:00 pm » posted from:Taipei,T'ai-pei,Taiwan

You have the following code at Evolution Page:
Code:
dv/dt=-k*y2/m-9.8
However, y2 is re-calculated at "Fixed Relation" Page,
which is processed after  "Evolution Page".

Code:
if (y < 0 ) y2 = y;
else y2 = 0;

At "Custom page": Click to create a page
You will find default code like the following
Code:
public void lib_Page () {
}

Change it to
Code:
public double myYvalue(double y){
 if(y<0)return y;
 return 0;
}

Then in the "Evolution Page"
Code:
dv/dt = -k*myYvalue(y)/m-9.8

You can change myYvalue to any name you want, however, you need to use the same name in the evolution page.

The function myYvalue will be called in the evolution page (at the time it is needed).

Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #2 on: April 10, 2012, 08:57:34 am » posted from:SINGAPORE,SINGAPORE,SINGAPORE

hi mickey2times,
i suspect the KE is giving your simulation a problem in displaying a constant value throughout the motion

when
y = -ve, KE = ok
y = -some value below zero, KE0- = ok
y = some value above zero, KE0+ = a bit different from KE0-

i could not solve this problem but i suspect it could be overcome by setting up an event handler to calculate the KE at y = 0, assign the KE0 into the release KE at some t in between the t KE0- and t KE0+

attached is my attempt to implement Prof Hwang custom method myYvalue(y) which works!


*** There are 1 more attached files. You need to login to acces it!
Logged
mickey2times
Newbie
*
Offline Offline

Posts: 11


«
Embed this message
Reply #3 on: April 12, 2012, 07:04:55 am » posted from:Boston,Massachusetts,United States

thanks lookang and Prof. Hwang.  I implemented your changes and got it the way I wanted.  There is still a tiny error in the beginning but it does not affect any numbers.  thank you again for your continued help, and for helping to support EJS.  my EJS sims have become invaluable to student learning in my physics class.
Logged
Pages: [1]   Go Up
  Print  
"It is not the strongest of the species that survive, but the one most responsive to change." ..."Darwin(1809-1882, English naturalist Evolution)"
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
vertical spring in equilibrium (adjustable gravity,spring constant and mass)
Dynamics
Fu-Kwun Hwang 0 9383 Last post October 01, 2009, 01:51:34 pm
by Fu-Kwun Hwang
Hozirontal spring and vertical spring
Dynamics
Fu-Kwun Hwang 1 12544 Last post April 05, 2010, 11:17:30 pm
by Fu-Kwun Hwang
Minimum energy problem
Dynamics
Fu-Kwun Hwang 0 4337 Last post February 22, 2010, 02:36:55 pm
by Fu-Kwun Hwang
Hozirontal spring and vertical spring
dynamics
ahmedelshfie 0 3108 Last post April 06, 2010, 11:42:18 pm
by ahmedelshfie
Minimum energy problem
dynamics
ahmedelshfie 0 2685 Last post June 01, 2010, 01:18:38 am
by ahmedelshfie
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.063 seconds with 23 queries.since 2011/06/15