Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Perform Monte Carlo simulation of scrambling and photodissociation reactions on PAHs

tim-degroot/PAHMC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

96 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PAH-MC

Perform Monte Carlo simulation of scrambling and photodissociation reactions on PAHs.

Associated research:

  1. Carels, E. J. Isotopic Effects Revealed Upon Photolysis of PAHs. (Universiteit van Amsterdam, 2023).
  2. de Groot, T. Modelling the Photochemistry of Polycyclic Aromatic Hydrocarbons. (Universiteit van Amsterdam, 2025).

Installation

Clone the repository.

Install the prerequisites using Mamba or another environment manager:

mamba create -n PAHMC numpy, matplotlib, pyyaml

If installing on a computer cluster you can skip the environment and instead load the modules using SLURM or a similar workload manager (see Running the program).

Usage

Preparing the .yaml input file

The input file uses YAML. While the documentation explains the file structure in a certain order this order is not necessary for the program to work.

We will prepare a simulation of Anthracene in this example to explain the input file structure.

Provide a name for the simulation (optional, currently not used for anything):

Name: Anthracene

The edge consists of groups of substituents that are linked by links. The edge loops around to itself.

Define the initial edge substituents (0 for none, H, D, HH or HD). Only one aliphatic site (HD/HH) supported. Label them according to nomeclature using edge numbers.

Initial edge: (H,H,H,H) (HD) (H,H,H,H) (H)
Initial edge numbers: (5,6,7,8) (9) (1,2,3,4) (10)

Define the initial tertiary links (0 for None). The links are added inbetween the edge groups starting after the first edge. Starting with aliphatic tertiary is currently not supported. Label them according to nomenclature using link numbers.

Initial links: (0) (0) (0) (0)
Initial link numbers: (8a) (9a) (4a) (10a)

Define any cross-links (optional). Cross-links can be any reaction that is not between neighbours on the edge structure. These are defined in pairs.

Initial cross-links: (8a,10a) (9a,4a)

Define the simulation energy in eV:

Energy: 4.66

Define the number of iterations:

Iterations: 2000

Define the maximum simulation time (s):

Maximum time: 0.02

Define error handling (w for warming, q for quit).

Error handling: w

Define the rates by pointing to the path where the RRKM rate files (prepared with rrkm.py) are stored and matching all reactions (HAtoB and DAtoB for every neighbour and cross-link pair). Symmetrical reactions can point to the same rate file.

Rates path: /RRKM/
Rates:
  H9to9a,H9to8a,H10to4a,H10to10a: H9to9a.txt
  D9to9a,D9to8a,D10to4a,D10to10a: D9to9a.txt
  H9ato9,H8ato9,H4ato10,H10ato10: H9ato9.txt
  D9ato9,D8ato9,D4ato10,D10ato10: D9ato9.txt
  ...
  H9diss,H10diss: diss_rate_H9.txt
  D9diss,D10diss: diss_rate_D9.txt
  ...

Running the program

usage: PAHMC [-h] [-c CORES] [-o OUTPUT] [-l LOG] [-d] inputfile

Perform Monte Carlo simulation of scrambling and photodissociation reactions on PAHs.

positional arguments:
  inputfile            Input YAML file

options:
  -h, --help           show this help message and exit
  -c, --cores CORES    Number of parallel processes to run
  -o, --output OUTPUT  Output file
  -l, --log LOG        Log file
  -d, --debug          Enable debugging

If no Output or Log files are specified the program uses the name of inputfile with different extensions (see Understanding the output).

If you are going to run this program on a supercomputer/computer cluster that uses SLURM for the job management create a script and run it:

#!/bin/bash
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task 128
#SBATCH --partition=rome

module load 2024
module load Python/3.12.3-GCCcore-13.3.0
module load Anaconda3/2024.06-1

python ../PAHMC/src/main.py $1
sbatch mc_slurm.sh <inputfile> 

This script has been successfully used on the Snellius computer cluster by Surf using the above configuration..

Understanding the output

The filename of the output is taken from the yaml (ABC.yaml gives filename = ABC) or can be set manually using the --OUTPUT parameter (see Running the program).

The program generates several files. They will be discussed in alphabetical order (the same way your system usually sorts them).

{filename}_data.csv contains the following:

MC#       ,Diss atom ,Diss pos  ,Diss time ,# hops    ,# D hops  ,# cross hops,HH time   ,HD time   ,DD time   
MC0       ,None      ,None      ,2.0061e-06,5248      ,353       ,18          ,1.6279e-06,3.782e-07 ,0         

Where MC# is the iteration number; Diss atom is the type of atom that dissociated, either H(ydrogen) or D(euterium); Diss pos is the edge number where the dissociation occured; Diss time is the time the simulation ran before dissociation occured, if no dissociation happened but the simulation was ended because of the Maximum time this value is the time at that point; # hops is the total number of hops that happened in the simulation; # D hops is the number of hops of a deuterium atom; # cross hops is the number of hops across a cross-link; HH/HD/DD time is the time spent with a HH/HD/DD aliphatic site respectively.

{filename}_key_hops.csv contains the following:

MC#    ,D1to2  ,D1to9a ,D2to1  ,D2to3  ,D9ato1 ,D9ato4a,D9ato9 ,D9to9a ,H1to2  ,H1to9a ,H2to1  ,H2to3  ,H9ato1 ,H9ato4a,H9ato9 ,H9to9a 
MC0    ,89     ,2      ,88     ,4      ,3      ,2      ,20     ,21     ,1650   ,33     ,1651   ,131    ,32     ,19     ,217    ,217    

Where the amount of occurences of every unique hop is stored. Symmetrical ones are summed under the label of the first in the list.

{filename}_diss_time.png shows a histogram of the dissociation times per iteration.

{filename}_hops.png shows a histogram of the number of hops per iteration.

{filename}.log contains the programs logger.

{filename}.out contains the main output. This includes the numbers of dissociation per atom (H(ydrogen), D(euterium) or None) and the numbers of dissociation per position of your molecule (numbered according to edge numbers).

If --debug is enabled {filename}_{iteration}_mol_structures.log contains the complete structure history of the molecular structure of the first iteration (iteration 0) is stored.

How it works

Code2flow diagram

Credits and acknowledgements

This program was created by Emma Carels for a master project. It was updated and is currently maintained by Tim de Groot for a subsequent bachelor project.

Supervision for both projects was done by dr. Alessandra Candian and dr. ir. Annemieke Petrignani

All research was performed at the Anton Pannekoek Institute for Astronomy & Van 't Hoff Institute for Molecular Sciences at the University of Amsterdam.

About

Perform Monte Carlo simulation of scrambling and photodissociation reactions on PAHs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages