11> module NewtonianMechanics.SingleParticle where
22
3- % < import Calculus.SyntaxTree
4-
53> import Test.QuickCheck
64
75Laws:
@@ -20,8 +18,8 @@ mathmatical functions in previous chapters we won't spend any time on them here
2018and instead just import those two modules.
2119
2220> import Calculus.FunExpr
23- > import Calculus.DifferentialCalc -- Maybe remove
24- > import Calculus.IntegralCalc -- Maybe remove
21+ > import Calculus.DifferentialCalc
22+ > import Calculus.IntegralCalc
2523> import Vector.Vector as V
2624
2725 The mass of a particle is just a scalar value so we'll model it using
@@ -35,11 +33,13 @@ type `VectorE` to signify that it's a vector of expressions.
3533
3634> type VectorE = Vector3 FunExpr
3735
36+ > type Position = Vector3 FunExpr
37+
3838Now we are ready to define what the data type for a particle is. As we
39- previously stated a point particle has a mass, and a position given as a vector
40- of function expressions. So our data type is simply:
39+ previously stated a point particle has a position given as a vector
40+ of function expressions, and a mass . So our data type is simply:
4141
42- > data Particle = P { pos :: VectorE -- Position as a function of time, unit m
42+ > data Particle = P { pos :: Position -- Position as a function of time, unit m
4343> , mass :: Mass -- Mass, unit kg
4444> } deriving Show
4545
@@ -282,17 +282,14 @@ equal to the change in kinetic energy $E_k$ of the particle:
282282
283283Let's codify this theorem:
284284
285- PS: This used to work just fine, but it no longer does since the switch to
286- FunExpr. Problem probably lies somewhere in SyntaxTree
287-
288- < prop_WorkEnergyTheorem :: Mass -> VectorE -> VectorE -> IO Bool
289- < prop_WorkEnergyTheorem m v1 v2 = prettyEqual deltaEnergy (kineticEnergy displacedParticle)
290- < where
291- < particle1 = P v1 m -- | Two particles with the same mass
292- < particle2 = P v2 m -- | But different position vector
293- < -- | E_k,2 - E_k,1
294- < deltaEnergy = kineticEnergy particle2 - kineticEnergy particle1
295- < displacedParticle = P (v2 - v1) m
285+ > prop_WorkEnergyTheorem :: Mass -> Position -> Position -> Bool
286+ > prop_WorkEnergyTheorem m p1 p2 = deltaEnergy == kineticEnergy displacedParticle
287+ > where
288+ > particle1 = P p1 m -- | Two particles with the same mass
289+ > particle2 = P p2 m -- | But different position vector
290+ > -- | E_k,2 - E_k,1
291+ > deltaEnergy = kineticEnergy particle2 - kineticEnergy particle1
292+ > displacedParticle = P (p2 - p1) m
296293
297294< -- Test values
298295< v1 = V3 (3 :* Id ) (2 :* Id ) (1 :* Id )
0 commit comments