Skip to content

Commit 811505c

Browse files
committed
Making headway on a grand unifying theory of particles
1 parent 78868b2 commit 811505c

File tree

3 files changed

+92
-42
lines changed

3 files changed

+92
-42
lines changed

Physics/src/Calculus/Calculus.lhs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,26 @@ left-associative, and set the precedence.
208208
> infixl 9 :.
209209

210210

211+
HEJ JOHAN! Vet inte vad du vill ha det här så lägger det bara mitt i ◕ ◡ ◕
212+
fattas några operationer eftersom jag inte visste hur du ville hantera dem.
213+
> instance Num FunExpr where
214+
> (+) = (:+)
215+
> (*) = (:*)
216+
> (-) = (:-)
217+
> fromInteger i = Const (fromInteger i)
218+
219+
> instance Fractional FunExpr where
220+
> (/) = (:/)
221+
> fromRational r = Const (fromRational r)
222+
223+
> instance Floating FunExpr where
224+
> pi = Const pi
225+
> exp a = Exp :. a
226+
> log a = Log :. a
227+
> sin a = Sin :. a
228+
> cos a = Cos :. a
229+
> asin a = Asin :. a
230+
> acos a = Acos :. a
211231

212232
A structure with class
213233
----------------------------------------------------------------------

Physics/src/Calculus/SyntaxTree.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ canonify (D e) = derive e
114114
-- | Catch all
115115
canonify (Const x) = Const x
116116
canonify Id = Id
117-
canonify Id = Id
118117
canonify e = error $ show e
119118

120119

Physics/src/NewtonianMechanics/SingleParticle.lhs

Lines changed: 72 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
> import Test.QuickCheck
88
> import Vector.Vector as V
99

10-
Laws
11-
1: A body remains at rest or in uniform motion unless acted upon by a force.
12-
2: A body acted upon by a force moves in such a manner that the time rate of
13-
change of the momentum equals the force.
14-
3: If two bodies exert forces on each other, these forces are equal in
15-
magnitude and opposite in direction.
10+
Laws:
11+
12+
- A body remains at rest or in uniform motion unless acted upon by a force.
13+
- A body acted upon by a force moves in such a manner that the time rate of change of the momentum equals the force.
14+
- If two bodies exert forces on each other, these forces are equal in magnitude and opposite in direction.
1615

1716
> type Time = Double
1817
> type Mass = FunExpr
@@ -30,15 +29,26 @@ unit m*s^-1
3029
> velocity :: Particle -> VectorE
3130
> velocity = vmap D . pos
3231

33-
Acceleration, derivative of velocity with respect to time
34-
unit m*s^-2
32+
Forces & Newton's second law
33+
------------------------------
3534

36-
> acceleration :: Particle -> VectorE
37-
> acceleration = vmap D . velocity
35+
This law expresses the relationship between force and momentum and is
36+
as follows:
37+
\begin{equation}
38+
\vec{F} = \frac{d \vec{p}}{d t} = \frac{d(m \cdot \vec{v})}{d t}
39+
\end{equation}
3840

39-
Force: F = m*a
40-
unit kg * m * s^-1
41-
this is a bit weird
41+
The quantity $m \cdot v$ is what we mean when we say momentum. So the law
42+
states that the net force on a particle is equal to the rate of change of the
43+
momentum with respect to time. And since the definition of acceleration is $a =
44+
\frac{d \vec{v}}{d t}$ we can write this law in a more familiar form, namely:
45+
46+
\begin{equation}
47+
\vec{F} = m \cdot \vec{a}
48+
\end{equation}
49+
50+
And thus if the particle is accelerating we can calculate the net force that
51+
must be acting on it, in code this would be:
4252

4353
> force :: Particle -> VectorE
4454
> force p = vmap (* m) a
@@ -48,12 +58,29 @@ this is a bit weird
4858

4959
> type Energy = FunExpr
5060

61+
Where the acceleration of particle is found by deriving the velocity of that
62+
same particle with respect to $t$:
63+
64+
> acceleration :: Particle -> VectorE
65+
> acceleration = vmap D . velocity
66+
5167
TODO: Write something here
5268

5369
> square :: VectorE -> FunExpr
5470
> square v = dotProd v v
5571

56-
1/2 m * v^2
72+
Work and energy
73+
---------------------
74+
75+
If a constant force $\vec{F}$ is applied to a particle that moves from
76+
position $\vec{r_1}$ to $\vec{r_2}$ then the *work* done by the force is defined
77+
as the dot product of the force and the vector of displacement.
78+
79+
\begin{equation}
80+
W = \vec{F} \cdot \Delta \vec{r}
81+
\end{equation}
82+
83+
where $\Delta \vec{r} = \vec{r_2} - \vec{r_1}$.
5784

5885
> kineticEnergy :: Particle -> Energy
5986
> kineticEnergy p = Const 0.5 * m * v2
@@ -67,7 +94,7 @@ total work *W* done on the particle as it moves from position $r_1$ to $r_2$ is
6794
equal to the change in kinetic energy $E_k$ of the particle:
6895

6996
\begin{equation}
70-
W = \delta E_K = E_{k,2} - E_{k,1} = \frac{1}{2} m (v^2_2 - v^2_1)
97+
W = \Delta E_K = E_{k,2} - E_{k,1} = \frac{1}{2} m (\vec{v_2}^2 - \vec{v_1}^2)
7198
\end{equation}
7299

73100
Let's codify this theorem:
@@ -77,7 +104,7 @@ Let's codify this theorem:
77104
> where
78105
> particle1 = P v1 m -- | Two particles with the same mass
79106
> particle2 = P v2 m -- | But different position vector
80-
> -- | E_k,2 - E_k,1
107+
> -- | E_k,2 - E_k,1
81108
> deltaEnergy = (kineticEnergy particle2) - (kineticEnergy particle1)
82109
> displacedParticle = P (v2 - v1) m
83110

@@ -90,51 +117,55 @@ Let's codify this theorem:
90117
> dE = (kineticEnergy p2) - (kineticEnergy p1)
91118
> p3 = P (v2 - v1) m
92119

93-
If a particles position is defined as a vector representing its displacement
94-
from some origin O, then its heigh should be x. Or maybe it should be the
95-
magnitude of the vector, if the gravitational force originates from O. Hmmm
96-
120+
Law of universal gravitation
121+
-------------------------------------
122+
Newton's law of universal gravitation states that a particle attracts every
123+
other particle in the universe with a force that is directly proportional to
124+
the product of their masses, and is inversely proportional to the square
125+
of the distance between their centers.
97126

98-
This seems so weird since I don't know what the frame of reference is...
127+
This means that every particle with mass attracts every other particle with
128+
mass by a force pointing along the line intersecting both points.
99129

100-
> potentialEnergy :: Particle -> Energy
101-
> potentialEnergy p = undefined
102-
> where
103-
> m = mass p
104-
> (V3 x _ _) = pos p
130+
There is an equation for calculating the magnitude of this force which
131+
states with math what we stated in words above:
105132

106133
\begin{equation}
107134
F = G \frac{m_1 m_2}{r^2}
108135
\end{equation}
109-
Where *F* is the force, *m1* and *m2* are the masses of the objects interacting,
110-
*r* is the distance between the centers of the masses and *G* is the
111-
gravitational constant.
136+
Where *F* is the maginitude of the force, *m1* and *m2* are the masses of the
137+
objects interacting, *r* is the distance between the centers of the masses and
138+
*G* is the gravitational constant.
112139

113-
> type Constant = FunExpr
140+
The gravitational constant has been finely approximated through experiments
141+
and we can state it out code like this:
114142

143+
> type Constant = FunExpr
144+
>
115145
> gravConst :: Constant
116146
> gravConst = 6.674 * (10 ** (-11))
117147

148+
Now we can codify the law of universal gravitation using our definition
149+
of particles.
150+
118151
> lawOfUniversalGravitation :: Particle -> Particle -> FunExpr
119152
> lawOfUniversalGravitation p1 p2 = gravConst * ((m1 * m2) / r2)
120153
> where
121154
> m1 = mass p1
122155
> m2 = mass p2
123156
> r2 = square $ (pos p2) - (pos p1)
124157

125-
> instance Num FunExpr where
126-
> (+) = (:+)
127-
> (*) = (:*)
128-
> (-) = (:-)
129-
> fromInteger i = Const (fromInteger i)
158+
If a particles position is defined as a vector representing its displacement
159+
from some origin O, then its heigh should be x. Or maybe it should be the
160+
magnitude of the vector, if the gravitational force originates from O. Hmmm
130161

131-
> instance Fractional FunExpr where
132-
> (/) = (:/)
133-
> fromRational r = Const (fromRational r)
162+
This seems so weird since I don't know what the frame of reference is...
134163

135-
> instance Floating FunExpr where
136-
> exp a = Exp :. a
137-
> log a = Exp :. a
164+
> potentialEnergy :: Particle -> Energy
165+
> potentialEnergy p = undefined
166+
> where
167+
> m = mass p
168+
> (V3 x _ _) = pos p
138169

139170
TODO!!!! Fix prettyCan $ lawOfUniversalGravitation p1 p2
140171

0 commit comments

Comments
 (0)