learn-physics-examples 0.3.1 → 0.5
raw patch · 6 files changed
+77/−108 lines, 6 filesdep ~learn-physicsdep ~not-glossdep ~spatial-mathnew-component:exe:learn-physics-Projectile
Dependency ranges changed: learn-physics, not-gloss, spatial-math
Files
- learn-physics-examples.cabal +29/−26
- src/DampedOscillator.hs +1/−0
- src/ElectricFluxPlot.hs +3/−1
- src/LorentzForceSimulation.hs +1/−1
- src/PlaneWave.hs +43/−0
- src/learn-physics-PlaneWave.hs +0/−80
learn-physics-examples.cabal view
@@ -1,5 +1,5 @@ Name: learn-physics-examples-Version: 0.3.1+Version: 0.5 Stability: Experimental Synopsis: examples for learn-physics Description: Executables that use the learn-physics library.@@ -9,58 +9,61 @@ Maintainer: Scott N. Walck <walck@lvc.edu> Category: Physics Build-type: Simple-Cabal-version: >=1.6-Tested-with: GHC == 7.6.3+Cabal-version: >=1.8+Tested-with: GHC == 7.8.2 Executable learn-physics-PlaneWave- Main-is: src/learn-physics-PlaneWave.hs- Build-depends: not-gloss >= 0.5.0 && < 0.6,- spatial-math >= 0.1.4 && < 0.2,+ Main-is: src/PlaneWave.hs+ Build-depends: not-gloss >= 0.6 && < 0.7, base >= 4.5 && < 4.8,- learn-physics >= 0.4.3+ learn-physics >= 0.5 && < 0.6 Executable learn-physics-eFieldLine3D Main-is: src/eFieldLine3D.hs- Build-depends: not-gloss >= 0.5.0 && < 0.6,- spatial-math >= 0.1.4 && < 0.2,+ Build-depends: not-gloss >= 0.6 && < 0.7, base >= 4.5 && < 4.8,- learn-physics >= 0.4.3+ learn-physics >= 0.5 && < 0.6 Executable learn-physics-LorentzForceSimulation Main-is: src/LorentzForceSimulation.hs- Build-depends: not-gloss >= 0.5.0 && < 0.6,- spatial-math >= 0.1.4 && < 0.2,+ Build-depends: not-gloss >= 0.6 && < 0.7,+ spatial-math >= 0.2 && < 0.3, base >= 4.5 && < 4.8,- learn-physics >= 0.4.3+ learn-physics >= 0.5 && < 0.6 Executable learn-physics-BCircularLoop Main-is: src/BCircularLoop.hs- Build-depends: not-gloss >= 0.5.0 && < 0.6,- spatial-math >= 0.1.4 && < 0.2,+ Build-depends: not-gloss >= 0.6 && < 0.7, base >= 4.5 && < 4.8,- learn-physics >= 0.4.3+ learn-physics >= 0.5 && < 0.6 Executable learn-physics-sunEarth Main-is: src/sunEarthRK4.hs Build-depends: gloss >= 1.8 && < 1.9, base >= 4.5 && < 4.8,- learn-physics >= 0.4.3+ learn-physics >= 0.5 && < 0.6 Executable learn-physics-eFieldLine2D Main-is: src/eFieldLine2D.hs Build-depends: gloss >= 1.8 && < 1.9, base >= 4.5 && < 4.8,- learn-physics >= 0.4.3+ learn-physics >= 0.5 && < 0.6 -Executable learn-physics-ElectricFluxPlot- Main-is: src/ElectricFluxPlot.hs+Executable learn-physics-Projectile+ Main-is: src/Projectile.hs Build-depends: gnuplot >= 0.5 && < 0.6, base >= 4.5 && < 4.8,- learn-physics >= 0.4.3+ learn-physics >= 0.5 && < 0.6 -Executable learn-physics-DampedOscillator- Main-is: src/DampedOscillator.hs- Build-depends: gnuplot >= 0.5 && < 0.6,- base >= 4.5 && < 4.8,- learn-physics >= 0.4.3+-- Executable learn-physics-ElectricFluxPlot+-- Main-is: src/ElectricFluxPlot.hs+-- Build-depends: gnuplot >= 0.5 && < 0.6,+-- base >= 4.5 && < 4.8,+-- learn-physics >= 0.5 && < 0.6++-- Executable learn-physics-DampedOscillator+-- Main-is: src/DampedOscillator.hs+-- Build-depends: gnuplot >= 0.5 && < 0.6,+-- base >= 4.5 && < 4.8,+-- learn-physics >= 0.5 && < 0.6
src/DampedOscillator.hs view
@@ -21,6 +21,7 @@ plot2 = plotList [Title "Damped Harmonic Oscillator" ,XLabel "Time (s)" ,YLabel "Voltage (V)"+ ,Key Nothing ] (map (\(t,x,_) -> (t,x)) $ take 1000 theStates) main :: IO ()
src/ElectricFluxPlot.hs view
@@ -15,7 +15,9 @@ plot1 :: IO () plot1 = plotFunc [Title "Electric flux produced by a 1-nC point charge through a sphere with radius 2m" ,YLabel "Electric flux (V m)"- ,XLabel "Displacement of point charge from center of sphere (m)"]+ ,XLabel "Displacement of point charge from center of sphere (m)"+ ,Key Nothing+ ] [-3.05,-2.95..3] (\x -> electricFlux (sphere 2 (cart 0 0 0)) (PointCharge 1e-9 (cart x 0 0))) -- | Electric flux plot
src/LorentzForceSimulation.hs view
@@ -10,7 +10,7 @@ drawFunction (_t,r,_v) = RotEulerDeg (Euler 270 0 0) $ RotEulerDeg (Euler 0 180 0) $ VisObjects [ Axes (0.5, 15)- , Trans (xyzFromPos r) (Sphere 0.1 Solid red)+ , Trans (v3FromPos r) (Sphere 0.1 Solid red) ] statePropagationFunction :: Float -> SimpleState -> SimpleState
+ src/PlaneWave.hs view
@@ -0,0 +1,43 @@+{-# OPTIONS_GHC -Wall #-}++module Main where++import Vis+ ( animate+ , VisObject(..)+ , red+ , blue+ )+import Physics.Learn.CarrotVec+ ( vec+ )+import Physics.Learn+ ( Position+ , VectorField+ , displayVectorField+ , cart+ , cartesianCoordinates+ )++samplePoints :: [Position]+samplePoints = [cart x y z | x <- [-2,0,2], y <- [-2,0,2], z <- [-4,-3.6..4]]++drawFun :: Float -> VisObject Double+drawFun time = VisObjects [displayVectorField blue 1 samplePoints (eField t)+ ,displayVectorField red 1 samplePoints (bField t)+ ]+ where+ t = realToFrac time++eField :: Double -> VectorField+eField t r = vec (cos (z - t)) 0 0+ where+ (_,_,z) = cartesianCoordinates r++bField :: Double -> VectorField+bField t r = vec 0 (cos (z - t)) 0+ where+ (_,_,z) = cartesianCoordinates r++main :: IO ()+main = animate Nothing "Plane Wave" drawFun
− src/learn-physics-PlaneWave.hs
@@ -1,80 +0,0 @@-{-# OPTIONS_GHC -Wall #-}--module Main where--import SpatialMath- ( Xyz(..)- )-import Vis- ( animate- , VisObject(..)- , Color- , red- , blue- )-import Physics.Learn.CarrotVec- ( Vec- , xComp- , yComp- , zComp- , vec- , magnitude- , (<.>)- )--pointList :: [Double]-pointList = [-2,0,2]---- samplePoints :: [Vec]--- samplePoints = [vec x y z | x <- [0], y <- [0], z <- [-4,-3.6..4]]--samplePoints :: [Vec]-samplePoints = [vec x y z | x <- [-2,0,2], y <- [-2,0,2], z <- [-4,-3.6..4]]--xyzFromVec :: Vec -> Xyz Double-xyzFromVec v = Xyz x y z- where- x = xComp v- y = yComp v- z = zComp v--thinArrow :: Double -> (Xyz Double) -> Color -> VisObject Double-thinArrow l = Arrow (l,10*l)--metersPerVPM :: Double-metersPerVPM = 1--eArrows :: Double -> [VisObject Double]-eArrows t = [Trans (xyzFromVec r) $ thinArrow (metersPerVPM * magnitude e) (xyzFromVec e) blue | (r,e) <- eFields t]--eFields :: Double -> [(Vec,Vec)]-eFields t = [(r,eField r t) | r <- samplePoints]--bArrows :: Double -> [VisObject Double]-bArrows t = [Trans (xyzFromVec r) $ thinArrow (metersPerVPM * magnitude b) (xyzFromVec b) red | (r,b) <- bFields t]--bFields :: Double -> [(Vec,Vec)]-bFields t = [(r,bField r t) | r <- samplePoints]--drawFun :: Float -> VisObject Double-drawFun time = VisObjects $ eArrows t ++ bArrows t- where- t = realToFrac time--c :: Double-c = 1--k :: Vec-k = vec 0 0 1--e0 :: Double-e0 = 1--eField :: Vec -> Double -> Vec-eField r t = vec (e0 * cos (k <.> r - c * magnitude k * t)) 0 0--bField :: Vec -> Double -> Vec-bField r t = vec 0 (e0 / c * cos (k <.> r - c * magnitude k * t)) 0--main :: IO ()-main = animate Nothing "Plane Wave" drawFun