Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README
Hard spheres model simulation, with output parsable by gnuplot.



== Install and compile

git checkout git://github.com/pisto/laurea.git
cd laurea/Release
make -j
cd ..


Optional compile flags can be specified with the usual CXXFLAGS and LDFLAGS. There are some program specific macros that can be overridden:

macro:		argument:	default:	description:
INTEGER_TYPE	type		int		Integer type (array indexes are always size_t)
REAL_TYPE	type		double		Type used for physic quantities
DIM		integer		2		Dimensions of the box
RADIUS		REAL_TYPE	0.5L		Radius of a sphere

Example:
make -j CXXFLAGS="-DREAL_TYPE=float -DDIM=3"

Default optimization flags are "-march=native -ffast-math -O3"
Run the ./fprofile-generate script (with normal arguments) to profile laurea.


== Structure

The program takes a textual (or raw, see option -rwi) input with box and balls specification, then runs a time-discretized simulation of their trajectories. It can output raw (-rwo) or textual informations.

Directory output: "-od folder"
	Print all balls information in folder/{frame}.balls and bins in folder/{frame}.bins

Template output: "-op inputtemplate outputfile"
	Takes inputtemplate, parses it and prints output to outputfile.

Template format
A tempalte file is a text file with a prologue section, which is output and evaluated before the simulation is run, a repeat section, which  is evaluated for each frame, and en epilogue section, which is evaluated after the time has run out or the user sent a SIGINT/SIGTERM.
Each section can contan simple strings, which are simply copied to the output, or commands, which begin with the character $.
You shall mark the beginning and the end of the repeat section with a single $ character, or the token $$.

This is the complete list of commands

COMMAND		ARGUMENTS	DESCRIPTION
cols		indexes		Columns: print the description of each ball. Column indexes are position first and velocity last, that is if compiled in 2D mode, index 0 and 1 are x and y position, 2 and 3 are x and y speed. If no index is given, prints everything.
f		-		Function: prints the expected thermalization velocity distribution function.
boltz		op binspec	Boltzmann: print Boltzmann related stuff for the given operation op. op values:
					bins: print bins
					calc: calc H value, store it in the H values history, output nothing
					current: as above, but print calculated value ("H=value")
					cumulative: as above but print full history of H values (list of "time Hvalue" tuples)
				binspec describes binwidth and number of bins. Can be "auto", or two parameters that tell the binned range and the number of bins within it.
mean		-		Mean: print the mean vectorial speed of the balls
setup		-		Setup: print some constants of the simulation
ct		-		Current time: print current time
mathematica	0|1		Mathematica output: 1 to turn on Mathematica friendly output (instead of Gnuplot's)
peeping		indexes		Peeping balls: print additional peeping balls. With periodic bounds, some balls can be close enough to a border, so that a part of them should be displayed at the other side. This commands calculates the shadow copies of these balls, and prints them with the same format as the command cols. The argument indexes is capped to the position columns.


== Usage

Invoke the program without arguments ('./Release/laurea') to print a brief help.

There are some scripts that automatize the creation of movies with gnuplot and ffmpeg.
movie_png.sh		Make video gnuplot png terminal. Extraordinarily slow (blame gnuplot), but supports antialiasing and so this script provides the best visual result. Gnuplot plotting is multithreaded automatically.
movie_gif.sh		much faster than png, no antialiasing.
revert.sh		Creates a fancy video like this http://www.youtube.com/watch?v=nu9g-kIqO-w&hd=1 , that is it starts from the initial distribution, simulates 30 seconds backward in time, and 20 forward, and then joins the two pieces. Can use both gif and png (switch by editing the two lines commented, comments start with #). Gnuplot multithreading fixed to 2 threads.

Initial distribution is a plain text file, which must contain in this order:
0|1				periodic boundaries flag
{dimensions}			dimensions of the box
{position} {velocity} ...	balls coordinates and speed

A Mathematica notebook (distribution.nb) is provided to generate the initial distribution. Evaluate the first cell, then you have the choice between the second cell which is a stub to generate randomish distribution, or the second which takes an image and ballifies it (the youtube link above exemplify it). 

Another notebook (results.nb) can be used to invoke laurea directly, and shows the bins and H(t) function.

laurea can be stopped gracefully at any time with SIGINT or SIGTERM, or queried about the completion percentage with SIGUSR1 ('killall -s 10 laurea').

Something went wrong with that request. Please try again.