Skip to content

Commit

Permalink
Merge pull request #10 from espottesmith/main
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
espottesmith authored Aug 23, 2024
2 parents 4554d8f + 13b4043 commit 8b07dc4
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 195 deletions.
192 changes: 11 additions & 181 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,189 +1,19 @@
<img src="./logo.png">

Reaction Network Monte Carlo (RNMC) is a collection of programs for Monte Carlo simulation of statistical mechanical systems heavily inspired by [SPPARKS](https://spparks.sandia.gov/). RNMC is designed to run large numbers of simulations of a fixed system in parallel. The project currently consists of three parts:
- `core` : Core code shared by all simulators, for example IO, threading logic and model independent simulation logic.
Reaction Network Monte Carlo (`RNMC`) is a collection of programs for Monte Carlo simulation of statistical mechanical systems heavily inspired by [SPPARKS](https://spparks.sandia.gov/). `RNMC` is designed to run large numbers of simulations of a fixed system in parallel. The project currently consists of four parts:
- `core` : Core code shared by all simulators, for example IO, threading logic, and model independent simulation logic.
- `GMC` : Implementation of Gillespie's next reaction simulator. GMC is able to run simulations of reaction networks with hundreds of millions of reactions, even when the number of species is small.
- `NPMC` : A 3D statistical field theory simulator which supports one and two site interactions. Useful for simulating nano particles.
- `LGMC` : A simulator that can include a static or dynamic lattice region and a homogeneous region and allows electrochemical as well as chemical reactions. Suitable for multi-phase simulations (e.g., heterogeneous catalysis, electrochemical plating or stripping).

See [this](https://doi.org/10.26434/chemrxiv-2021-c2gp3) paper for an example of the kind of work being done with RNMC.
Examples of research projects using `RNMC`:
- Spotte-Smith, Kam, et al., *ACS Energy Lett.* **7**(4), 1446–1453 (2022). [DOI: 10.1021/acsenergylett.2c00517](https://doi.org/10.1021/acsenergylett.2c00517)
- Barter, Spotte-Smith, et al., *Dig. Disc.* **2**, 123-137 (2023). [DOI: 10.1039/D2DD00117A](https://doi.org/10.1039/D2DD00117A)
- Spotte-Smith et al., *J. Am. Chem. Soc.* **145**(2), 12181–12192 (2023). [DOI: 10.1021/jacs.3c02222](https://doi.org/10.1021/jacs.3c02222)
- Xia et al., *Nano Lett.* **23**(23), 11129–11136 (2023). [DOI: 10.1021/acs.nanolett.3c03568](https://doi.org/10.1021/acs.nanolett.3c03568)

### Dependencies

RNMC depends on [GSL](https://www.gnu.org/software/gsl/) for pseudo random number generation and [sqlite](https://www.sqlite.org/index.html) for the database interfaces.

### Building

On a machine with system versions of GSL and sqlite, the executables can be built like this:
```
./build.sh
```
The executables are put in the `build` directory. Note that the build script uses the `gsl-config` utility to find headers and libraries for GSL. If you are on a cluster and sqlite is not present, it can be built as follows:

```
cd $HOME
wget https://www.sqlite.org/2021/sqlite-amalgamation-3360000.zip
unzip sqlite-amalgamation-3360000.zip
cd sqlite-amalgamation-3360000
gcc -o libsqlite3.so -shared -fPIC sqlite3.c -lpthread -ldl
```

in which case, the simulators can be built like this:

```
export CPATH=$HOME/sqlite-amalgamation-3360000:$CPATH
export LIBRARY_PATH=$HOME/sqlite-amalgamation-3360000:$LIBRARY_PATH
./build.sh
```

### Testing

Run the tests using `test.sh` from the root directory of the repository.

## Running GMC

GMC is run as follows:

```
GMC --reaction_database=rn.sqlite --initial_state_database=initial_state.sqlite --number_of_simulations=1000 --base_seed=1000 --thread_count=8 --step_cutoff=200
```

- `reaction_database`: a sqlite database containing the reaction network and metadata.
- `initial_state_database` : a sqlite database containing initial state. The simulation trajectories are also written into the database
- `number_of_simulation`: an integer specifying how many simulations to run
- `base_seed`: seeds used are `base_seed, base_seed+1, ..., base_seed+number_of_simulations-1`
- `thread_count`: is how many threads to use.
- `step_cutoff`: how many steps in each simulation

### The Reaction Network Database

There are 2 tables in the reaction network database:
```
CREATE TABLE metadata (
number_of_species INTEGER NOT NULL,
number_of_reactions INTEGER NOT NULL
);
```

```
CREATE TABLE reactions (
reaction_id INTEGER NOT NULL PRIMARY KEY,
number_of_reactants INTEGER NOT NULL,
number_of_products INTEGER NOT NULL,
reactant_1 INTEGER NOT NULL,
reactant_2 INTEGER NOT NULL,
product_1 INTEGER NOT NULL,
product_2 INTEGER NOT NULL,
rate REAL NOT NULL
);
Complete documentation, including a guide to installing `RNMC` can be found [here](https://blaugroup.github.io/RNMC/).

```
There are 3 tables in the initial state database. The factors can be used to modify rates of reactions which have zero or two reactants, or have duplicate reactants.
```
CREATE TABLE trajectories (
seed INTEGER NOT NULL,
step INTEGER NOT NULL,
reaction_id INTEGER NOT NULL,
time REAL NOT NULL
);
```

```
CREATE TABLE factors (
factor_zero REAL NOT NULL,
factor_two REAL NOT NULL,
factor_duplicate REAL NOT NULL)
```

```
CREATE TABLE initial_state (
species_id INTEGER NOT NULL PRIMARY KEY,
count INTEGER NOT NULL
);
```

## Running NPMC
NPMC is run as follows:

```
NPMC --nano_particle_database=np.sqlite --initial_state_database=initial_state.sqlite --number_of_simulations=1000 --base_seed=1000 --thread_count=8 --step_cutoff=200 --dependency_threshold=1
```

- `nano_particle_database`: a sqlite database containing the nano particle data and metadata.
- `initial_state_database` : a sqlite database containing initial state. The simulation trajectories are also written into the database
- `number_of_simulation`: an integer specifying how many simulations to run
- `base_seed`: seeds used are `base_seed, base_seed+1, ..., base_seed+number_of_simulations-1`
- `thread_count`: is how many threads to use.
- `step_cutoff`: how many steps in each simulation

### The Nano particle Database
There are 4 tables in the nano particle database:
```
CREATE TABLE species (
species_id INTEGER NOT NULL PRIMARY KEY,
degrees_of_freedom INTEGER NOT NULL
);
```

```
CREATE TABLE sites (
site_id INTEGER NOT NULL PRIMARY KEY,
x REAL NOT NULL,
y REAL NOT NULL,
z REAL NOT NULL,
species_id INTEGER NOT NULL
);
```

```
CREATE TABLE interactions (
interaction_id INTEGER NOT NULL PRIMARY KEY,
number_of_sites INTEGER NOT NULL,
species_id_1 INTEGER NOT NULL,
species_id_2 INTEGER NOT NULL,
left_state_1 INTEGER NOT NULL,
left_state_2 INTEGER NOT NULL,
right_state_1 INTEGER NOT NULL,
right_state_2 INTEGER NOT NULL,
rate REAL NOT NULL
);
```

```
CREATE TABLE metadata (
number_of_species INTEGER NOT NULL,
number_of_sites INTEGER NOT NULL,
number_of_interactions INTEGER NOT NULL
);
```

there are 3 tables in the initial state database:
```
CREATE TABLE initial_state (
site_id INTEGER NOT NULL PRIMARY KEY,
degree_of_freedom INTEGER NOT NULL
);
```

```
CREATE TABLE trajectories (
seed INTEGER NOT NULL,
step INTEGER NOT NULL,
time REAL NOT NULL,
site_id_1 INTEGER NOT NULL,
site_id_2 INTEGER NOT NULL,
interaction_id INTEGER NOT NULL
);
```


```
CREATE TABLE factors (
one_site_interaction_factor REAL NOT NULL,
two_site_interaction_factor REAL NOT NULL,
interaction_radius_bound REAL NOT NULL,
distance_factor_type TEXT NOT NULL
);
```
### Dependencies

`distance_factor_type` specifies how to compute interaction propensities for two site interactions as a function of distance. Currently the accepted values are `linear` and `inverse_cubic`.
Note that `RNMC` depends on [GSL](https://www.gnu.org/software/gsl/) for pseudo random number generation and [sqlite](https://www.sqlite.org/index.html) for the database interfaces.
53 changes: 44 additions & 9 deletions paper.bib
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,48 @@ @article{spotte2023chemical
publisher={ACS Publications}
}

@article{Gnach_2012,
title={Lanthanide-doped up-converting nanoparticles: Merits and challenges},
author={Gnach, Anna and Bednarkiewicz, Artur},
journal={Nano Today},
volume={7},
@article{xia2023accelerating,
title={Accelerating the Design of Multishell Upconverting Nanoparticles through Bayesian Optimization},
author={Xia, Xiaojing and Sivonxay, Eric and Helms, Brett A and Blau, Samuel M and Chan, Emory M},
journal={Nano Letters},
volume={23},
number={23},
pages={11129--11136},
year={2023},
publisher={ACS Publications}
}

@article{chan2015combinatorial,
title={Combinatorial approaches for developing upconverting nanomaterials: high-throughput screening, modeling, and applications},
author={Chan, Emory M},
journal={Chemical Society Reviews},
volume={44},
number={6},
pages={532--563},
year={2012},
publisher={Elsevier}
}
pages={1653--1679},
year={2015},
publisher={Royal Society of Chemistry}
}

@article{skripka2023NL,
author = {Skripka, Artiom and Lee, Minji and Qi, Xiao and Pan, Jia-Ahn and Yang, Haoran and Lee, Changhwan and Schuck, P. James and Cohen, Bruce E. and Jaque, Daniel and Chan, Emory M.},
title = {A Generalized Approach to Photon Avalanche Upconversion in Luminescent Nanocrystals},
journal = {Nano Letters},
volume = {23},
number = {15},
pages = {7100-7106},
year = {2023},
doi = {10.1021/acs.nanolett.3c01955},
URL = {https://doi.org/10.1021/acs.nanolett.3c01955},
eprint = {https://doi.org/10.1021/acs.nanolett.3c01955},
}

@article{teitelboim2019energy,
title={Energy transfer networks within upconverting nanoparticles are complex systems with collective, robust, and history-dependent dynamics},
author={Teitelboim, Ayelet and Tian, Bining and Garfield, David J and Fernandez-Bravo, Angel and Gotlin, Adam C and Schuck, P James and Cohen, Bruce E and Chan, Emory M},
journal={The Journal of Physical Chemistry C},
volume={123},
number={4},
pages={2678--2689},
year={2019},
publisher={ACS Publications}
}
15 changes: 10 additions & 5 deletions paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ authors:
- name: Rohith Srinivaas Mohanakrishnan
corresponding: false
affiliation: "1, 4"
- name: Emory M. Chan
corresponding: false
affiliation: 5
- name: Kristin Aslaug Persson
corresponding: true
affiliation: "4, 5"
Expand All @@ -45,7 +48,7 @@ affiliations:
index: 4
- name: Molecular Foundry, Lawrence Berkeley National Laboratory, Berkeley, CA, USA 94720
index: 5
date: 2024-07-22
date: 2024-08-14
bibliography: paper.bib
---

Expand All @@ -69,23 +72,25 @@ We have designed `RNMC` to be easily extensible, enabling users to add additiona

Three are many existing kMC implementations, including several open source examples (e.g. the Stochastic Parallel PARticle Kinetic Simulator or `SPPARKS`[@garcia2009crossing] and `kmos`).[@hoffmann2014kmos]
`RNMC` began as a fork of SPPARKS but differs in several important ways.
First, because `RNMC` uses the widely supported SQLite database engine for simulation inputs and outputs, it is facile to automate simulations using `RNMC`.
First, because `RNMC` uses the widely supported SQLite database engine for simulation inputs and outputs, it facilitates the automation of simulations.
Second, `RNMC` has a focus on modularity; it is designed such that users can quickly develop new types of kMC simulations using a common core library.

The simulation modules already implemented in `RNMC` provide unique capabilities that are not widely available in other open source codes.
`NPMC` is specially designed for 3D simulations of interactions in nanocrystals.
For instance, it can be used to simulate the upconversion of infrared to ultraviolet light *via* interactions between spatially distributed dopants in nanoparticles.[@Gnach_2012]
`NPMC` is specifically designed for 3D simulations of the complex photophysical interaction networks in nanocrystals,[@teitelboim2019energy] particularly multi-domain heterostructures whose optical properties cannot be calculated deterministically.[@skripka2023NL]
`NPMC` can be used to simulate energy transfer interactions between dopants in nanoparticles, their radiative transitions, and nonlinear processes such as upconversion [@chan2015combinatorial] and photon avalanching.[@skripka2023NL]
`LGMC` is also somewhat unique in that it can simulate multi-phase systems and electrochemical processes.
Simulations using `LGMC` can include a lattice region and a homogeneous solution region which can interact *via* interfacial reactions.
Electrochemcial reactions can be treated using Marcus theory[@marcus1965theory] or Butler-Volmer kinetics.[@newman2021electrochemical]
Because it allows for a dynamic lattice region, `LGMC` is also appropriate for simulations of nucleation and growth, dissolution, precipitation, and related phenomena.

We have already used the `GMC` module in a number of prior works in applications related to Li-ion and Mg-ion batteries.[@spotte2022toward; @barter2023predictive; @spotte2023chemical] We note that these simulations included tens of millions of reactions, demonstrating that `RNMC` is able to scale to large and complex reaction networks.
We have already used the `GMC` module in a number of prior works in applications related to Li-ion and Mg-ion batteries.[@spotte2022toward; @barter2023predictive; @spotte2023chemical] We note that these simulations included tens of millions of reactions, demonstrating that `RNMC` is able to scale to large and complex reaction networks. In addition, we have used `NPMC` to perform Bayesian optimization of upconverting nanoparticles.[@xia2023accelerating]

# Acknowledgements

This project was intellectually led by the Laboratory Directed Research and Development Program of Lawrence Berkeley National Laboratory under U.S. Department of Energy Contract No. DE-AC02-05CH11231.
L.Z. was supported in part by the U.S. Department of Energy, Office of Science, Office of Workforce Development for Teachers and Scientists (WDTS) under the Science Undergraduate Laboratory Internships Program (SULI).
E.W.C.S.-S. was supported by the Kavli Energy NanoScience Institute Philomathia Graduate Student Fellowship.
Work at the Molecular Foundry (E.M.C., K.A.P) was supported by the Office of Science, Office of Basic Energy Sciences, of the U.S. Department of Energy under Contract No. DE-AC02-05CH11231.
Additional support came from the Joint Center for Energy Storage Research (JCESR), an Energy Innovation Hub funded by the U.S. Department of Energy, Office of Science, Basic Energy Sciences.
This code was developed and tested using computational resources provided by the National Energy Research Scientific Computing Center (NERSC), a U.S. Department of Energy Office of Science User Facility under Contract No. DE-AC02-05CH11231, the Eagle and Swift HPC systems at the National Renewable Energy Laboratory (NREL), and the Lawrencium HPC cluster at Lawrence Berkeley National Laboratory.

Expand Down
Binary file modified paper.pdf
Binary file not shown.

0 comments on commit 8b07dc4

Please sign in to comment.