Skip to content

Commit 93ca617

Browse files
Add documentation (#53)
1 parent 58cdfb0 commit 93ca617

File tree

17 files changed

+803
-5
lines changed

17 files changed

+803
-5
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Manifest.toml
88
*.xyz
99
*.out
1010
*.err
11-
*.pdf
1211
*.DS_Store
1312
*.gz
1413
*.cov
1514
log_output/
1615
log_error/
1716
data/*
1817
deps/build.log
18+
docs/build/*
1919

2020
!config_0.xyz

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h1 align="center">
2-
<img src="particlesmc_logo.png" width="500"/>
2+
<img src="https://raw.githubusercontent.com/TheDisorderedOrganization/ParticlesMC/main/logo.png" width="500"/>
33
</h1>
44

55
<div align="center">
@@ -16,7 +16,7 @@ ParticlesMC is a Julia package for performing atomic and molecular Monte Carlo s
1616
</p>
1717

1818
<p align="center">
19-
<img src="https://github.com/TheDisorderedOrganization/ParticlesMC/blob/main/examples/movie/movie.gif" alt="MC simulation of a 2D liquid" width="400">
19+
<img src="https://raw.githubusercontent.com/TheDisorderedOrganization/ParticlesMC/main/examples/movie/movie.gif" alt="MC simulation of a 2D liquid" width="400">
2020
</p>
2121

2222
<p align="center">

docs/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
ParticlesMC = "98828e2c-de49-11ef-324d-d77a22de11e4"
4+
5+
[compat]
6+
Documenter = "1.8"

docs/make.jl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Documenter
2+
using ParticlesMC
3+
4+
readme = read(joinpath(@__DIR__, "..", "README.md"), String)
5+
html_part = readme[1:findlast("</p>", readme)[end]]
6+
html_part = replace(html_part, r"<div align=\"center\">[\s\S]*?</div>" => "")
7+
md_part = readme[findlast("</p>", readme)[end]+1:end]
8+
readme = "```@raw html\n" * html_part * "\n```\n" * md_part
9+
write(joinpath(@__DIR__, "src", "index.md"), readme)
10+
11+
makedocs(
12+
sitename = "ParticlesMC",
13+
format = Documenter.HTML(;
14+
prettyurls = get(ENV, "CI", nothing) == "true",
15+
size_threshold_ignore = ["api.md"],
16+
sidebar_sitename = false
17+
),
18+
modules = [ParticlesMC],
19+
warnonly = [:missing_docs],
20+
pages = [
21+
"Home" => "index.md",
22+
"Manual" => Any[
23+
"man/particlesmc.md",
24+
"man/architecture.md",
25+
"man/simulations.md"
26+
],
27+
"API" => "api.md",
28+
]
29+
)
30+
31+
# Deploying to GitHub Pages
32+
deploydocs(;
33+
repo = "github.com/TheDisorderedOrganization/ParticlesMC.git",
34+
)

docs/src/api.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# API
2+
3+
This is the documentation of the ParticlesMC module's functions, types and structures.
4+
5+
# API Reference
6+
7+
```@meta
8+
CurrentModule = ParticlesMC
9+
```
10+
11+
## Index
12+
13+
```@index
14+
```
15+
16+
## Types and Functions
17+
18+
```@autodocs
19+
Modules = [ParticlesMC]
20+
```

docs/src/assets/goodpolicy.pdf

24 KB
Binary file not shown.

docs/src/assets/maniac.jpg

275 KB
Loading

docs/src/index.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
```@raw html
2+
<h1 align="center">
3+
<img src="https://raw.githubusercontent.com/TheDisorderedOrganization/ParticlesMC/main/logo.png" width="500"/>
4+
</h1>
5+
6+
7+
8+
<p align="center">
9+
ParticlesMC is a Julia package for performing atomic and molecular Monte Carlo simulations. It is designed to be efficient and user-friendly, making it suitable for both research and educational purposes. Built on top of the <a href="https://github.com/TheDisorderedOrganization/Arianna.jl"> Arianna </a> module, it leverages Arianna’s Monte Carlo framework.
10+
</p>
11+
12+
<p align="center">
13+
<img src="https://raw.githubusercontent.com/TheDisorderedOrganization/ParticlesMC/main/examples/movie/movie.gif" alt="MC simulation of a 2D liquid" width="400">
14+
</p>
15+
16+
<p align="center">
17+
MC simulation of a 2D liquid. This example can be reproduced by running <code>particlesmc params.toml</code> in the <code>examples/movie/</code> folder. Movie generated with <a href="https://www.ovito.org/"> ovito</a>.
18+
</p>
19+
```
20+
21+
22+
## Features
23+
24+
- **Flexible execution**: Simulations can be run from standalone scripts or through a command-line interface (CLI), enabling easy integration into workflows.
25+
- **Interaction potentials**: Supports a broad range of interatomic and intermolecular interaction potentials.
26+
- **Monte Carlo moves**: Implements state-of-the-art Monte Carlo moves for both atomic and molecular simulations.
27+
- **Computational efficiency**: Designed with performance in mind to enable fast simulations.
28+
- **Arianna framework integration**: Leverages the [Arianna](https://github.com/TheDisorderedOrganization/Arianna.jl) Monte Carlo framework, benefiting from advanced techniques such as Policy-Guided Monte Carlo (PGMC) and parallel tempering (soon).
29+
30+
31+
## Installation
32+
33+
### Requirements
34+
- Julia version 1.9 or higher
35+
36+
### Installing ParticlesMC
37+
You can install ParticlesMC using the Julia package manager in one of two ways:
38+
39+
1. Using the package mode (press `]` in the Julia REPL):
40+
```julia
41+
add https://github.com/TheDisorderedOrganization/ParticlesMC.git
42+
```
43+
44+
2. Using the Pkg API:
45+
```julia
46+
using Pkg
47+
Pkg.add(url="https://github.com/TheDisorderedOrganization/ParticlesMC.git")
48+
```
49+
50+
### Building ParticlesMC
51+
52+
The build should be automatic when installing `ParticlesMC`. If it hasn't, you can manually build the package, by entering the package mode (press `]` in the Julia REPL) and by typing:
53+
54+
```julia
55+
build
56+
```
57+
This will build the `particlesmc` executable at `~/.julia/bin` (please add this path to your PATH).
58+
59+
## Usage
60+
61+
### Running a Monte Carlo Simulation
62+
63+
To run a Monte Carlo simulation, you need an input atomic or molecular configuration file (typically with a `.xyz` extension) and a parameter file (in `TOML` format). The parameter file specifies both the system details (such as temperature, density, and interaction model) and the simulation details (such as simulation type, number of steps, Monte Carlo moves, and outputs). A minimal example is presented below. More detailed explanations can be found in the documentation.
64+
65+
**config.xyz**
66+
```
67+
3
68+
Lattice="1.7321 0.0 0.0 0.0 1.7321 0.0 0.0 0.0 0.0" Properties=type:I:1:pos:R:2
69+
1 0.1585 0.4965
70+
1 1.7215 0.7468
71+
1 0.7606 1.1439
72+
```
73+
74+
**params.toml**
75+
```toml
76+
[system]
77+
config = "config.xyz"
78+
temperature = 1.0
79+
density = 1.0
80+
list_type = "LinkedList"
81+
82+
[model]
83+
[model."1-1"]
84+
name = "LennardJones"
85+
epsilon = 1.0
86+
sigma = 1.0
87+
rcut = 2.5
88+
89+
[simulation]
90+
type = "Metropolis"
91+
steps = 500
92+
seed = 10
93+
parallel = false
94+
output_path = "./"
95+
96+
[[simulation.move]]
97+
action = "Displacement"
98+
probability = 1.0
99+
policy = "SimpleGaussian"
100+
parameters = {sigma = 0.05}
101+
102+
[[simulation.output]]
103+
algorithm = "StoreTrajectories"
104+
scheduler_params = {linear_interval = 50}
105+
fmt = "XYZ"
106+
```
107+
108+
**Explanation of the example:**
109+
110+
This example defines a minimal Monte Carlo simulation setup:
111+
112+
- The `[system]` section specifies the input configuration file (`config.xyz`), the simulation temperature and density, and the use of a linked list for neighbor searching.
113+
- The `[model]` section defines the interaction potential between particles. Here, a Lennard-Jones potential is used for species pair "1-1" with specified parameters (`epsilon`, `sigma`, and cutoff `rcut`).
114+
- The `[simulation]` section sets the simulation type to Metropolis, the number of Monte Carlo steps to 500, the random seed, whether to run in parallel, and the output path.
115+
- The `[[simulation.move]]` section describes the Monte Carlo move to use: a displacement move with probability 1.0, guided by a simple Gaussian policy with a standard deviation (`sigma`) of 0.05.
116+
- The `[[simulation.output]]` section configures the output: trajectories will be stored every 50 steps in the XYZ format.
117+
118+
By executing `particlesmc params.toml` you will run a basic Metropolis Monte Carlo simulation of particles interacting via the Lennard-Jones potential, using displacement moves, and periodically saving the system's trajectory.
119+
120+
## Contributing
121+
122+
We welcome contributions from the community. If you have a new system or feature to add, please fork the repository, make your changes, and submit a pull request.
123+
124+
## Citing
125+
126+
If you use Arianna in your research, please cite it! You can find the citation information in the [CITATION](https://github.com/TheDisorderedOrganization/ParticlesMC/blob/main/CITATION.bib) file or directly through GitHub's "Cite this repository" button.
127+
128+
## License
129+
130+
This project is licensed under the GNU General Public License v3.0. License. See the [LICENSE](https://github.com/TheDisorderedOrganization/ParticlesMC/blob/main/LICENSE) file for details.
131+
132+
## Contact
133+
134+
For any questions or issues, please open an issue on the GitHub repository or contact the maintainers.

docs/src/man/architecture.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
# Package Architecture
3+
4+
The package adopts a modular architecture, with each module responsible for a distinct component of the simulation workflow.
5+
6+
## Core systems
7+
8+
Two fundamental data structures represent physical systems: the **Atoms** struct for atomic systems and the **Molecules** struct for molecular systems.
9+
Both structures inherit from the abstract **Particles** type, which itself is a subtype of **AriannaSystem** (see *Arianna* [types](https://thedisorderedorganization.github.io/Arianna.jl/stable/man/system/)).
10+
This design allows the use of the [*Arianna.jl*](https://github.com/TheDisorderedOrganization/Arianna.jl) framework. The **Atoms** struct encapsulates properties such as particle positions,
11+
atom types, and interaction potentials. The **Molecules** struct extends the **Atoms** struct by including bond information (type and interaction potential).
12+
13+
Users can choose from a variety of potentials for calculating interactions between particles. The interactions depend solely on the type of the particles.
14+
For molecular systems, users choose potentials for both bonded particles and non-bonded particles. The interactions depend on the type of particles for
15+
non-bonded interactions and on the type of bond for bonded interactions.
16+
17+
In both cases, the target distribution is the Boltzmann distribution and thus,
18+
simulations are performed in the canonical ensemble (constant number of particles, volume, and temperature). An extension to perform
19+
simulations in the NPT ensemble (constant number of particles, pressure, and temperature) is in current development.
20+
21+
## Monte Carlo Moves
22+
23+
To use the [*Arianna.jl*](https://github.com/TheDisorderedOrganization/Arianna.jl) framework, the package implements moves defined through actions and policies, as described in the previous [section](https://thedisorderedorganization.github.io/ParticlesMC/stable/man/particlesmc).
24+
The package provides a collection of predefined actions and policies corresponding to standard and state-of-the-art Monte Carlo moves in atomic and molecular simulations:
25+
26+
- Standard displacement moves.
27+
- Swap moves for particle exchange in atomic systems.
28+
- Flip moves in molecular systems.
29+
- Intramolecular swap moves in polymeric systems.
30+
31+
Each action supports multiple policy implementations. For instance, displacement moves can employ either normal
32+
or uniform probability distributions for trial move generation.
33+
34+
All moves are designed to be compatible with both the Metropolis-Hastings algorithm and the Policy-Guided Monte Carlo (PGMC) method of Arianna.
35+
This means that all functions required by the *Arianna.jl* framework (see *Arianna* [moves](https://thedisorderedorganization.github.io/Arianna.jl/stable/man/system/)) are implemented for each action and policy.
36+
37+
## Neighbour Lists
38+
39+
The package incorporates efficient neighbor list algorithms[^1] to accelerate interaction computations between particles.
40+
Users can choose two neighbor list implementations, **LinkedList** and **EmptyList**. Both structs are subtypes of the
41+
**NeighbourList** type. The **EmptyList** is a dummy neighbour list that does not store any information, and thus
42+
the interaction between particles is computed by looping over all the particles. The **LinkedList** struct is
43+
a cell list implementation that divides the simulation box into cells of size larger that the maximul cutoff of the interaction
44+
potentials. This permits to calculate the potential energy of a particle by only calculating its interactions with particles
45+
inside the neighbouring cells. For large systems, using the **LinkedList** struct accelerates significantly simulations
46+
compared to using the **EmptyList** struct.
47+
48+
49+
## Input/Output
50+
51+
The package handle file operations, supporting configuration import from *.xyz*, *.exyz*, and *.lammps* formats.
52+
The package can also write the output trajectories in these same formats, providing users flexibility in choosing their preferred file format
53+
for data storage and analysis.
54+
55+
Additionally, the package provides callback functions for on-the-fly calculation of thermodynamic and structural properties during simulations,
56+
including energy and pressure for both atomic and molecular systems. These callbacks are stored in the output directory for post-processing.
57+
58+
[^1]: *Computer simulation of liquids*, Allen, Michael P and Tildesley, Dominic J, 2017

0 commit comments

Comments
 (0)