]> permondes.de Git - Analog_Engine.git/commitdiff
Further examples of harmonic oscillation main
authorPermondes <machen@permondes.de>
Sun, 22 Dec 2024 19:46:56 +0000 (20:46 +0100)
committerPermondes <machen@permondes.de>
Sun, 22 Dec 2024 19:46:56 +0000 (20:46 +0100)
Examples:
- Calculation of damping of harmonic oscillator;
- Forced harmonic oscillator;
- 2 coupled pendulums;
- Superposition of oscillations
Technical Topics: Better understanding of sine/cosine
AESL:
- Some DIVISIONs are optional;
- combining operators with indentation;
- direct connection

20 files changed:
Analog Engine Example Applications.odt
Analog Engine Scripting Language.odt
Analog Engine Technical Topics.odt
Language for Analog Computing Engines.odt
Potentials and Motion.odt [new file with mode: 0755]
scripts/CompoundFunctions.LACE
scripts/EP1 04.02 Starting a Rocket_a.LACE [new file with mode: 0644]
scripts/EP1 04.02 Starting a Rocket_b.LACE [new file with mode: 0644]
scripts/EP1 10.01 Damped Harmonic Oscillator.LACE [new file with mode: 0644]
scripts/EP1 10.02 Forced Harmonic Oscillator.LACE [new file with mode: 0644]
scripts/EP1 10.03 Coupled Pendulums.LACE [new file with mode: 0644]
scripts/EP1 871102 Throwing a stone.LACE [new file with mode: 0644]
scripts/Gravity-1-dimensional.LACE [moved from scripts/Gravity – 1-dimensional.LACE with 100% similarity]
scripts/Gravity-2-dimensional.LACE [new file with mode: 0644]
scripts/Pendulum.LACE [new file with mode: 0644]
scripts/Superposition of oscillations.LACE [new file with mode: 0644]
scripts/THAT.LACE [new file with mode: 0644]
scripts/TP1 04.12 Harmonic Oscillator.AESL [deleted file]
scripts/TP1 04.12 Harmonic Oscillator.LACE [new file with mode: 0644]
scripts/TP1 07.19 Falling Mass.SALSA [deleted file]

index c59148e8d3b551f3d4f84c4cd6c2b212085e7968..d26398f6050517b24bb8c60899af10cd6d60a901 100644 (file)
Binary files a/Analog Engine Example Applications.odt and b/Analog Engine Example Applications.odt differ
index 50ef93308d5f8558708507882c887eb647c5e05f..8ec8b442fa065648b6c84e9560cc4e4ea869e614 100644 (file)
Binary files a/Analog Engine Scripting Language.odt and b/Analog Engine Scripting Language.odt differ
index 28d4ff13c27b392c2e22bb3b7399fb9f613dacce..f8423c0746e6a758c57052206e9dbb2787ef3bf3 100644 (file)
Binary files a/Analog Engine Technical Topics.odt and b/Analog Engine Technical Topics.odt differ
index 4da5af013de0d1ecc0d98d103aeaef6b0771211a..cad656a25de365ab8d52840f33338d002d67d726 100644 (file)
Binary files a/Language for Analog Computing Engines.odt and b/Language for Analog Computing Engines.odt differ
diff --git a/Potentials and Motion.odt b/Potentials and Motion.odt
new file mode 100755 (executable)
index 0000000..cf28c35
Binary files /dev/null and b/Potentials and Motion.odt differ
index e2a7cef374340a89e68ffd0d6be7f3bfa2cf1931..d3329ed92fb8ee4673db421fc4c3481e55c8e2db 100644 (file)
@@ -1,3 +1,4 @@
+# CompoundFunctions.LACE
 # collection of compound functions which can be realized with THAT
 
 # Open Amplifier
 # collection of compound functions which can be realized with THAT
 
 # Open Amplifier
diff --git a/scripts/EP1 04.02 Starting a Rocket_a.LACE b/scripts/EP1 04.02 Starting a Rocket_a.LACE
new file mode 100644 (file)
index 0000000..25b0546
--- /dev/null
@@ -0,0 +1,33 @@
+# A rocket is started from the surface of the earth. Calculating the height as function of its mass and fuel consumption. 
+# Approximation of gravity of earth by g
+# Equation of motion
+# r'' = alpha / (m0 - alpha*t) * v0 - g
+#   alpha: fuel consumption, e.g. 2000t in 2,5 min = 13,333*10^3 kg/s
+#   m0: initial mass of rocket, e.g. Saturn V: 2900 t = 2,9*10^6 kg
+#   v0: the velocity of the exhaust of the rocket: 3,180*10^3 m/s
+#   g: acceleration of earth = 9,81 m/s^2
+
+include CompoundFunctions.LACE # include idivide
+
+coefficient.1     -> alpha1
+coefficient.2(+1) -> alpha2 # == alpha1
+coefficient.3(-1) -> -m0
+coefficient.4     -> v0
+coefficient.5(+1) -> g
+
+# generate t-ramp
+iintegrate (-1) -> t
+
+cmultiply (alpha1, t) -> alpha*t
+isum (-m0, alpha*t) -> m0-alpha*t
+idivide (alpha2, m0-alpha*t) -> -alpha/(m0-alpha*t)
+cmultiply (-alpha/(m0-alpha*t), v0) -> -alpha/(m0-alpha*t)*v0
+isum(-alpha/(m0-alpha*t)*v0, g) -> alpha/(m0-alpha*t)*v0-g
+
+iintegrate (alpha/(m0-alpha*t)*v0-g) -> -v
+invert (-v) -> v
+iintegrate (-v) -> z
+
+output (t) -> out.x
+output (v) -> out.y
+output (z) -> out.z
diff --git a/scripts/EP1 04.02 Starting a Rocket_b.LACE b/scripts/EP1 04.02 Starting a Rocket_b.LACE
new file mode 100644 (file)
index 0000000..85a5177
--- /dev/null
@@ -0,0 +1,44 @@
+# A rocket is started from the surface of the earth. Calculating the height as function of its mass and fuel consumption. 
+# Approximation of acceleration with Taylor series
+# Equation of motion
+# r'' = (alpha / m0)*v0 + (alpha/m0)²*v0*t - gamma * ME / r²
+#   alpha: fuel consumption, e.g. 2000t in 2,5 min = 13,333*10^3 kg/s
+#   m0: initial mass of rocket, e.g. Saturn V: 2900 t = 2,9*10^6 kg
+#   v0: the velocity of the exhaust of the rocket: 3,180*10^3 m/s
+#   gamma: gravitational constant: 6,6743E-11 m³/(kg*s²)
+#   ME: mass of earth: 5,97E+24 kg
+
+# include idivide
+include CompoundFunctions.LACE 
+
+coefficient.1(+1) -> alpha/m0*v0
+coefficient.2(+1) -> (alpha/m0)^2*v0
+coefficient.3     -> scale 
+coefficient.4(-1) -> -RE
+coefficient.5(+1) -> 10*gamma*ME
+
+# generate t-ramp
+iintegrate (-1) -> t
+
+# calculating altitude
+iintegrate (alpha/m0*v0, (alpha/m0)^2*v0*t, -gamma*ME/r^2) -> -v # input is a ### 3. Term fehlen noch ###
+cmultiply (scale, -v) -> -v.scaled
+iintegrate (-v) -> r
+  IC: -RE
+
+# calculating acceleration
+multiply (r,r) -> r^2
+idivide (10*gamma*ME, r^2) -> -10*gamma*ME/r^2
+
+cmultiply ((alpha/m0)^2*v0, t) -> (alpha/m0)^2*v0*t
+
+# inverting velocity for display
+invert (-v.scaled) -> v.scaled
+
+# subtracting the radius of earth in order to get altitude above ground for display
+isum (-RE, r) -> -z
+invert (-z) -> z
+
+output (t) -> out.x
+output (v) -> out.y
+output (z) -> out.z
diff --git a/scripts/EP1 10.01 Damped Harmonic Oscillator.LACE b/scripts/EP1 10.01 Damped Harmonic Oscillator.LACE
new file mode 100644 (file)
index 0000000..0f03c01
--- /dev/null
@@ -0,0 +1,19 @@
+# Damped_Oscillator
+# phi'' = -(S*phi + D/m*phi')
+
+coefficient.1(-1) -> -phi0   # Initial Amplitude
+coefficient.3     -> S     # SpringForce
+coefficient.4     -> D/m   # Damping linear to speed
+
+iintegrate phi'' -> -phi'
+invert -phi' -> phi'
+cmultiply phi', D/m -> D/m*phi'
+
+iintegrate -phi' -> phi
+  IC: -phi0
+cmultiply S, phi -> S*phi
+
+isum 10:S*phi, D/m*phi' -> -(Sphi+D/mphi')
+assign -(Sphi+D/mphi') -> phi''
+
+output(y) -> out.y
diff --git a/scripts/EP1 10.02 Forced Harmonic Oscillator.LACE b/scripts/EP1 10.02 Forced Harmonic Oscillator.LACE
new file mode 100644 (file)
index 0000000..6e51b64
--- /dev/null
@@ -0,0 +1,33 @@
+# Forced Damped_Harmonic Oscillator
+# x'' + 2*delta*x' + omega.0^2*x = A cos (omega.f t)
+
+# generating oscillation with omega.f
+# f'' = -omega.f^2*f
+coefficient.1(-1) -> -f0      # amplitude
+coefficient.2     -> omega^2
+iintegrate f'' -> -f'
+iintegrate -f' -> f
+  IC: -f0
+cmultiply f, omega^2 -> omega^2*f
+invert omega^2*f -> -omega^2*f
+assign -omega^2*f -> f''
+invert f -> -f
+output f -> y
+
+# forced damped harmonic oscillation
+# x'' = -(2*delta*x' + omega.0^2*x) + A cos (omega.f t)
+coefficient.5(-1) -> -x0       # amplitude of oscillation
+coefficient.6     -> 2*delta   # attenuation
+coefficient.7     -> omega.0^2 # Eigenfrequency of this oscillator, ^2
+
+iintegrate x'' -> -x'
+invert -x' -> x'
+cmultiply x', 2*delta -> 2*delta*x'
+
+iintegrate -x' -> x
+  IC: -x0
+cmultiply x, omega.0^2 -> omega.0^2*x
+isum 2*delta*x', omega.0^2*x, -f -> -(2*delta*x'+omega.0^2*x)-f
+assign -(2*delta*x'+omega.0^2*x)-f -> x''
+
+output(x) -> x
diff --git a/scripts/EP1 10.03 Coupled Pendulums.LACE b/scripts/EP1 10.03 Coupled Pendulums.LACE
new file mode 100644 (file)
index 0000000..5ef0517
--- /dev/null
@@ -0,0 +1,34 @@
+# 2 coupled pendulums
+# x1'' = -k1*x1 + k*(x2-x1)
+# x2'' = -k2*x2 - k*(x2-x1)
+# xi are the displacement of the pendulum to its resting position
+
+coefficient.1 -> k1
+coefficient.2 -> k2
+coefficient.3 -> k
+coefficient.5(-1) -> -x10 # initial displacement x1
+coefficient.6(-1) -> -x20 # initial displacement x2
+
+iintegrate x1'' -> -x1'
+iintegrate -x1' -> x1
+  IC: -x10
+
+iintegrate x2'' -> -x2'
+iintegrate -x2' -> x2
+  IC: -x20
+
+cmultiply x1, k1 -> k1*x1
+cmultiply x2, k2 -> k2*x2
+
+invert x1 -> -x1
+isum x2, -x1 -> -(x2-x1)
+cmultiply -(x2-x1), k -> -k*(x2-x1)
+
+isum k1*x1, -k*(x2-x1) -> -k1*x1+k*(x2-x1)
+assign -k1*x1+k*(x2-x1) -> x1''
+invert -k*(x2-x1) -> k*(x2-x1)
+isum k2*x2, k*(x2-x1) -> -k2*x2-k*(x2-x1)
+assign -k2*x2-k*(x2-x1) -> x2''
+
+output x1 -> out.x
+output x2 -> out.y
diff --git a/scripts/EP1 871102 Throwing a stone.LACE b/scripts/EP1 871102 Throwing a stone.LACE
new file mode 100644 (file)
index 0000000..5fd5852
--- /dev/null
@@ -0,0 +1,22 @@
+# Throwing a stone on earth
+#
+# z'' = -g, with g=0,981 da*m/s^2
+# Initial speeds: v.z0 (vertical) and v.x0 (horizontal)
+
+coefficient.1(-1) -> -g    # set to 0,981
+coefficient.2(+1) -> v.z0  # initial vertical speed
+coefficient.3(+1) -> v.x0  # initial horizontal speed
+coefficient.4(-1) -> -z0   # initial altitude
+
+iintegrate (-g) -> -v
+  IC: v.z0
+iintegrate (-v) -> z
+  IC: -z0
+
+iintegrate (v.x0) -> x
+
+invert (-v) -> v
+
+output (x) -> out.x
+output (z) -> out.y
+output (v) -> out.z
diff --git a/scripts/Gravity-2-dimensional.LACE b/scripts/Gravity-2-dimensional.LACE
new file mode 100644 (file)
index 0000000..92a36fb
--- /dev/null
@@ -0,0 +1,36 @@
+# Gravity–2-dimensional.LACE
+
+# The small mass m moves within the gravitational potential of a mass M.
+# The situation is analysed in polar coordinates.
+
+# r'' = r * phi'^2 - gamma*M/r^2
+# phi'' = -2* r' / r * phi'
+
+include CompoundFunctions.LACE   # idivide
+
+coefficient(1): +1 -> r0' # -1 to move initially towards M, +1 to  move away from it
+coefficient(2): -1 -> -r0 # initial distance of m to M
+coefficient(3): +1 -> phi0' 
+coefficient(4): -1 -> -phi0 
+coefficient(5): +1 -> gamma*M
+
+iintegrate r*phi'^2, -gamma*M/r^2 -> -r' # input is r''
+   IC: r0'
+iintegrate -r' -> r
+  IC: -r0
+
+iintegrate -r'/r*phi', -r'/r*phi' -> -phi' # input is phi''
+  IC: phi0'
+iintegrate -phi' -> phi
+  IC: -phi0
+  
+multiply r, -phi' -> -r*phi'
+multiply -r*phi', -phi' -> r*phi'^2
+multiply r, r -> r^2
+idivide gamma*M, r^2 -> -gamma*M/r^2
+
+idivide -r', -r*phi' -> r'/r*phi'
+invert r'/r*phi' -> -r'/r*phi'
+  
+output(x): r      # distance
+output(y): phi    # angle
diff --git a/scripts/Pendulum.LACE b/scripts/Pendulum.LACE
new file mode 100644 (file)
index 0000000..c5e8ab2
--- /dev/null
@@ -0,0 +1,37 @@
+# Pendulum: Comparing Harmonic Oscillator with 4th order Taylor approximation
+
+### Taylor 4 approximation: phi'' = - g/r * (phi - 1/6 * phi^3)
+# fortunately, the components of orders 0, 2 and 4 are zero
+
+coefficient.1     -> g/r
+coefficient.2     -> 1/6   # set to 0,167 or 0 (for harmonic solution)
+coefficient.3(-1) -> -phi0
+
+iintegrate phi'' -> -phi'
+iintegrate -phi' -> phi
+  IC: -phi0
+
+multiply phi, phi   -> phi^2
+multiply phi^2, phi -> phi^3
+invert phi^3 -> -phi^3
+
+cmultiply 1/6, -phi^3 -> -1/6*phi^3
+isum phi, -1/6*phi^3 -> -(phi-1/6*phi^3)
+cmultiply -(phi-1/6*phi^3), g/r -> -g/r*(phi-1/6*phi^3)
+assign -g/r*(phi-1/6*phi^3) -> phi''
+
+output phi -> out.x
+
+### Harmonic oscillator: phi'' = - g/r * phi
+coefficient.5     -> g/r_h    # identical to g/r
+coefficient.7(-1) -> -phi0_h  # identical to -phi0
+
+iintegrate phi_h'' -> -phi_h'
+iintegrate -phi_h' -> phi_h
+  IC: -phi0_h
+invert phi_h -> -phi_h
+
+cmultiply -phi_h, g/r_h -> -g/r*phi_h
+assign -g/r*phi_h -> phi_h''
+
+output phi_h -> out.y
diff --git a/scripts/Superposition of oscillations.LACE b/scripts/Superposition of oscillations.LACE
new file mode 100644 (file)
index 0000000..b25f7e4
--- /dev/null
@@ -0,0 +1,31 @@
+# Superposition of the oscillation of two undamped harmonic oscillators
+# x1'' = -omega1^2*x1
+# x2'' = -omega2^2*x2
+
+coefficient.1(-1) -> -x10 # amplitude of 1
+coefficient.2     -> omega1^2
+coefficient.5(-1) -> -x20 # amplitude of 2
+coefficient.6     -> omega2^2
+
+# 1st oscillator
+iintegrate x1'' -> -x1'
+iintegrate -x1' -> x1
+  IC: -x10
+cmultiply x1, omega1^2 -> omega1^2*x1
+invert omega1^2*x1 -> -omega1^2*x1
+assign -omega1^2*x1 -> x1''
+output x1 -> out.x
+
+# 2nd oscillator
+iintegrate x2'' -> -x2'
+iintegrate -x2' -> x2
+  IC: -x20
+cmultiply x2, omega2^2 -> omega2^2*x2
+invert omega2^2*x2 -> -omega2^2*x2
+assign -omega2^2*x2 -> x2''
+output x2 -> out.y
+
+# Sum
+isum x1, x2 -> -(x1+x2)
+invert -(x1+x2) -> x1+x2
+output x1+x2 -> out.z
diff --git a/scripts/THAT.LACE b/scripts/THAT.LACE
new file mode 100644 (file)
index 0000000..81228ff
--- /dev/null
@@ -0,0 +1,2 @@
+# definitions of functions available on the Anabrid-THAT
+#
diff --git a/scripts/TP1 04.12 Harmonic Oscillator.AESL b/scripts/TP1 04.12 Harmonic Oscillator.AESL
deleted file mode 100644 (file)
index 2c0e512..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-IDENTIFICATION DIVISION
-PROGRAM-ID HarmonicOscillator
-VERSION 20240201
-COMMENT A mass m is subject to a force F=-k*r.
-COMMENT What is the trajectory if the mass starts at position (a,0,0)?
-COMMENT How much time does it take to pass through zero?
-COMMENT What is the trajectory if it starts at (a,0,0) with velocity (0,v0,0)?
-COMMENT m*x'' = -k*x
-COMMENT m*y'' = -k*y (z can be set to 0).
-
-ENVIRONMENT DIVISION
-ENGINE Anabrid-THAT
-TIMEBASE 1ms
-REQUIRES COEFFICIENT 4, INTEGRATOR 4, INVERTER 2
-
-DATA DIVISION
-OUTPUT OUTPUT.X x
-OUTPUT OUTPUT.Y y
-COEFFICIENT.1 A     # (a,0,0)
-COEFFICIENT.2 K/M_x # k/m for x
-COEFFICIENT.3 V0    # (0,v0,0)
-COEFFICIENT.4 K/M_y # k/m for y, identical to k/m for x
-
-PROGRAM DIVISION
--1 -> COEFFICIENT.A -> -a # has to be negative because x' is negative
-+1 -> COEFFICIENT.V0 -> v0 # has to be positive because y'' is positive
-
-x'' -> INTEGRATOR -> -x'
--x', IC:-a -> INTEGRATOR -> x
-x -> COEFFICIENT.K/M_x -> k/m*x
-k/m*x -> INVERTER -> -k/m*x = x''
-
-y'', IC:v0 -> INTEGRATOR -> -y'
--y' -> INTEGRATOR -> y
-y -> COEFFICIENT.K/M_y -> k/m*y
-k/m*y -> INVERTER -> -k/m*y = y''
-
-OPERATION DIVISION
-MODE REPEAT
-OP-TIME 100 ms
diff --git a/scripts/TP1 04.12 Harmonic Oscillator.LACE b/scripts/TP1 04.12 Harmonic Oscillator.LACE
new file mode 100644 (file)
index 0000000..89b0723
--- /dev/null
@@ -0,0 +1,31 @@
+# Harmonic Oscillator
+# A mass m is subject to a force F=-k*r.
+# What is the trajectory if the mass starts at position (a,0,0)?
+# How much time does it take to pass through zero?
+# What is the trajectory if it starts at (a,0,0) with velocity (0,v0,0)?
+# Compare to the case including gravity on earth in x direction
+# m*x'' = -k*x +       g
+# m*y'' = -k*y (z can be set to 0).
+
+coefficient.1(-1) -> -a    # (a,0,0), has to be negative because x' is negative
+coefficient.2     -> k/m_x # k/m for x
+coefficient.3(+1) -> v0    # (0,v0,0), has to be positive because y'' is positive
+coefficient.4     -> k/m_y # k/m for y, identical to k/m for x
+coefficient.5(-1) -> -g     # g
+
+iintegrate x'' -> -x'
+iintegrate -x' -> x
+   IC: -a
+cmultiply (k/m_x, x) -> k/m*x
+isum (k/m*x, -g) -> -k/m*x+g
+assign (-k/m*x+g) -> x''
+
+iintegrate y'' -> -y'
+   IC: v0
+iintegrate -y' -> y
+cmultiply (k/m_y, y) -> k/m*y
+invert (k/m*y) -> -k/m*y
+assign (-k/m*y) -> y''
+
+output x -> out.x
+output.y -> out.y
diff --git a/scripts/TP1 07.19 Falling Mass.SALSA b/scripts/TP1 07.19 Falling Mass.SALSA
deleted file mode 100644 (file)
index 3f3dc6b..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-# Wiring mache ich von links nach rechts !!!
-
-...IDENTIFICATION DIVISION
-...PROGRAM-ID FallingParticle
-...VERSION 20240225
-...COMMENT Calculate the deflection from the vertical caused by the Earth's rotation of a particle falling freely from rest from a height h.
-...COMMENT Differential Equations:
-...COMMENT    x''=-bz'+ay' # x-axis is along latitude,  directed to east
-...COMMENT    y''=-ax'     # y-axis is along longitude, directed to north
-...COMMENT    z''=-g+ax'   # z-axis is perpendicular to the surface of earth
-...COMMENT    g: gravitational acceleration = 9,81 m/s²
-...COMMENT    a: 2*omega*sin(phi)
-...COMMENT    b: 2*omega*cos(phi)
-...COMMENT    omega: rotation velocity of the earth = 2*pi/day
-...COMMENT    phi: Latitude of location (0-90°)
-...COMMENT    Initial Condition: z(0)=h
-...COMMENT The full solution requires 6 INTEGRATORs, Anabrid-THAT just has 5. The deflection to longitude (y) is neglegible and can be omitted (marked #*).
-...COMMENT It could also be solved in a separated algorithm omitting x.
-
-...ENVIRONMENT DIVISION
-...TIMEBASE 1ms
-
-...DATA DIVISION
-SET COEFFICIENT.1 TO AY # 2*2pi/day*sin(phi)
-SET COEFFICIENT.2 TO AX # = AY
-SET COEFFICIENT.3 TO B  # 2*2pi/day*cos(phi)
-SET COEFFICIENT.4 TO G  # gravitational acceleration = 9,81 m/s²
-SET COEFFICIENT.5 TO H  # height h
-SET OUTPUT.X TO x
-SET OUTPUT.Y TO y
-SET OUTPUT.Z TO z
-
-INITIALIZE H by -1 TO -h # same as COMPUTE -1 TIMES H TO -h
-INITIALIZE G by +1 TO g
-
-INTEGRATE 1*-bz',1*ay' TO -x' # Input is x''
-INTEGRATE -x' TO x
-
-INTEGRATE y'' TO -y'
-INTEGRATE -y' TO y   
-
-INTEGRATE z'' TO -z' 
-INTEGRATE -z', IC:-h, LIMIT:(z >= 0) TO z
-
--x' * AX -> -ax'
--ax' = y''
--y' * AY -> -ay'
-INVERT -ay' TO ay'
--z' * B -> -bz'
-ADD 1*-ax', 1*g TO -g+ax'
--g+ax' = z''
-
-...OPERATION DIVISION
-...MODE REPEAT
-...OP-TIME 7,3ms