NTNUJAVA Virtual Physics LaboratoryEnjoy the fun of physics with simulations! Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
October 24, 2020, 10:45:06 am

Like what you dislike of those things are imortant. ...Wisdom

 Pages: [1]   Go Down
 Author Topic: simple pendulum  (Read 15272 times) 0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
sithy
Newbie

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
Hero Member

Offline

Posts: 3086

 « 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.
2. Right click and select open EJS model , the EJS xml source will be loaded into EJS automatically.
 Logged
sithy
Newbie

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
Hero Member

Offline

Posts: 3086

 « 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
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

Posts: 1796

http://weelookang.blogspot.com

 « 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
 « Last Edit: March 31, 2009, 12:51:26 pm by lookang » Logged
sithy
Newbie

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.

 Logged
sithy
Newbie

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
Hero Member

Offline

Posts: 3086

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

The Upload new EJS simulation is for upload EJS jar file only.
 Logged
sithy
Newbie

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
Hero Member

Offline

Posts: 3086

 « 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

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
cyberops21
Newbie

Offline

Posts: 1

 « Embed this message Reply #11 on: January 28, 2020, 04:15:36 pm » posted from:,,Satellite Provider

these are some really helpful replies
 Logged

 Pages: [1]   Go Up
Like what you dislike of those things are imortant. ...Wisdom