learn-physics-0.6.2: Haskell code for learning physics

Copyright(c) Scott N. Walck 2014
LicenseBSD3 (see LICENSE)
MaintainerScott N. Walck <walck@lvc.edu>
Stabilityexperimental
Safe HaskellTrustworthy
LanguageHaskell98

Physics.Learn.Mechanics

Contents

Description

Newton's second law and all that

Synopsis

Documentation

type TheTime = Double #

Time (in s).

type TimeStep = Double #

A time step (in s).

type Velocity = Vec #

Velocity of a particle (in m/s).

Simple one-particle state

type SimpleState = (TheTime, Position, Velocity) #

A simple one-particle state, to get started quickly with mechanics of one particle.

type SimpleAccelerationFunction = SimpleState -> Vec #

An acceleration function gives the particle's acceleration as a function of the particle's state. The specification of this function is what makes one single-particle mechanics problem different from another. In order to write this function, add all of the forces that act on the particle, and divide this net force by the particle's mass. (Newton's second law).

simpleStateDeriv #

Arguments

:: SimpleAccelerationFunction

acceleration function for the particle

-> DifferentialEquation SimpleState

differential equation

Time derivative of state for a single particle with a constant mass.

simpleRungeKuttaStep #

Arguments

:: SimpleAccelerationFunction

acceleration function for the particle

-> TimeStep

time step

-> SimpleState

initial state

-> SimpleState

state after one time step

Single Runge-Kutta step

One-particle state

data St #

The state of a single particle is given by the position of the particle and the velocity of the particle.

Constructors

St 
Instances
Show St # 
Instance details

Defined in Physics.Learn.Mechanics

Methods

showsPrec :: Int -> St -> ShowS #

show :: St -> String #

showList :: [St] -> ShowS #

StateSpace St # 
Instance details

Defined in Physics.Learn.Mechanics

Associated Types

type Diff St :: * #

Methods

(.-.) :: St -> St -> Diff St #

(.+^) :: St -> Diff St -> St #

type Diff St # 
Instance details

Defined in Physics.Learn.Mechanics

type Diff St = DSt

data DSt #

The associated vector space for the state of a single particle.

Constructors

DSt Vec Vec 
Instances
Show DSt # 
Instance details

Defined in Physics.Learn.Mechanics

Methods

showsPrec :: Int -> DSt -> ShowS #

show :: DSt -> String #

showList :: [DSt] -> ShowS #

VectorSpace DSt # 
Instance details

Defined in Physics.Learn.Mechanics

Associated Types

type Scalar DSt :: * #

Methods

(*^) :: Scalar DSt -> DSt -> DSt #

AdditiveGroup DSt # 
Instance details

Defined in Physics.Learn.Mechanics

Methods

zeroV :: DSt #

(^+^) :: DSt -> DSt -> DSt #

negateV :: DSt -> DSt #

(^-^) :: DSt -> DSt -> DSt #

type Scalar DSt # 
Instance details

Defined in Physics.Learn.Mechanics

type OneParticleSystemState = (TheTime, St) #

The state of a system of one particle is given by the current time, the position of the particle, and the velocity of the particle. Including time in the state like this allows us to have time-dependent forces.

type OneParticleAccelerationFunction = OneParticleSystemState -> Vec #

An acceleration function gives the particle's acceleration as a function of the particle's state.

oneParticleStateDeriv #

Arguments

:: OneParticleAccelerationFunction

acceleration function for the particle

-> DifferentialEquation OneParticleSystemState

differential equation

Time derivative of state for a single particle with a constant mass.

oneParticleRungeKuttaStep #

Arguments

:: OneParticleAccelerationFunction

acceleration function for the particle

-> TimeStep

time step

-> OneParticleSystemState

initial state

-> OneParticleSystemState

state after one time step

Single Runge-Kutta step

oneParticleRungeKuttaSolution #

Arguments

:: OneParticleAccelerationFunction

acceleration function for the particle

-> TimeStep

time step

-> OneParticleSystemState

initial state

-> [OneParticleSystemState]

state after one time step

List of system states

Two-particle state

type TwoParticleSystemState = (TheTime, St, St) #

The state of a system of two particles is given by the current time, the position and velocity of particle 1, and the position and velocity of particle 2.

type TwoParticleAccelerationFunction = TwoParticleSystemState -> (Vec, Vec) #

An acceleration function gives a pair of accelerations (one for particle 1, one for particle 2) as a function of the system's state.

twoParticleStateDeriv #

Arguments

:: TwoParticleAccelerationFunction

acceleration function for two particles

-> DifferentialEquation TwoParticleSystemState

differential equation

Time derivative of state for two particles with constant mass.

twoParticleRungeKuttaStep #

Arguments

:: TwoParticleAccelerationFunction

acceleration function

-> TimeStep

time step

-> TwoParticleSystemState

initial state

-> TwoParticleSystemState

state after one time step

Single Runge-Kutta step for two-particle system

Many-particle state

type ManyParticleSystemState = (TheTime, [St]) #

The state of a system of many particles is given by the current time and a list of one-particle states.

type ManyParticleAccelerationFunction = ManyParticleSystemState -> [Vec] #

An acceleration function gives a list of accelerations (one for each particle) as a function of the system's state.

manyParticleStateDeriv #

Arguments

:: ManyParticleAccelerationFunction

acceleration function for many particles

-> DifferentialEquation ManyParticleSystemState

differential equation

Time derivative of state for many particles with constant mass.

manyParticleRungeKuttaStep #

Arguments

:: ManyParticleAccelerationFunction

acceleration function

-> TimeStep

time step

-> ManyParticleSystemState

initial state

-> ManyParticleSystemState

state after one time step

Single Runge-Kutta step for many-particle system