Created
June 28, 2013 14:17
-
-
Save akira093/5885002 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Graphics.Gnuplot.Simple | |
ts :: [Double] | |
ts = linearScale 100 (0, 1) | |
k :: Double | |
k = 1000.0 | |
m :: Double | |
m = 12 / 6.02e23 / 1000 | |
q1 t = (2.0 * pi / 3.0 * (1-t), 2.0 * pi / 3.0 * (1-t)) | |
q2 t = (0.0, pi * t) | |
q3 t = (2.0 / 3.0 * pi * t, (3-t)*pi / 3) | |
dot :: (Double, Double) -> (Double, Double) -> Double | |
dot x y = fst x * fst y + snd x * snd y | |
w q t = sqrt $ (4*k/m*) $ s q (1, 0) t + s q (0, 1) t + s q (1,1) t | |
s q a t = (**2) $ sin $ dot (q t) a / 2 | |
w1 = map (w q1) ts | |
w2 = map (w q2) ts | |
w3 = map (w q3) ts | |
ts1 = map (*2)ts | |
ts2 = map ((+2) . (* sqrt 3)) ts | |
ts3 = map (2 + sqrt 3 + ) ts | |
main = plotPaths [Title "二次元の格子振動", PNG "ahya.png"] $ [zip ts1 w1, zip ts2 w2, zip ts3 w3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment