LPFP-core-1.1.1: Code for the book Learn Physics with Functional Programming
Copyright(c) Scott N. Walck 2023
LicenseBSD3 (see LICENSE)
MaintainerScott N. Walck <walck@lvc.edu>
Stabilitystable
Safe HaskellSafe-Inferred
LanguageHaskell2010

LPFPCore.Mechanics1D

Description

Code from chapter 15 of the book Learn Physics with Functional Programming

Synopsis

Documentation

type Time = R Source #

type Mass = R Source #

type Force = R Source #

euler1D :: R -> (State1D -> (R, R, R)) -> State1D -> State1D Source #

eulerCromer1D :: R -> (State1D -> (R, R, R)) -> State1D -> State1D Source #

type UpdateFunction s = s -> s Source #

An update function takes a state as input and returns an updated state as output.

type DifferentialEquation s ds = s -> ds Source #

A differential equation takes a state as input and returns as output the rate at which the state is changing.

type NumericalMethod s ds = DifferentialEquation s ds -> UpdateFunction s Source #

A numerical method turns a differential equation into a state-update function.

solver :: NumericalMethod s ds -> DifferentialEquation s ds -> s -> [s] Source #

Given a numerical method, a differential equation, and an initial state, return a list of states.

class RealVectorSpace ds where Source #

A real vector space allows vector addition and scalar multiplication by reals.

Methods

(+++) :: ds -> ds -> ds Source #

scale :: R -> ds -> ds Source #

Instances

Instances details
RealVectorSpace DParticleFieldState Source # 
Instance details

Defined in LPFPCore.Lorentz

RealVectorSpace DParticleState Source # 
Instance details

Defined in LPFPCore.Mechanics3D

RealVectorSpace DMultiParticleState Source # 
Instance details

Defined in LPFPCore.MultipleObjects

RealVectorSpace (R, R) Source # 
Instance details

Defined in LPFPCore.Mechanics1D

Methods

(+++) :: (R, R) -> (R, R) -> (R, R) Source #

scale :: R -> (R, R) -> (R, R) Source #

RealVectorSpace (R, R, R) Source #

A triple of real numbers is a real vector space.

Instance details

Defined in LPFPCore.Mechanics1D

Methods

(+++) :: (R, R, R) -> (R, R, R) -> (R, R, R) Source #

scale :: R -> (R, R, R) -> (R, R, R) Source #

class RealVectorSpace ds => Diff s ds where Source #

A type class that expresses a relationship between a state space and a time-derivative-state space.

Methods

shift :: R -> ds -> s -> s Source #

Instances

Instances details
Diff ParticleFieldState DParticleFieldState Source # 
Instance details

Defined in LPFPCore.Lorentz

Diff ParticleState DParticleState Source # 
Instance details

Defined in LPFPCore.Mechanics3D

Diff MultiParticleState DMultiParticleState Source # 
Instance details

Defined in LPFPCore.MultipleObjects

Diff State1D (R, R, R) Source #

A triple of real numbers can serve as the time derivative of a State1D.

Instance details

Defined in LPFPCore.Mechanics1D

Methods

shift :: R -> (R, R, R) -> State1D -> State1D Source #

Diff (Time, Velocity) (R, R) Source # 
Instance details

Defined in LPFPCore.Mechanics1D

Methods

shift :: R -> (R, R) -> (Time, Velocity) -> (Time, Velocity) Source #

euler :: Diff s ds => R -> (s -> ds) -> s -> s Source #

Given a step size, return the numerical method that uses the Euler method with that step size.

rungeKutta4 :: Diff s ds => R -> (s -> ds) -> s -> s Source #

Given a step size, return the numerical method that uses the 4th order Runge Kutta method with that step size.

update2 :: (R, R, R) -> (R, R, R) Source #

forces :: R -> [State1D -> R] Source #

vdp :: R -> [(R, R)] Source #