NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
October 19, 2017, 05:22:07 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  
"Make priority, take action and start now." ...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: simple pendulum  (Read 12238 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
sithy
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
on: March 31, 2009, 08:44:49 am » posted from:Lansdale,Pennsylvania,United States

In an attempt to learn EJS, I started to do simple pendulum simulation since there are a lots of those already available over the internet. I am starting off with the differential equation, a = -(g/L) sin q where a is the angular acceleration and q is the angle of the string with respect to the vertical. My amplitude drops with time. Note that I have not introduced any damping. My plot of w vs. q are ellipse which spiral down towards the center with time (expected). I have googled to find solution to exact solution to this equation.

I saw one of your simple pendulums. I did not see its source. Are you assuming small angle oscillations?

Thanks

Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: March 31, 2009, 08:51:40 am » posted from:Taipei,T\'ai-pei,Taiwan

1. You need to select Runge-Kutta 4th order numerical method in the evolution page.
2. It depends on how you wrote the evolution page. Please upload your ejs xml source as attachement.

If you want to open the xml source for EJS simulation download at this  web site.
 1.Double click download jar file to run it,
 2. Right click and select open EJS model , the EJS xml source will be loaded into EJS automatically.
Logged
sithy
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
Reply #2 on: March 31, 2009, 10:50:01 am » posted from:Lansdale,Pennsylvania,United States

I did not use the differential equations technique. My Evaluation page looks like this:

a =-g*Math.sin(q)/L;
q -= w*dt - 0.5 * a * dt*dt;
a = -g*Math.sin(q)/L;
w-= a*dt;
t +=dt;
x = L*Math.sin(q);
y = -L*Math.cos(q);
PE = m*9.8*(L+y);
KE = 0.5*m*L*L*w*w;







*** 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 #3 on: March 31, 2009, 11:25:32 am » posted from:Taipei,T'ai-pei,Taiwan

Your equations  only good if dt is very small.
The error will accumulate very quickly.

1. Copy
Quote
x = L*Math.sin(q);
y = -L*Math.cos(q);
PE = m*9.8*(L+y);
KE = 0.5*m*L*L*w*w;
to Fixed relation page
2. remove the current evolution page
3. Add an ODE page
At the top two text field enter t and dt

4 .enter q at the left first column (it will displayed as dq/dt). enter w at the right column
to set up dq/dt=w , this will tell EJS to calculate new q(t+dt) from q(t) and w
5. enter another relation to get

dw/dt = -g*Math.sin(q)/L;

6. select Runge-Kutta 4th order method
7. re-compile it again and it will give you correct result.



Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #4 on: March 31, 2009, 12:48:57 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

it might of of interest to browse the D:\EasyJavaSimulation\EJS_4.1_090312\EJS_4.1\workspace\source\users\murcia\fem\physics\mechanics\SimplePendulum.xml

i think it has useful tips for modeling pendulum.

Description: Pendulum
A simple pendulum is a physical abstraction that considers a point mass m that oscillates in a vertical plane at the end of a rod of length L and negligible mass.
 
If we consider the force exerted by gravity on the mass as constant, g, the motion of a simple pendulum can be modeled by a second order ordinary differential equation.
The equation includes a friction force, with b as friction coefficient, and a time-dependent external torque of the form A*sin(F*t), which drives the motion. Typically, the pendulum starts oscillating at time t=0, from a given angle with zero initial angular velocity.

Evolution equation:
d(theta)/dt = omega
d(omega)/dt =-g/L * Math.sin(theta) + (-b*omega+torque(t))/(m*L*L)

Custom:
public double torque (double time) {
  return amplitude*Math.sin(frequency*time);
}

I would delete the torque part if you want a simple pendulum with no external torque.

Evolution equation:
d(theta)/dt = omega
d(omega)/dt =-g/L * Math.sin(theta)


I also journeyed on learning with e-trails of my learning
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=818.0
may my XML help you too.
« Last Edit: March 31, 2009, 12:51:26 pm by lookang » Logged
sithy
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
Reply #5 on: April 08, 2009, 12:24:44 am » posted from:Lansdale,Pennsylvania,United States

Thanks for your responses. I have attached a file below. Please have a look at it. Try to increase the length by simply typing a number in the Length field and hitting the 'enter' key. Take a look at the pendulum. When length reach large values (eg. L = 2.0 m), the fixed end of the string begins to oscillate as well. I could not figure out why this is. In the properties of string, I have set x = y = 0 (so they are fixed !) and Pos(x) and Pos (y) are functions of x and y.  Could you able to tell me why the fixed end of the string is moving for L >>. I am trying to understand EJS. Thank you.

PS. Looks like my xml file is not uploading..
Logged
sithy
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
Reply #6 on: April 08, 2009, 12:26:37 am » posted from:Lansdale,Pennsylvania,United States

I am unable to upload files.
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #7 on: April 08, 2009, 07:24:53 am » posted from:Taipei,T'ai-pei,Taiwan

You need to click Additional Options... to upload attached files.
The Upload new EJS simulation is for upload EJS jar file only.
Logged
sithy
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
Reply #8 on: April 08, 2009, 10:46:38 am » posted from:Lansdale,Pennsylvania,United States

Thanks. I have uploaded the file.


*** 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 #9 on: April 08, 2009, 01:00:17 pm » posted from:Taipei,T'ai-pei,Taiwan

The problem is due to that
Autoscale X and Autoscale Y of the drawingPanel "Simple_Pendulum" were set to  true as default.
Even the default range was -1 to 1.
But when the x,y is smaller than -1 , EJS will change the scale so that it will fit into the range automatically (because it was set to autoscale)

You can set the Autoscale X and Autoscale Y to false. 
But you will need to change ymin and ymax to larger value , e.g. -1.5 to 1.5 or larger otherwise, it will be drawn outside the simulation region.

You do not need to set action to _paly() in the texfield region. unless it was not running initially, and you want to start the simulation when user enter new value.

For those traces in the plotting panel, I would suggest you set Max Points to a variable: e.g. maxpts
and define maxpts = 500(as integer) , then only the last 500 points will be shown in the trace.
Otherwise, the time scale will be changing all the time in the plottingPanel. 
Logged
sithy
Newbie
*
Offline Offline

Posts: 10


«
Embed this message
Reply #10 on: April 08, 2009, 08:55:58 pm » posted from:Lansdale,Pennsylvania,United States

Thank you. I have some free time these days. I found EJS very interesting and decided to create some simulations. Your site is very helpful. Thanks.
Logged
Pages: [1]   Go Up
  Print  
"Make priority, take action and start now." ...Wisdom
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
help: simple pendulum
Dynamics
foofz 3 22002 Last post November 11, 2009, 09:59:13 pm
by Fu-Kwun Hwang
Hi! I've got a simple difficult problem...
Physics Questions
razvan5050 5 6430 Last post October 10, 2011, 06:23:51 pm
by Fu-Kwun Hwang
PVT Simple simulation
Question related to Physics or physics related simulation
andresgo 5 6370 Last post February 14, 2015, 06:25:48 pm
by asalspammer
Simple Pendulum for use in Primary School
Collaborative Community of EJS
engrg1 0 5476 Last post September 25, 2012, 03:13:14 pm
by engrg1
Teaching how to solve simple resistive circuits./board:41-1-
Request for physics Simulations
alvalv31 0 2186 Last post August 01, 2013, 05:01:04 am
by alvalv31
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.062 seconds with 23 queries.since 2011/06/15