11> module NewtonianMechanics.SingleParticle where
22
3- > import Calculus.Calculus
43> import Calculus.SyntaxTree
54> import Test.QuickCheck
6- > import Vector.Vector as V
75
86Laws:
97
108- A body remains at rest or in uniform motion unless acted upon by a force.
119- A body acted upon by a force moves in such a manner that the time rate of change of the momentum equals the force.
1210- If two bodies exert forces on each other, these forces are equal in magnitude and opposite in direction.
1311
14- > type Time = Double
15- > type Mass = FunExpr
12+ We will begin our journey into classical mechanics by studying point particles.
13+ A point particle has a mass and it's position is given as vector in three
14+ dimensions. Of course it could exist in any number of dimensions but we'll stay
15+ in three dimensions since it is more intuitive and easier to understand.
16+
17+ The components of the vector are functions over time that gives the particles
18+ position in each dimension, x, y, and z. Since we've already defined vectors and
19+ mathmatical functions in previous chapters we won't spend any time on them here
20+ and instead just import those two modules.
21+
22+ > import Calculus.Calculus
23+ > import Vector.Vector as V
24+
25+ The mass of a particle is just a numerical value so we'll model it using
26+ doubles.
27+
28+ < type Mass = Double
29+
30+ \ignore {
31+
32+ > type Mass = FunExpr
33+
34+ }
35+
36+ We combine the constructor for vectors in three dimensions with the function
37+ expressions defined in the chapter on mathmatical analysis. We'll call this new
38+ type `VectorE` to signify that it's a vector of expressions.
39+
1640> type VectorE = Vector3 FunExpr
1741
42+ Now we are ready to define what the data type for a particle is. As we
43+ previously stated a point particle has a mass, and a position given as a vector
44+ of function expressions. So our data type is simply:
1845
1946> data Particle = P { pos :: VectorE -- Position as a function of time, unit m
20- > -- , time :: Time -- Time, unit s
21- > , mass :: Mass -- Mass, unit kg
47+ > , mass :: Mass -- Mass, unit kg
2248> } deriving Show
2349
24- Velocity, derivative of pos with respect to time
25- unit m*s^-1
50+ So now we can create our particles! Let's try it out!
51+
52+ `` `
53+ ghci > let particle = P (V3 (3 :* Id :* Id) (2 :* Id) 1) 3
54+ ghci > particle
55+ P {pos = (((3 * id) * id) x, (2 * id) y, 1 z), mass = 3}
56+ `` `
57+
58+ We've created our first particle! And as we can see from the print out it's
59+ accelerating by $ 3 t^2 $ in the x-dimension, has a constant velocity of $ 2
60+ t$ in the y-dimension, is positioned at $ 1 $ in the z-dimension, and has a
61+ mass of $ 3 $ .
62+
63+ Velocity & Acceleration
64+ ------------------
65+
66+ Velocity is defined as the derivative of the position with respect to time. More
67+ formally:
68+
69+ \begin {equation* }
70+ \vec {v} = \frac {d\vec {p}}{dt}
71+ \end {equation* }
72+
73+ And since the position of our particles are given as vectors we'll do the
74+ derivation component-wise. We need not worry about the details of the derivation
75+ at all since this is all take care of by the Calculus module, all we need to to
76+ is use the constructor `D` for the derivative and apply it to each of the
77+ components of the vector. The business of applying something to each component
78+ of a vector has also already been taken care of! This was the point of `vmap` to
79+ map a function over the components of the vector. So if we combine them we get a
80+ rather elegant way of computing the velocity of a particle.
2681
2782> velocity :: Particle -> VectorE
2883> velocity = vmap D . pos
2984
85+ Acceleration is defined as the derivative of the velocity with respect to time,
86+ or the second derivative of the position. More formally:
87+
88+ \begin {equation* }
89+ \vec {a} = \frac {d\vec {v}}{dt} = \frac {d^2\vec {p}}{dt^2}
90+ \end {equation* }
91+
92+ **Exercise** Try to figure out how to define the function for calculating the
93+ acceleration of a particle
94+
3095Forces & Newton's second law
3196------------------------------
3297
@@ -36,6 +101,8 @@ as follows:
36101 \vec {F} = \frac {d \vec {p}}{d t} = \frac {d(m \cdot \vec {v})}{d t}
37102\end {equation }
38103
104+
105+
39106The quantity $ m \cdot v$ is what we mean when we say momentum. So the law
40107states that the net force on a particle is equal to the rate of change of the
41108momentum with respect to time. And since the definition of acceleration is $ a =
@@ -48,6 +115,7 @@ momentum with respect to time. And since the definition of acceleration is $a =
48115And thus if the particle is accelerating we can calculate the net force that
49116must be acting on it, in code this would be:
50117
118+
51119> force :: Particle -> VectorE
52120> force p = vmap (* m) a
53121> where
0 commit comments