--- /dev/null
+# collection of compound functions which can be realized with THAT
+
+# Open Amplifier
+define openamp (weight*: variable-1, …) -> output
+ isum (weight*: variable-1, …) -> output
+ connect (FB:) -> GND
+
+# Division
+define idivide (numerator, denominator) -> -quotient
+ openamp (numerator, product) -> -quotient
+ multiply (-quotient, denominator) -> product
+
+# Integration extension
+define iintegrate (weight*: variable-1, …, ic: variable-IC, limit: gt0) -> variable-n
+ iintegrate (weight*: variable-1, …) -> variable-n
+ diode (cat:variable-n) -> DA
+ connect (DA) -> sj
+# diode and connect used to limit the result to values >0
+
+# Building an additional integrator with the help of an openamp
+define iintegrate.additional (variable) -> integral
+ openamp variable -> integral
+ connect SJ -> cp
+ capacitor.100nF (integral) -> cp
+# NB: The 100 nF capacitor is available on a THAT. This capacitance corresponds to those of the SLOW settings. In order to use the standard time constant an external 1 nF capacitor has to be used.
+
+# Summing extension
+define isum (weight*: variable-1, …, /divisor) -> -result
+ isum (weight*: variable-1, …) -> -result
+ connect (-result, …) -> IN
--- /dev/null
+#PROGRAM-ID ChargeInEMfield
+#VERSION 20240116
+# A mass m with charge q>0 is located in a static electro-magnetic field [0,0,E], [0,-B,0].
+# Find the trajetory
+# Differential equation (Lorentz force):
+# x'' = omega*z'
+# z'' = a*omega^2 - omega*x'
+# good start settings are omega=0,92, a*omega^2=0,05
+
+# coefficient definition
+alias coefficient.1 -> omega_x # -omega for x'
+coefficient.2 (+1) -> a*omega^2
+alias coefficient(3) -> omega_z # omega for z'
+
+# solving the DE
+iintegrate (x'') -> -x'
+iintegrate (-x') -> x
+
+coefficient.omega_x (-x') -> -omega*x'
+#cmultiply (-x', omega_x) -> omega*x'
+
+iintegrate (a*omega^2, -omega*x') -> -z' # input is z''
+iintegrate (-z') -> z
+invert (-z') -> z'
+
+coefficient.omega_z (z') -> omega*z'
+#cmultiply (z', omega_z) -> omega*z'
+assign omega*z' -> x''
+
+output(x) -> out.x
+output(z) -> out.z
# equation of motion:
# mu'' = - g/4a * mu, with mu = sin(phi/2) and phi a parameter of the cycloid
-coefficient(1): g/4a
-coefficient(2): 1 -> mu0'
-coefficient(3): -1 -> -mu0
-coefficient(4): 4ax
-coefficient(5): 4ay # same as 4ax
+alias coefficient.1 g/4a
+coefficient.2 (+1) -> mu0'
+coefficient.3 (-1) -> -mu0
+alias coefficient.4 4ax
+alias coefficient.5 4ay # same as 4ax
iintegrate mu'' -> -mu'
IC: mu0'
iintegrate -mu' -> mu
IC: -mu0
invert mu -> -mu
--mu * g/4a -> -g/4a*mu
-mu'' = -g/4a*mu
+coefficient.g/4a (-mu) -> -g/4a*mu
+assign -g/4a*mu -> mu''
# the following is for displaying the cycloid in x-y space
# calculating x (NB: this includes some unacceptable approximations)
-mu * 4ax -> 4a*mu
-output(x): 4a*mu
+coefficient.4ax (mu) -> 4a*mu
+output(4a*mu) -> out.x
# calculating y
multiply mu, mu -> mu^2
-mu^2 * 4ay -> 4ay*mu^2
+coefficient.4ay (mu^2) -> 4ay*mu^2
isum 4a*mu^2 -> -2a*mu^2 # just serves to devide by 2 because we need 2a instead of 4a
/2
invert -2a*mu^2 -> 2a*mu^2
-output(y): 2a*mu^2
+output(2a*mu^2) -> out.y
# display mu, so the sinus
-output(z): mu
+output(mu) -> out.z
# NB: all integrators have to run with 100 nF capacitance, i.e. SLOW mode
-coefficient(1): omega0^2_1 # omega0^2 for s1
-coefficient(2): omega0^2_2 # omega0^2 for s2 # same as omega0^2_1
-coefficient(3): omega0^2_3 # omega0^2 for s3 # same as omega0^2_1
-coefficient(4): my
-coefficient(5): -1 -> -s1_0 # initial position of s1
-coefficient(6): -1 -> -s3_0 # initial position of s3
+# the following integrator has to be built up manually as THAT only has 5 integrators and we need 6
+# iintegrate -s2' -> s2
+define openamp (variable) -> result
+ isum (variable) -> result
+ connect (FB) -> GND
+
+define iintegrate6 (variable) -> integral
+ openamp variable -> integral
+ connect SJ -> cp
+ capacitor.100nF (integral) -> cp
+# this capacitance requires SLOW settings on all other capacitors. Better use an external 1 nF capacitor.
+
+alias coefficient.1 -> coefficient.omega0^2_1 # omega0^2 for s1
+alias coefficient.2 -> coefficient.omega0^2_2 # omega0^2 for s2 # same as omega0^2_1
+alias coefficient.3 -> coefficient.omega0^2_3 # omega0^2 for s3 # same as omega0^2_1
+alias coefficient.4 -> coefficient.my
+coefficient.5 (-1) -> -s1_0 # initial position of s1
+coefficient.6 (-1) -> -s3_0 # initial position of s3
# initial positon of s2, the central mass, is set to 0
iintegrate -omega0^2_1*s1, omega0^2_2*s2 -> -s1' # input is s1''
iintegrate -s1' -> s1
IC: -s1_0
invert s1 -> -s1
--s1 * omega0^2_1 -> -omega0^2_1*s1
+coefficient.omega0^2_1 (-s1) -> -omega0^2_1*s1
iintegrate -my*bracket -> -s2' # input is s2''
-# the following integrator has to be built up manually as THAT only has 5 integrators and we need 6
-# iintegrate -s2' -> s2
-openamp -s2' -> s2
- loopback: capacitor(100nF)
-s2 * omega0^2_2 -> omega0^2_2*s2
+iintegrate6 -s2' -> s2
+coefficient.omega0^2_2 (s2) -> omega0^2_2*s2
isum -omega0^2_1*s1, omega0^2_2*s2, omega0^2_2*s2, -omega0^2_3*s3 -> -bracket
--bracket * my -> -my*bracket
+coefficient.my (-bracket) -> -my*bracket
iintegrate omega0^2_2*s2, -omega0^2_3*s3 -> -s3' # input is s3''
iintegrate -s3' -> s3
IC: -s3_0
invert s3 -> -s3
--s3 * omega0^2_3 -> -omega0^2_3*s3
+coefficient.omega0^2_3 (-s3) -> -omega0^2_3*s3
+
+output s1 -> out.x
+output s2 -> out.y
+output s3 -> out.z
- output(x): s1
- output(y): s2
- output(z): s3
--- /dev/null
+# Determine the potential (inside and outside) of a charged sphere (radius R) with a constant internal charge density rho0.
+#
+# phi(r)'' = -rho0/epsilon0 - 2/r * phi(r)'
+# with rho0 = 0 outside of sphere
+# using t as variable for r
+#
+# compound functions used:
+# Open Amplifier
+define openamp (weight*: variable-1, weight*: variable-2) -> output
+ isum (weight*: variable-1, weight*: variable-2) -> output
+ connect (FB:) -> GND
+
+# Division
+define idivide (numerator, denominator) -> -quotient
+ openamp (numerator, product) -> -quotient
+ multiply (-quotient, denominator) -> product
+
+# coefficients
+coefficient.1 -> factor0,2 # shall be set to 0.2
+coefficient.2 (-1) -> -rho0/epsilon0
+coefficient.3 (-1) -> -phi0
+coefficinet.4 (-1) -> -R # -radius of sphere
+
+# generate a ramp of t
+iintegrate (-1) -> t
+
+# distinguish in sphere or outside
+compare (t, -R) -> -rho/epsilon0_l
+ LT0: -rho/epsilon0 # in sphere,
+ GT0: GND # outside sphere
+
+# calculate phi
+iintegrate (1*: -rho0/epsilon0_l, 10*: -0.2/r*phi') -> -phi' # need 2/r*phi' thus 10* input
+iintegrate (-phi') -> phi
+ IC: -phi0
+invert(-phi') -> phi'
+
+# doing this division by t first because phi' is low when also t is, thus there is the chance of less overload
+idivide (phi', t) -> -phi'/t
+cmultiply (-phi'/t, factor0.2) -> -0.2/r*phi'
+
+output(t) -> out.x
+output(phi') -> out.y
+output(phi) -> out.z
--- /dev/null
+IDENTIFICATION DIVISION
+PROGRAM-ID ...
+VERSION ...
+COMMENT ...
+
+ENVIRONMENT DIVISION
+ENGINE Anabrid-THAT
+TIMEBASE 1ms
+REQUIRES ...
+
+DATA DIVISION
+INPUT ...
+OUTPUT OUTPUT.X ...
+OUTPUT OUTPUT.Y ...
+OUTPUT OUTPUT.Z ...
+OUTPUT OUTPUT.U ...
+COEFFICIENT.n ...
+
+PROGRAM DIVISION
+# INTEGRATOR is inverting!
+# SUMMER is inverting!
+...
+
+OPERATION DIVISION
+MODE REPEAT
+OP-TIME ...