Post on 28-Sep-2020
transcript
Using Mathematica to solve
coupled oscillators
2 coupled oscillators between fixed walls (essentially the same
as coupled pendula)
Here we have two equal masses (m=1) and three springs (with spring-constants 1, c and 1). Thus c is
the strength of the "coupling" between the two masses, which otherwise oscillate independently.
This is the general solution with four integration constants, and a sum of two normal modes. (It's a little
hard to parse this as the result is given after complexificatin.)
DSolve@8x''@tD + H1 + cL x@tD - c y@tD � 0, y''@tD + H1 + cL y@tD - c x@tD � 0<,8x@tD, y@tD<, tD
::x@tD ®1
4
ã-ä t- -1-2 c t Jã
ä t+ ã
-1-2 c t+ ã
2 ä t+ -1-2 c t+ ã
ä t+2 -1-2 c tN C@1D +1
4 -1 - 2 c
ã-ä t- -1-2 c t J-ã
ä t+ ä -1 - 2 c ã
-1-2 c t- ä -1 - 2 c ã
2 ä t+ -1-2 c t+ ã
ä t+2 -1-2 c tN
C@2D +1
4
ã-ä t- -1-2 c t J-ã
ä t+ ã
-1-2 c t+ ã
2 ä t+ -1-2 c t- ã
ä t+2 -1-2 c tN C@3D +
ã-ä t- -1-2 c t Jãä t + ä -1 - 2 c ã -1-2 c t - ä -1 - 2 c ã2 ä t+ -1-2 c t - ãä t+2 -1-2 c tN C@4D
4 -1 - 2 c
,
y@tD ®1
4
ã-ä t- -1-2 c t J-ã
ä t+ ã
-1-2 c t+ ã
2 ä t+ -1-2 c t- ã
ä t+2 -1-2 c tN C@1D +
ã-ä t- -1-2 c t Jãä t + ä -1 - 2 c ã -1-2 c t - ä -1 - 2 c ã2 ä t+ -1-2 c t - ãä t+2 -1-2 c tN C@2D
4 -1 - 2 c
+1
4
ã-ä t- -1-2 c t Jã
ä t+ ã
-1-2 c t+ ã
2 ä t+ -1-2 c t+ ã
ä t+2 -1-2 c tN C@3D +
1
4 -1 - 2 c
ã-ä t- -1-2 c t
J-ãä t
+ ä -1 - 2 c ã-1-2 c t
- ä -1 - 2 c ã2 ä t+ -1-2 c t
+ ãä t+2 -1-2 c tN C@4D>>
We can pick out one normal mode by introducing initial conditions in which both x and y are moved by
the same amount to the side. This normal mode has omega=1.
The “Flatten” command strips away one of the parentheses:
sol1 = Flatten@DSolve@8x''@tD + H1 + cL x@tD - c y@tD � 0, y''@tD + H1 + cL y@tD - c x@tD � 0,
x@0D � 1, x'@0D � 0, y@0D � 1, y'@0D � 0<, 8x@tD, y@tD<, tDD
:x@tD ®1
2
ã-ä t I1 + ã
2 ä tM, y@tD ®1
2
ã-ä t I1 + ã
2 ä tM>
Here’s one way of getting the real part of x(t)
First pick out the x[t] part of the solution
Here’s one way of getting the real part of x(t)
First pick out the x[t] part of the solution
x@tD �. sol1
1
2
ã-ä t I1 + ã
2 ä tM
Expand to multiply out
Expand@x@tD �. sol1D
ã-ä t
2
+ãä t
2
Finally, ComplexExpand gives the answer in a simple form, which is real because the
initial conditions are real.
ComplexExpand@Expand@x@tD �. sol1DDCos@tD
ComplexExpand@Expand@y@tD �. sol1DDCos@tD
Here's the other normal mode, where x=-y, and omega=Sqrt[1+2c] (which agrees with our answer from
lectures when c=1):
sol2 = Flatten@DSolve@8x''@tD + H1 + cL x@tD - c y@tD � 0, y''@tD + H1 + cL y@tD - c x@tD � 0,
x@0D � 1, x'@0D � 0, y@0D � -1, y'@0D � 0<, 8x@tD, y@tD<, tDD
:x@tD ®1
2
ã- -1-2 c t J1 + ã
2 -1-2 c tN, y@tD ® -1
2
ã- -1-2 c t J1 + ã
2 -1-2 c tN>
Simplify@ComplexExpand@y@tD �. sol2D, c > 0D
-CosB 1 + 2 c tF
Here's a solution with boundary conditions that excite both modes:
sol = Flatten@DSolve@8x''@tD + H1 + cL x@tD - c y@tD � 0, y''@tD + H1 + cL y@tD - c x@tD � 0,
x@0D � 1, x'@0D � 0, y@0D � 0, y'@0D � 0<, 8x@tD, y@tD<, tDD
:x@tD ®1
4
ã-ä t- -1-2 c t Jã
ä t+ ã
-1-2 c t+ ã
2 ä t+ -1-2 c t+ ã
ä t+2 -1-2 c tN,
y@tD ® -1
4
ã-ä t- -1-2 c t Jã
ä t- ã
-1-2 c t- ã
2 ä t+ -1-2 c t+ ã
ä t+2 -1-2 c tN>
Plot for coupling c=1 (the first case discussed in class):
2 CoupledOsc.nb
Plot@8x@tD �. sol �. c ® 1, y@tD �. sol �. c ® 1<,8t, 0, 30<, PlotStyle ® 88Thick, Red<, 8Thick, Blue<<D
5 10 15 20 25 30
-1.0
-0.5
0.5
1.0
Weak coupling (c=0.1): notice that x (red) mostly oscillates at first, then y (blue), etc.
This is like the demonstration in class where the energy oscillates back and forward between the two
pendula.
Plot@8x@tD �. sol �. c ® .1, y@tD �. sol �. c ® .1<,8t, 0, 120<, PlotStyle ® 88Thick, Red<, 8Thick, Blue<<D
20 40 60 80 100 120
-1.0
-0.5
0.5
1.0
Plot@8x@tD �. sol �. c ® .1, y@tD �. sol �. c ® .1<,8t, 0, 120<, PlotStyle ® 88Thick, Red<, 8Thick, Blue<<D
20 40 60 80 100 120
-1.0
-0.5
0.5
1.0
Very strong coupling (c=5). The two masses oscillate about an envolope corresponding to the low-
frequency normal mode.
CoupledOsc.nb 3
Very strong coupling (c=5). The two masses oscillate about an envolope corresponding to the low-
frequency normal mode.
Plot@8x@tD �. sol �. c ® 5, y@tD �. sol �. c ® 5<,8t, 0, 10<, PlotStyle ® 88Thick, Red<, 8Thick, Blue<<D
2 4 6 8 10
-1.0
-0.5
0.5
1.0
Making an animation (essentially equivalent to the coupled
pendula demonstration)
Convenient to pull out the functions x[t] and y[t] from solution:
xx@t_D = Re@x@tDD �. sol
1
4
ReBã-ä t- -1-2 c t Jã
ä t+ ã
-1-2 c t+ ã
2 ä t+ -1-2 c t+ ã
ä t+2 -1-2 c tNF
yy@t_D = Re@y@tDD �. sol
-1
4
ReBã-ä t- -1-2 c t Jã
ä t- ã
-1-2 c t- ã
2 ä t+ -1-2 c t+ ã
ä t+2 -1-2 c tNF
Place a disk at the positions of the masses, assuming (arbitrarily) that they are distance 4 apart at rest.
c0 is the coupling.
plotosc@t_, c0_D := Graphics@8Red, Disk@8N@4 + xx@tD �. c ® c0D, 0<, 0.1D, Blue, Disk@8N@yy@tD �. c ® c0D, 0<, 0.1D<,Axes ® True, PlotRange ® 88-1.1, 5.1<, 8-.14, .14<<D
Now make a little movie:
With weak coupling
Animate@plotosc@t, 0.1D, 8t, 0, 100<, AnimationRate ® 1D
t
-1 1 2 3 4 5
With strong coupling
4 CoupledOsc.nb
Animate@plotosc@t, 5D, 8t, 0, 100<, AnimationRate ® 1D
t
-1 1 2 3 4 5
Here’s the first normal mode (which is independent of the coupling c):
xx1@t_D = Re@x@tDD �. sol1 ; yy1@t_D = Re@y@tDD �. sol1;
plotosc1@t_D :=
Graphics@8Red, Disk@8N@4 + xx1@tDD, 0<, 0.1D, Blue, Disk@8N@yy1@tDD, 0<, 0.1D<,Axes ® True, PlotRange ® 88-1.1, 5.1<, 8-.14, .14<<D
Animate@plotosc1@tD, 8t, 0, 100<, AnimationRate ® 1D
t
-1 1 2 3 4 5
Here’s the second normal mode (which idepends on the coupling c, set to 1 below):
xx2@t_D = Re@x@tDD �. sol2; yy2@t_D = Re@y@tDD �. sol2;
plotosc2@t_, c0_D := Graphics@8Red,Disk@8N@4 + xx2@tD �. c ® c0D, 0<, 0.1D, Blue, Disk@8N@yy2@tD �. c ® c0D, 0<, 0.1D<,
Axes ® True, PlotRange ® 88-1.1, 5.1<, 8-.14, .14<<D
Animate@plotosc2@t, 1D, 8t, 0, 100<, AnimationRate ® 1D
t
-1 1 2 3 4 5
CoupledOsc.nb 5