NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
December 12, 2017, 10:48:12 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  
Last chance is the best chance. ...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: not sure why but total energy is not conserved in this model, can help debug?  (Read 3488 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: June 11, 2012, 05:12:15 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

hi prof,

not sure why but total energy is not conserved in this model, can help debug?

ke = 0.5*mtest*vxtest*vxtest;
//pe = -G*mtest*m2/Math.abs(x2-xtest)-G*mtest*m1/Math.abs(x1-xtest);
pe = Vy*mtest;
te = ke+pe;

i have been looking at this on and off, but cannot figure out what is wrong. te should be a constant value

the total energy of the mtest, te decays which is not suppose to happen. weird

Smiley

appreciate any help
thanks!


* weird.png (50.93 KB, 758x634 - viewed 258 times.)

*** There are 1 more attached files. You need to login to acces it!
« Last Edit: June 11, 2012, 05:14:42 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: June 11, 2012, 09:00:02 pm » posted from:Taipei,T'ai-pei,Taiwan

I downloaded your code, but it is too complicate.

It took me a lot of time try to understand it.


The problem I found is :

The evolution equations are:


d(xtest)/dt=vxtest;

d(vxtest)/dt=gy;


However, the gy is defined at constraint page (which is calculated after evolution page was done).

The evolution equations were calculated 4 times (when Runge-Kutta method was selected). -- This has something to do with numerical method.

However, gy was a constant in your code (and it was calculated after evolution page was processed).
You should use user defined function to return gy while evolution was processed.

And all the conditions related gy need to be done inside user's function.

I do not understand what you were doing so I do not know how to help you change your code.

Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #2 on: June 12, 2012, 11:20:20 am » posted from:SINGAPORE,SINGAPORE,SINGAPORE

hi prof!

the tip worked very well!

thank you very much again for helping teachers all over the world in customizing computer models to suit our learning and teaching needs. Smiley

attached is the corrected version thanks to engrg1's (we are colleagues in the same workplace)
help after discussion.

will post the refined simulation up ASAP. at http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1924.0

the people who use Easy Java simulation are awesome!


*** There are 1 more attached files. You need to login to acces it!
Logged
Pages: [1]   Go Up
  Print  
Last chance is the best chance. ...Wisdom
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Energy conservation: potential/kinetic energy
Kinematics
Fu-Kwun Hwang 2 23035 Last post June 17, 2008, 03:09:47 pm
by Fu-Kwun Hwang
potential energy
Dynamics
deepika.physicslover 6 14850 Last post February 15, 2009, 10:59:52 pm
by deepika.physicslover
Minimum energy problem
Dynamics
Fu-Kwun Hwang 0 4399 Last post February 22, 2010, 02:36:55 pm
by Fu-Kwun Hwang
Charge and Energy
Physics Questions
leeyiren 5 13832 Last post September 29, 2010, 04:27:56 pm
by lookang
TOTAL INTERNAL REFLECTION - PRISM
Request for physics Simulations
bgrao321 3 6885 Last post January 24, 2015, 12:35:52 pm
by teresajscott
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.055 seconds with 23 queries.since 2011/06/15