]> permondes.de Git - Analog_Engine.git/blob - scripts/TP1 04.12 Harmonic Oscillator.LACE
89b0723160bd71eeda166cfb7c00fd756ff15a78
[Analog_Engine.git] / scripts / TP1 04.12 Harmonic Oscillator.LACE
1 # Harmonic Oscillator
2 # A mass m is subject to a force F=-k*r.
3 # What is the trajectory if the mass starts at position (a,0,0)?
4 # How much time does it take to pass through zero?
5 # What is the trajectory if it starts at (a,0,0) with velocity (0,v0,0)?
6 # Compare to the case including gravity on earth in x direction
7 # m*x'' = -k*x + g
8 # m*y'' = -k*y (z can be set to 0).
9
10 coefficient.1(-1) -> -a # (a,0,0), has to be negative because x' is negative
11 coefficient.2 -> k/m_x # k/m for x
12 coefficient.3(+1) -> v0 # (0,v0,0), has to be positive because y'' is positive
13 coefficient.4 -> k/m_y # k/m for y, identical to k/m for x
14 coefficient.5(-1) -> -g # g
15
16 iintegrate x'' -> -x'
17 iintegrate -x' -> x
18 IC: -a
19 cmultiply (k/m_x, x) -> k/m*x
20 isum (k/m*x, -g) -> -k/m*x+g
21 assign (-k/m*x+g) -> x''
22
23 iintegrate y'' -> -y'
24 IC: v0
25 iintegrate -y' -> y
26 cmultiply (k/m_y, y) -> k/m*y
27 invert (k/m*y) -> -k/m*y
28 assign (-k/m*y) -> y''
29
30 output x -> out.x
31 output.y -> out.y