Você está na página 1de 4

Before you open the xls please note

- It uses macros and circular refs so observe the following


- Close all other xls spreadsheets and Excel before opening this xls. Re-close and start over if already op
- Do not copy these worksheets to other spreadsheet files the macros will get left behind
- If you copy these to powerpoint you can only run in non-slide show mode so probably best to run from xl
- Change only values in tan colored cells for different intial conditions etc
- Click on Click-to-Init and then Run for Max Iterations to see the sim
- To abort hit Esc then select End in the dialog box

Simulation Approach for colliding pendulums


Since the movement of each mass is constrained by the pendulum string we
can simplify the state variable to be the angle of the string (theta) and its
rate of change. The radii of rotation are fixed at L1, L2
Accel due to gravity is then given by
L*(th_accel) = g*sin(th)
or (th_accel) = g*sin(th)/L
Collision is delt with by first detecting first impact and then solving the
equations for change in velocity due to elastic collision
First impact is when separation < 0 and centers of the bobs are closing
Equations for impact are
m1*((v1-u1) = m2* (v2-u2)
[= Impulse (force * dt) ]
(v1-v2) =-r*(u1-u2)
[ coef of restitution ]
where u,v are approx = L*(th_vel)
Solving gives v1, v2 interms of u1, u2 and constants L1, L2, k0k4
The new state variable for each pendulum at time (T+dt) is computed and
copied back (to time T) each iteration except when iniitalizing.
Data table for the trace is compiled by keeping an iteration counter (d19)
and copying the state variable into the table when the iteration counter
reaches each row number. The latest point fills the remainder of the table to
keep the plot clean
The mimic is drawn as 2 series in x,y ; one for each pendulum
The radius of each bob is made proportional to the cube root of mass
Pivots are located to make the bobs just touch when theta 1 and 2 are zero
The outline of each Bob is drawn as 20 sided polygon
Only 3 macros are needed for the simulation (see below)
Initialization assigned to a shape
Iterate for N steps assigned to a shape
Beep on impact used in cell("k15")

Macros (Alt f8 then edit to see these)


Sub cellstart()
'
' cellstart Macro
' Macro recorded 6/10/2003 by John Houldsworth
'
' Keyboard Shortcut: Ctrl+s
'
Range("E8").Select
ActiveCell.FormulaR1C1 = "1"
Range("E7").Select
Calculate
Range("E8").Select
ActiveCell.FormulaR1C1 = "0"
Range("E7").Select
End Sub
Sub Run_to_Balance_Click()
Max = Range("d2").Value
For i = 1 To Max
Calculate
Next i
End Sub
Function Beep_if_True(arg1 As Boolean, arg2 As String) As String
Beep_if_True = ""
If arg1 Then
Beep
Beep_if_True = arg2
End If
End Function

e and start over if already opened.


get left behind
probably best to run from xls instead.

Simulation of Colliding Pendulums - John H - Jan 20 2010


Number of Iterations
Iteration Time
Gravity
Coef of Restitution
Allow Impact

1200
0.03
9.81
0.95
1

Pendulum 1
L1
M1
0
1.1
100
101

Initial Values
constants k0k4
State Variable at Time T
Accel Due to G
Vel after acc
Pos after acc
Impact?
State Variable after impact
New State Variable at (T + dt)
Iteration #

Pos
Th1
-0.2

Vel
Accel
Pendulum 2
Pos
Vel
Accel
Th1_dot Th1_2dot 1st contact L2
M2
Th2
Th2_dot Th2_2dot
0
4
1
0
0
Click to Init
99.05
1.95
195
-94
0.15032 0.34188
0.19766 0.52374
-1.3356
-0.48161
0.30182
0.50929
0.15938
0.21294
FALSE
0.15938 0.30182
0.21294 0.50929
0.15938 0.30182

0.21294 0.50929

Pendulum 1Th1_dot
-0.2
0
-0.1984 0.05315
-0.1952 0.10589
-0.1905 0.15779
-0.1842 0.20845
-0.1765 0.25746
-0.1674 0.30444
-0.1569 0.34902
-0.1452 0.39083
-0.1323 0.42954
-0.1184 0.46483
-0.1035 0.49642
-0.0877 0.52405
-0.0713 0.5475
-0.0543 0.56656
-0.0369 0.58109
-0.0192 0.59096
-0.0013 0.59608
0.01661 0.58491
0.03403 0.58047
0.05117 0.57136
0.0679 0.55768
0.08409 0.53953

Pendulum 2Th2_dot
0
0
0
0
0
0
Gravity Sling Shot - 0
Animation 0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.31667
0.0095 0.31667
0.01898 0.31597
0.02842 0.31457
0.03779 0.31248

97
Time
0
0.03
0.06
0.09
0.12
0.15
0.18
0.21
0.24
0.27
0.3
0.33
0.36
0.39
0.42
0.45
0.48
0.51
0.54
0.57
0.6
0.63
0.66

Data For the Mimic


Ball Scale
0.1
Radius1
0.464 based on weight
Radius2
0.100 based on weight
R1+R2
0.564
Plot x,y data for Mimic
x
y1
y2
Dist apart Separation Closing?
Pivot 1
-0.464
1.100
String1
-0.299
0.012
1.124478
0.560
FALSE
Pivot 2
0.100
4.000
String2
0.885
0.078

Run for Max


Iterations

Ball1
20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Ball2
20
1
2
3
4
5

0
0.314159
0.628319
0.942478
1.256637
1.570796
1.884956
2.199115
2.513274
2.827433
3.141593
3.455752
3.769911
4.08407
4.39823
4.712389
5.026548
5.340708
5.654867
5.969026
6.283185

-0.299
-0.156
-0.027
0.076
0.142
0.165
0.142
0.076
-0.027
-0.156
-0.299
-0.443
-0.572
-0.675
-0.741
-0.764
-0.741
-0.675
-0.572
-0.443
-0.299

0
0.314159
0.628319
0.942478
1.256637
1.570796

0.885
0.916
0.944
0.966
0.981
0.985

0.477
0.454
0.388
0.285
0.156
0.012
-0.131
-0.260
-0.363
-0.429
-0.452
-0.429
-0.363
-0.260
-0.131
0.012
0.156
0.285
0.388
0.454
0.477
0.178
0.173
0.159
0.137
0.109
0.078

Você também pode gostar