From: Troels Emtekær Linnet (troels.linnet_at_bbz.uni-leipzig.de)
Date: Thu Mar 10 2011 - 15:06:17 CST

Hi.

I made a gnuplot file for step: 2-2 Maxwell
Makes things a little easier than excell

#########

reset
cd 'C:\NAMD27\Tutor\2-2-maxwell'
set term postscript eps enhanced color

set title "Maxwell-Boltzmann Energy Distribution"
set xlabel 'Energy (kcal/mol)'
set ylabel 'Relative Frequency' font 'Times-Roman,10'

## To get the sum for the columns in the data
## http://gnuplot-tricks.blogspot.com/2010_01_01_archive.html
### Prints to table, instead of graph. Gets number of datapoints.
set table 'inline.dat'
plot "energy.dat"
unset table
### Get the number N and sum of datapoints, by making summing function
N = 0
sum = 0.0
f(x) = (N = N+1, sum = sum+x, x)
### Run the sum function over the data.
plot "energy.dat" using (f($1))
### 'N' and 'sum'now available for normalization
print N, sum

## See histogram info
http://stackoverflow.com/questions/2471884/histogram-using-gnuplot
set xrange [0:70]
binwidth=0.1
bin(x,width)=floor(x/width)
set output "energy-NotNormalized.eps.eps"
plot "energy.dat" using (bin($1,binwidth)):(1.0) title 'Not normalized'
smooth freq with boxes
## Show in window, x11 for Linux
#set term x11
set term windows
replot
pause -1

## Now normalize
set term postscript eps enhanced color
set xrange [0:7]
binwidth=0.1
bin(x,width)=binwidth*floor(x/width)
set output "energy-Normalized.eps"
plot "energy.dat" using (bin($1,binwidth)):(1.0/(N*binwidth)) title
'Normalized' smooth freq with boxes
## Save the data in a table
set table 'energy-Normalized.dat'
plot "energy.dat" using (bin($1,binwidth)):(1.0/(N*binwidth)) title
'Normalized' smooth freq with boxes
unset table
## Show in window, x11 for Linux
#set term x11
set term windows
replot
pause -1

### Fitting Maxwell-Boltzmann distribution for kinetic energy
## kBT in units of kcal/mol
kBT = 0.5
h(x) = (2/sqrt(pi*kBT**3))*sqrt(x)*exp(-x/kBT)
fit h(x) "energy-Normalized.dat" using 1:2 via kBT
plot "energy-Normalized.dat" using 1:2 title 'Normalized' smooth freq with
boxes, h(x) title 'Fitted Maxwell-Boltzmann'
## Show in window, x11 for Linux
#set term x11
set term windows
replot
pause -1

## Value for kB
kB = 0.00198657
T = kBT/kB
print T

2011/1/7 Troels Emtekær Linnet <troels.linnet_at_bbz.uni-leipzig.de>

> Hi all.
>
> I am slowly going through the tutorial.
> I would like to use gnuplot instead of excel, but I have small problems to
> get histogram working in gnuplot.
>
> I was wondering if anybody else used gnuplot, and have some suggestions for
> a histogram function in gnuplot.
> Thanks!
>
> Troels Emtekær Linnet
>
>

**
** Visit http://www.greatcircle.com/majordomo/ for more info on majordomo
**