Copyright | (c) Scott N. Walck 2023 |
---|---|
License | BSD3 (see LICENSE) |
Maintainer | Scott N. Walck <walck@lvc.edu> |
Stability | stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Code from chapters 16, 17, and 18 of the book Learn Physics with Functional Programming
Synopsis
- data ParticleState = ParticleState {}
- defaultParticleState :: ParticleState
- rockState :: ParticleState
- type OneBodyForce = ParticleState -> Vec
- data DParticleState = DParticleState {}
- newtonSecondPS :: [OneBodyForce] -> ParticleState -> DParticleState
- earthSurfaceGravity :: OneBodyForce
- sunGravity :: OneBodyForce
- airResistance :: R -> R -> R -> OneBodyForce
- windForce :: Vec -> R -> R -> R -> OneBodyForce
- uniformLorentzForce :: Vec -> Vec -> OneBodyForce
- eulerCromerPS :: TimeStep -> NumericalMethod ParticleState DParticleState
- statesPS :: NumericalMethod ParticleState DParticleState -> [OneBodyForce] -> ParticleState -> [ParticleState]
- updatePS :: NumericalMethod ParticleState DParticleState -> [OneBodyForce] -> ParticleState -> ParticleState
- positionPS :: NumericalMethod ParticleState DParticleState -> [OneBodyForce] -> ParticleState -> Time -> PosVec
- class HasTime s where
- constantForce :: Vec -> OneBodyForce
- moonSurfaceGravity :: OneBodyForce
- earthGravity :: OneBodyForce
- tvyPair :: ParticleState -> (R, R)
- tvyPairs :: [ParticleState] -> [(R, R)]
- tle1yr :: ParticleState -> Bool
- stateFunc :: [ParticleState] -> Time -> ParticleState
- airResAtAltitude :: R -> R -> R -> OneBodyForce
- projectileRangeComparison :: R -> R -> (R, R, R)
- halleyUpdate :: TimeStep -> ParticleState -> ParticleState
- halleyInitial :: ParticleState
- baseballForces :: [OneBodyForce]
- baseballTrajectory :: R -> R -> R -> [(R, R)]
- zGE0 :: [ParticleState] -> [ParticleState]
- trajectory :: [ParticleState] -> [(R, R)]
- baseballRange :: R -> R -> R -> R
- bestAngle :: (R, R)
- projectileUpdate :: TimeStep -> ParticleState -> ParticleState
- projectileInitial :: [String] -> ParticleState
- protonUpdate :: TimeStep -> ParticleState -> ParticleState
- protonInitial :: ParticleState
- apR :: R
- wallForce :: OneBodyForce
- energy :: ParticleState -> R
- firstOrbit :: ParticleState -> Bool
- relativityPS :: [OneBodyForce] -> ParticleState -> DParticleState
- twoProtUpdate :: TimeStep -> (ParticleState, ParticleState) -> (ParticleState, ParticleState)
- twoProtInitial :: (ParticleState, ParticleState)
- relativityPS' :: R -> [OneBodyForce] -> ParticleState -> DParticleState
Documentation
data ParticleState Source #
Data type for the state of a single particle in three-dimensional space.
Instances
HasTime ParticleState Source # | |
Defined in LPFPCore.Mechanics3D timeOf :: ParticleState -> Time Source # | |
Show ParticleState Source # | |
Defined in LPFPCore.Mechanics3D showsPrec :: Int -> ParticleState -> ShowS # show :: ParticleState -> String # showList :: [ParticleState] -> ShowS # | |
Diff ParticleState DParticleState Source # | |
Defined in LPFPCore.Mechanics3D shift :: R -> DParticleState -> ParticleState -> ParticleState Source # |
defaultParticleState :: ParticleState Source #
A default particle state.
type OneBodyForce = ParticleState -> Vec Source #
Data type for a one-body force.
data DParticleState Source #
Data type for the time-derivative of a particle state.
Instances
RealVectorSpace DParticleState Source # | |
Defined in LPFPCore.Mechanics3D (+++) :: DParticleState -> DParticleState -> DParticleState Source # scale :: R -> DParticleState -> DParticleState Source # | |
Show DParticleState Source # | |
Defined in LPFPCore.Mechanics3D showsPrec :: Int -> DParticleState -> ShowS # show :: DParticleState -> String # showList :: [DParticleState] -> ShowS # | |
Diff ParticleState DParticleState Source # | |
Defined in LPFPCore.Mechanics3D shift :: R -> DParticleState -> ParticleState -> ParticleState Source # |
:: [OneBodyForce] | |
-> ParticleState | |
-> DParticleState | a differential equation |
Given a list of forces, return a differential equation based on Newton's second law.
earthSurfaceGravity :: OneBodyForce Source #
The force of gravity near Earth's surface. The z direction is toward the sky. Assumes SI units.
sunGravity :: OneBodyForce Source #
The force of the Sun's gravity on an object. The origin is at center of the Sun. Assumes SI units.
:: R | drag coefficient |
-> R | air density |
-> R | cross-sectional area of object |
-> OneBodyForce |
The force of air resistance on an object.
:: Vec | wind velocity |
-> R | drag coefficient |
-> R | air density |
-> R | cross-sectional area of object |
-> OneBodyForce |
The force of wind on an object.
:: Vec | E |
-> Vec | B |
-> OneBodyForce |
The force of uniform electric and magnetic fields on an object.
eulerCromerPS :: TimeStep -> NumericalMethod ParticleState DParticleState Source #
Euler-Cromer method for the ParticleState
data type.
:: NumericalMethod ParticleState DParticleState | numerical method |
-> [OneBodyForce] | list of force funcs |
-> ParticleState | |
-> [ParticleState] | evolver |
Given a numerical method, a list of one-body forces, and an initial state, return a list of states describing how the particle evolves in time.
updatePS :: NumericalMethod ParticleState DParticleState -> [OneBodyForce] -> ParticleState -> ParticleState Source #
Given a numerical method and a list of one-body forces, return a state-update function.
:: NumericalMethod ParticleState DParticleState | |
-> [OneBodyForce] | list of force funcs |
-> ParticleState | initial state |
-> Time | |
-> PosVec | position function |
Given a numerical method, a list of one-body forces, and an initial state, return a position function describing how the particle evolves in time.
class HasTime s where Source #
Instances
HasTime ParticleFieldState Source # | |
Defined in LPFPCore.Lorentz timeOf :: ParticleFieldState -> Time Source # | |
HasTime ParticleState Source # | |
Defined in LPFPCore.Mechanics3D timeOf :: ParticleState -> Time Source # | |
HasTime MultiParticleState Source # | |
Defined in LPFPCore.MultipleObjects timeOf :: MultiParticleState -> Time Source # |
constantForce :: Vec -> OneBodyForce Source #
tle1yr :: ParticleState -> Bool Source #
stateFunc :: [ParticleState] -> Time -> ParticleState Source #
:: R | drag coefficient |
-> R | air density at sea level |
-> R | cross-sectional area of object |
-> OneBodyForce |
halleyUpdate :: TimeStep -> ParticleState -> ParticleState Source #
zGE0 :: [ParticleState] -> [ParticleState] Source #
trajectory :: [ParticleState] -> [(R, R)] Source #
projectileInitial :: [String] -> ParticleState Source #
protonUpdate :: TimeStep -> ParticleState -> ParticleState Source #
energy :: ParticleState -> R Source #
firstOrbit :: ParticleState -> Bool Source #
relativityPS :: [OneBodyForce] -> ParticleState -> DParticleState Source #
Given a list of forces, return a differential equation based on the theory of special relativity.
twoProtUpdate :: TimeStep -> (ParticleState, ParticleState) -> (ParticleState, ParticleState) Source #
relativityPS' :: R -> [OneBodyForce] -> ParticleState -> DParticleState Source #