Last active
August 29, 2015 14:10
-
-
Save bsima/9bc1bd9cd8825640e3e4 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
;;; The Bolzmann formula for entropy as a measure of molecular disorder. | |
;;; | |
;;; Consider a container partitioned into two equal volumes. The number of ways, | |
;;; P, in which N molecules can be divided into two groups, N1 and N2, is given by | |
;;; the simple combinatorial formula | |
;;; | |
;;; P = N! / N1! N2! | |
;;; | |
;;; in which N! = N(N-1)(N-2)...3*2*1. The quantity P is called the "number of | |
;;; complections" (see Landau and Lifschitz, 1968) [p. 10] | |
;;; | |
;;; Here, the difference between N1 and N2 is described by the "ratio" parameter, | |
;;; which is expected to be a decimal. | |
(defun factorial (n &optional (acc 1)) | |
"Naive factorial implementation" | |
(if (<= n 1) | |
acc | |
(factorial (- n 1) (* acc n)))) | |
(defun boltzmann (n ratio) | |
"Prigogine 1980, p.10" | |
(/ (factorial n) | |
(* (factorial (* n ratio)) | |
(factorial (* n (- 1 ratio)))))) | |
(defun boltzmann-entropy (w) | |
"Derived version of Boltzmann's formula. k is Boltzmann's constant, or | |
1.38062*10^-23" | |
) | |
(defun random-walk-1 (m n) | |
"'An idealized but nevertheless successful model for Brownian motion.' | |
- Prigogine 1980, p.11" | |
(* .5 | |
(/ (factorial n) | |
(* (factorial (* .5 (+ n m))) | |
(factorial (* .5 (- n m))))))) | |
(defun random-walk-2 (m n) | |
"Shouldn't random-walk-1 and random-walk-2 be equal? Because they aren't... | |
I think I need to revist this." | |
(* (expt .5 (/ 2 (* pi n))) | |
(exp (* (/ (- 1 (expt m 2)) | |
2) | |
n)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment