---
# System prepended metadata

title: Polygons Randy
tags: [PhD projects]

---

# Polygons Randy
###### tags: `PhD projects`
## Goal
We want to calculate the diffusion (MSD) and mean square rotation (MSR) $\langle\Delta\theta^2(t)\rangle$ for a system of polygogons. Note that for this last quantity we want the total angle change and not the absolute angle change (i.e. $8\pi\neq 0$).
## Franks code
**Important variables**
* *nverts*: Number of vertices of the polygon.
* *numbatches*: the number of batches at which a logmarithmic series of snapshots is made. The time distance between snapshots is equal.
* *numsnapshots*: every batch has a least this amount of snapshots printed at logmarithmic time intervals (can also be more for earlier snapshots).

### Checks:
**Rotation angle**
We checked that the angle parameter $\alpha$ of the particle is equal to the theta parameter, except for a factor of $2\pi$, where $\theta = \text{mod}(\alpha, 2\pi)$. 

**Equation of state**
*Found on ODIN /home/users/5670772/Polygons/code_EDMD_polygon/CHECKS/check_EOS_triangles/*
We check the equation of state for squares with the the one from a paper of Daan Frenkel(https://lib.psnc.pl/Content/575/10.12921_cmst.2004.10.02.235-255_Wojciechowska.pdf}).

![](https://i.imgur.com/7Id7jbn.png)
In this figure the red points are our pressure, while the blue points are the points from the paper. Note that here $\rho\sigma^2 = \text{number density} \times \text{volume one particle}$. Since our particles have a volume of 2 whereas the particles in the paper have a volume of 1, we have an extra factor 2 in the analysis (see mathematica notebook). This factor is not there in $\beta P/\rho$ because here we only consider number density.   

## Statepoints

To investigate the statepoints we consider the following paper

*Anderson, Joshua A., et al. "Shape and symmetry determine two-dimensional melting transitions of hard regular polygons." Physical Review X 7.2 (2017): 021001.*

Here the show a one of the figures that contains the transition form fluid to solid for pentagons. 

![](https://i.imgur.com/Jv7CB09.png)

As we can see around $\phi=0.676$ the entire system is fluid, while aroung $\phi=0.696$ almost the entire system is solid. 


## Simulations
:::warning
It turned out that there was a small bug in Franks EDMD code, which made the polygons sometimes overlap, see below:

*It occurs in all simulations, although it also seems to fix itself at some point (i.e. after some period of time the overlap disappears again).*
|  ![](https://i.imgur.com/INphyOr.png) |![](https://i.imgur.com/KZWr9Ht.png)|
| -------- | -------- | 
Frank fixed the bug, but the old code can still be found in *qstat*
:::
We simulate a system of $2000$ 2D polygons at various densities. Note that all densities are chosen based on the paper discussed above. We include densities up to the fluid-crystal transition and slightly above.


| Sides            | 3    | 4    | 5    | 6    |
| ---------------- | ---- | --- | --- | ---- |
| Packing fraction |  $\eta = [0.50,0.80]$      |  $\eta = [0.50,0.80]$     | $\eta = [0.50,0.80]$    |  $\eta = [0.50,0.80]$      |

We let the system equilibrate for $5\cdot t/\tau= 10^4$ and then measure for the same amount of time. For each particle we then logmarithmically (and in 20 various batches of each 50 snapshots) write out 
* x, y
* $\alpha$, which is the absolute angle.

With this we can measure, both MSD and MSR
### Results
*Data and codes can be found on ODIN /home/users/5670772/Polygons/. The data in the folder 'data_polygons' and the notebooks in the folder 'analysis'.*

Below we show the mean square rotation/displacement and the corresponding slopes in the diffusive regime.

#### Triangles
|  | Mean square rotation/displacement|Diffusion constants |
| -------- | -------- | -------- |
|Displacement|![](https://hackmd.io/_uploads/Hy56lKNwn.png)|![](https://hackmd.io/_uploads/SJ7vltEPn.png)|
|Rotation |![](https://hackmd.io/_uploads/rkqpxY4v2.png)|![](https://hackmd.io/_uploads/BJXvxt4Pn.png)|


#### Squares
|  | Mean square rotation/displacement|Diffusion constants |
| -------- | -------- | -------- |
|Displacement|![](https://hackmd.io/_uploads/SkK40NPDn.png)|![](https://hackmd.io/_uploads/BkFN0Ewvh.png)|
|Rotation |![](https://hackmd.io/_uploads/r1YEC4wDn.png)|![](https://hackmd.io/_uploads/rkUoREww2.png)| 

#### Pentagons

|  | Mean square rotation/displacement|Diffusion constants |
| -------- | -------- | -------- |
|Displacement| ![](https://hackmd.io/_uploads/B1W4bKVP2.png)|![](https://hackmd.io/_uploads/rkx4WF4Ph.png)|
|Rotation |![](https://hackmd.io/_uploads/r1bEWt4Ph.png)| ![](https://hackmd.io/_uploads/SJxVZY4Dn.png)|


#### Hexagons

|  | Mean square rotation/displacement|Diffusion constants |
| -------- | -------- | -------- |
|Displacement| ![](https://hackmd.io/_uploads/r1XaZFVD3.png)|![](https://hackmd.io/_uploads/H1f6ZKVw3.png)|
|Rotation |![](https://hackmd.io/_uploads/HJQTbt4w3.png)|![](https://hackmd.io/_uploads/SyM6WtEw2.png)|






#### Comparison

|![](https://hackmd.io/_uploads/Hk7DgYED2.png)Triangles   |![](https://hackmd.io/_uploads/SkUiRNDwn.png)Squares|
| --- | ------------------------------------ |
|![](https://hackmd.io/_uploads/H1vKZY4vn.png)**Pentagons**|![](https://hackmd.io/_uploads/Sy4kfFVv2.png)**Hexagons** |

:::info
Note that I accidently started some of the lower packing fraction simulations again. The associated logsnapshots are still correct, however the pressure files are overwritten. Since we however do no use the pressure for anything, I did not run them again. 
:::
## Pentagons France
file:///home/rinske/Downloads/pentagons_d%C3%BCrer.pdf
### MC code square box 
*On ODIN /home/users/5670772/Polygons/code_MC_polygons/ an MC code for hard polygons can be found*
#### CHECKS
We checked the MC code and especially the implemented seperating axis therom by measuring the equation of state for hard cubes (see left picture below), using the same benchmark paper as for the check above. On the right we show a snapshot for pentagons. 

| Equation of state cubes|Snapshot Pentagons| 
| -------- | -------- | 
| ![](https://hackmd.io/_uploads/SkLf8zDd3.png)|![](https://hackmd.io/_uploads/SJLMUMDO2.png)  | 


### MC code floppy box
We then changed the code such that the box no longer has to be regtengular, using the floppy box algorithm. In order to make sure that the box never becomes to skewed, we implemented a check that forbids box shapes where the number of cells to check is higher than the actual number of cells.

The simulation is such that one can choose whether you want NVT/NPT/floppy box and whether it wants to start in a hexoganal crystal (in a skewed box), in a cubic crystal (in a cubic box) or in a fluid (in a square box). 

#### CHECKS
*Found on ODIN /home/users/5670772/Polygons/code_MC_polygons/MC_floppybox/CHECKS/*
##### Results cubic system
As a reference check we consider two different system sizes of cubic particles in an NPT system (where we start the system both in a fluid as well as in a cubic system). Below we show the results.
![](https://hackmd.io/_uploads/SkrGHuJh2.png)



##### Results hexagonal system
Furthermore we also consider a system of hexagons. To check the code we use the EOS for hexagons found in the SI (https://journals.aps.org/prx/supplemental/10.1103/PhysRevX.7.021001/Supplementary_Information.pdf) of the paper "Shape and Symmetry Determine Two-Dimensional Melting Transitions of
Hard Regular Polygons".

Below we show the results, where we run the simulation for a system of 2000 particles at different pressures and different initial conditions (i.e. starting in a fluid or hexagonal crystal and whether or not the box is floppy).
![](https://hackmd.io/_uploads/rk6DEdyn3.png)

As we can see the floppy box converges both with the fluid at lower densitoes as well as the NPT constant box crystal at higher densities. We see that our values reasonably overlap with literature (also keeping in mind that literature uses a system of 4096 particles). As we can see the NPT hex crystal with the constant box ratio deviates quite a bit for lower pressure, however this can be explained by the fact that this system turned out to be not well equilibrated (see figures below where we plot the volume as a function of the MC steps).

 | Volume as function MC cycle                   | Angle box                                     | Size ratio box                                |
 | --------------------------------------------- | --------------------------------------------- | --------------------------------------------- |
 |![](https://hackmd.io/_uploads/HkHGWdJ3n.png)**Hex 0 FB 0** |                                               |                                               
  | ![](https://hackmd.io/_uploads/BJ6Db_1hn.png)**Hex 1 FB 0** |                                               |                                               |
| ![](https://hackmd.io/_uploads/HJvqZ_1nh.png)**Hex 1 FB 1** | ![](https://hackmd.io/_uploads/r1hJSdk22.png)| ![](https://hackmd.io/_uploads/r1O3W_kn2.png) |

Finally we also consider the box angle and the size ratio for the FB simulation as a function of pressure. As we can see the angle lies around 60 (which is the angle at which we initialize the box) and the size ratio lies around 1 (where we indeed initialize it at 1).
::: warning
With Laura and Frank check initial settings for MC and check how volume is updated.
:::
### Square shoulder
Finally we implement a square shoulder potential, given by 
$$
U = 
\begin{cases}
\infty &\text{ if }r \leq \sigma \\
\epsilon&\text{ if }\sigma < r \leq \lambda\\
0&\text{ if }\lambda < r
\end{cases}
$$
where we set $\sigma$ equal to the inscribed circle of the polygon and $\lambda <$ outscribed circle. That way there is an effective attraction between particle faces.

#### Checks
*Found on ODIN /home/rinskealkemade/Documents/MobaXterm_download/Polygons_France/CHECKS/MC_pol_FB_0_NVT_NPT_1_inithex_0_initcub_1_SH_0_N3_0_N4_625_N5_0_N6_0
/home/rinskealkemade/Documents/MobaXterm_download/Polygons_France/CHECKS/CHECK_POL_SH.nb*
We compute the energy in two ways: once every *n* steps we compute the total energy of the system by looping over all particle pairs and we compute the energy by updating it every MC step. We then check that the energy computed with the total energy function is be equal to the energy that is updated every step.

![](https://hackmd.io/_uploads/HyLf_EM2h.png) 
Moreover, for this system of 225 particles that starts in a dense hexagonal crystall ($pf = 0.9$) with $\epsilon = -1$, the maximum energy (when all particles have 6 neighbour bonds) should be equal to $-225\cdot 6/2 = -675$, which is indeed what we see. 

Furthermore if we start with $\epsilon = -1000$ and $\lambda = -1.80$ in a low density fluid, but with high pressure, we get a gellike structure



|Snapshot $t=0$ | Snapshot later in time |
| -------- | -------- |
|![](https://hackmd.io/_uploads/BkTaiVMhn.png)| ![](https://hackmd.io/_uploads/r1QA5NGnh.png)|


## Explore phases
The phases we expect to see (https://equipes2.lps.u-psud.fr/matrix/bidimensional-crystals-of-pentagons/)
![](https://hackmd.io/_uploads/SkTapOb-T.png)

Algorithm: 
1. Quench cycle start fluid at low density and $\beta P = 2.0$ every 100.000 cycles raise  $\beta P $ by 0.1
2. Do 500.000 init cyles at desired pressure
3. Measure for 1.000.000 cycles

### $\lambda = 1.65$
*See ODIN /home/users/5670772/Polygons/analysis/analysis_data_polygons_dif_statepoints.nb, data can be found in /home/users/5670772/Polygons/data_pentagons_MC/*
|     |Packing fraction                                                                                    | Energy| Packing fraction vs volme |
| --- | ------------------------------------------------------------------------------------------ | -------- | -------- |
|  ![](https://hackmd.io/_uploads/ryXl-uWZp.png)|![Screenshot from 2024-02-29 10-23-24](https://hackmd.io/_uploads/Bkqza6php.png) |![Screenshot from 2024-02-29 10-23-58](https://hackmd.io/_uploads/ByVSTpphp.png)| ![](https://hackmd.io/_uploads/B1yQMO--p.png)|


### $\lambda = 1.75$


|     |Packing fraction                                                                                    | Energy| Packing fraction vs volme |
| --- | ------------------------------------------------------------------------------------------ | -------- | -------- |
|  ![](https://hackmd.io/_uploads/ryXl-uWZp.png)| ![Screenshot from 2024-02-29 10-24-23](https://hackmd.io/_uploads/Skq8p6ah6.png)|![Screenshot from 2024-02-29 10-24-40](https://hackmd.io/_uploads/BJtDpa6na.png)| ![](https://hackmd.io/_uploads/rJ8gVdbb6.png)|

 

### $\lambda = 1.85$


|     |Packing fraction                                                                                    | Energy| Packing fraction vs volme |
| --- | ------------------------------------------------------------------------------------------ | -------- | -------- |
|![](https://hackmd.io/_uploads/ryXl-uWZp.png)|![Screenshot from 2024-02-29 10-25-04](https://hackmd.io/_uploads/SJ7KpTa36.png)|!![Screenshot from 2024-02-29 10-25-27](https://hackmd.io/_uploads/SkO966ph6.png)|![](https://hackmd.io/_uploads/S10oh_ZW6.png)

### Fourier transform
*See ODIN /home/users/5670772/Polygons/Fourier_Transform/*
To check which phases we obtain, we consider the FFT of the phases
#### CHECKS

| Snapshot                                      | FT                                            |
| --------------------------------------------- | --------------------------------------------- |
| ![](https://hackmd.io/_uploads/Hy1hg44Wa.png) | ![](https://hackmd.io/_uploads/HJ2HgVN-p.png) |
|![](https://hackmd.io/_uploads/B1Nkpu-b6.png)|![](https://hackmd.io/_uploads/rykG7EN-T.png)|
#### Results
*See /home/users/5670772/Polygons/analysis/Analysis_FFT/ for FFT analysis, /home/users/5670772/Polygons/data_pentagons_MC/ for data (NVT simulations are save in folders called NVT_startfrom_\<betaP\>.*

*See /home/users/5670772/Polygons/analysis/Analysis_snapshots/ for the mathematica nogebooks. Particlepositions.nb contains the script to find pictures in the first collumn, Particle_network.nb for the pictures in the third colllumn and Particle_network_direction_squares.nb to find the pictures in the last collumn )*

We took some of the fial snapshots that came out of the NPT simulation ($\epsilon/k_BT = -5.0$ for $\lambda = 1.65$ and $\lambda = 1.75$ and$\epsilon/k_BT = -3.0$ for $\lambda = 1.85$) and then ran these for many more NVT cycles to see what phases we obtain. In the third right collumn of each table we plot lines between particles if they are closer to each other than $\approx 2.25$ times the outer diameter of the pentagons. At the same time we colour the pentagons by the amount of bonds that they have. 

To make the direction of the areas that are in a Durer phase more clear, we colour the bonds that are associated with squares (by selecting bonds that have the correct length) by heir orientation (see most right collumn). Note that we only plot pentagons if they have 5 bonds. 

##### $\lambda = 1.65, \epsilon = -5$ 
Snapshots taken at $95\cdot10^6$ MC cycles
| $\beta P$ init | Snapshots                                     | FFT                                           | Network                                       |Colour bonds     |
| -------------- | --------------------------------------------- | --------------------------------------------- | --------------------------------------------- | --- |
| $3.0$          | ![](https://hackmd.io/_uploads/SkgxpoA-p.png) | ![](https://hackmd.io/_uploads/rJNLaiRba.png) | ![](https://hackmd.io/_uploads/B1-R6sRZa.png) | ![](https://hackmd.io/_uploads/SkeaLNKGT.png)  |
| $3.1$          | ![](https://hackmd.io/_uploads/H17l6iCbT.png) | ![](https://hackmd.io/_uploads/rJDI6jCZ6.png) |![](https://hackmd.io/_uploads/SynRaiAW6.png) |![](https://hackmd.io/_uploads/r19EvVKza.png)|
| $3.2$          | ![](https://hackmd.io/_uploads/H1UeTi0Wa.png) | ![](https://hackmd.io/_uploads/S15L6o0Wp.png) | ![](https://hackmd.io/_uploads/ByL0poA-p.png) |![](https://hackmd.io/_uploads/SkyBPNtf6.png) |
| $3.3$          | ![](https://hackmd.io/_uploads/Syqg6o0-T.png) | ![](https://hackmd.io/_uploads/HJaUaj0ba.png) | ![](https://hackmd.io/_uploads/Bk1J0jR-p.png) |![](https://hackmd.io/_uploads/HyaC8Etf6.png) |
| $3.4$          | ![](https://hackmd.io/_uploads/S1axaoCba.png) | ![](https://hackmd.io/_uploads/S1xKasRba.png) | ![](https://hackmd.io/_uploads/SkG1AiRZT.png) |![](https://hackmd.io/_uploads/r1SC8NFf6.png)|
| $3.5$          | ![](https://hackmd.io/_uploads/rkxW6oRWp.png) | ![](https://hackmd.io/_uploads/B1u_piA-T.png) | ![](https://hackmd.io/_uploads/BkeMRsC-T.png) | ![](https://hackmd.io/_uploads/r1PAUEYMa.png) |


##### $\lambda = 1.75, \epsilon = -5$ 
Snapshots taken at $95\cdot10^6$ MC cycles
| $\beta P$ init | Snapshots                                     | FFT                                           | Network   |
| -------------- | --------------------------------------------- | --------------------------------------------- | --- |
| $3.0$          |![](https://hackmd.io/_uploads/B1CbTjCZT.png)|![](https://hackmd.io/_uploads/HywFTs0W6.png)|![](https://hackmd.io/_uploads/rJDzRoCZp.png)|
| $3.1$          |![](https://hackmd.io/_uploads/B1gf6o0W6.png)|![](https://hackmd.io/_uploads/H1qtTsAbT.png)|![](https://hackmd.io/_uploads/SyqMAi0-T.png)|
| $3.2$          |![](https://hackmd.io/_uploads/r1QG6iAZp.png)|![](https://hackmd.io/_uploads/rkRYTsCWa.png)|![](https://hackmd.io/_uploads/ryAMAiRbp.png)|
| $3.3$          |![](https://hackmd.io/_uploads/B1Hz6oA-a.png)|![](https://hackmd.io/_uploads/B1WqpjA-a.png)|![](https://hackmd.io/_uploads/HJeX0oRZT.png)| 
| $3.4$          |![](https://hackmd.io/_uploads/HJX7TiRZT.png)|![](https://hackmd.io/_uploads/r1EqpiC-p.png)|![](https://hackmd.io/_uploads/H1BQ0sCZa.png)|
| $3.5$          |![](https://hackmd.io/_uploads/HyLQajRZa.png)|![](https://hackmd.io/_uploads/r1wqpjAZp.png)|![](https://hackmd.io/_uploads/HkuQCiCWT.png)|


##### $\lambda = 1.85, \epsilon = -3$ 
Snapshots taken at $95\cdot10^6$ MC cycles
| $\beta P$ init | Snapshots                                     | FFT                                           | Network   |
| -------------- | --------------------------------------------- | --------------------------------------------- | --- |
| $3.0$          |![](https://hackmd.io/_uploads/SJ-V6oC-p.png)|![](https://hackmd.io/_uploads/HymipiRbT.png)|![](https://hackmd.io/_uploads/ryhNRs0Wa.png)|
| $3.1$          |![](https://hackmd.io/_uploads/B1VNaj0ZT.png)|![](https://hackmd.io/_uploads/r1Rs6jAWT.png)|![](https://hackmd.io/_uploads/SJZSCiA-6.png)|
| $3.2$          |![](https://hackmd.io/_uploads/BkwEajR-p.png)|![](https://hackmd.io/_uploads/HJuiasA-a.png)|![](https://hackmd.io/_uploads/ry4SAoAba.png)|
| $3.3$          |![](https://hackmd.io/_uploads/HkqEpsAbT.png)|![](https://hackmd.io/_uploads/Sk03aiRZT.png)|![](https://hackmd.io/_uploads/HJuB0j0b6.png)| 
| $3.4$          |![](https://hackmd.io/_uploads/rkpV6j0Wp.png)|![](https://hackmd.io/_uploads/rk-TpsAb6.png)|![](https://hackmd.io/_uploads/B19r0iAba.png)|
| $3.5$          |![](https://hackmd.io/_uploads/S1eBai0ba.png)|![](https://hackmd.io/_uploads/ByBaaoAZ6.png)|![](https://hackmd.io/_uploads/SypB0jR-T.png)|


## To do
- [ ] Measure sliding parameter?

## Discuss
- [ ] Seems like there is a phase transition for pentagons (and possibly also hexagons).This is however hard to see when we are just lookig at the snapshots. 


## Possibly useful information
- [ ] At Physics at Veldhoven there was a talk of Dimitris Krommydas abouty moving without space about T1 transitions of cell tissue. It seemd to be related to Randy's stuff, so maybe at ome point this becomes useful. 



## OLD


### $\lambda = 1.65$


|     |Packing fraction                                                                                    | Energy| Packing fraction vs volme |
| --- | ------------------------------------------------------------------------------------------ | -------- | -------- |
|  ![](https://hackmd.io/_uploads/ryXl-uWZp.png)| ![](https://hackmd.io/_uploads/rJTVxOWWp.png) |![](https://hackmd.io/_uploads/BJtxf_-Wa.png)| ![](https://hackmd.io/_uploads/B1yQMO--p.png)|

|     |Snapshot                                                                                    | 
| --- | ------------------------------------------------------------------------------------------ | 
|$\beta \epsilon = -9$, $\beta P = 3.1$    | ![](https://hackmd.io/_uploads/SkQ7xu-Zp.png)|
|$\beta \epsilon = -5$, $\beta P = 3.5$    |![](https://hackmd.io/_uploads/B1t_GubZp.png)|



 


### $\lambda = 1.75$


|     |Packing fraction                                                                                    | Energy| Packing fraction vs volme |
| --- | ------------------------------------------------------------------------------------------ | -------- | -------- |
|  ![](https://hackmd.io/_uploads/ryXl-uWZp.png)| ![](https://hackmd.io/_uploads/BJW07uWZp.png) |![](https://hackmd.io/_uploads/ryXyN_Wbp.png)| ![](https://hackmd.io/_uploads/rJ8gVdbb6.png)
|

|                                        | Snapshot                                      |     |
| -------------------------------------- | --------------------------------------------- | --- |
| $\beta \epsilon = -9$, $\beta P = 3.0$ | ![](https://hackmd.io/_uploads/H1BqV_-ba.png) |     |
| $\beta \epsilon = -5$, $\beta P = 3.1$ | ![](https://hackmd.io/_uploads/BJMr0dWba.png) |     |
| $\beta \epsilon = -5$, $\beta P = 3.4$ |![](https://hackmd.io/_uploads/HJGCR_ZbT.png)|![](https://hackmd.io/_uploads/SkanCubbT.png)|
| $\beta \epsilon = -5$, $\beta P = 3.5$ | ![](https://hackmd.io/_uploads/HkQ7Hd--a.png) | ![](https://hackmd.io/_uploads/rJy_RuWW6.png)]    |



 

### $\lambda = 1.85$


|     |Packing fraction                                                                                    | Energy| Packing fraction vs volme |
| --- | ------------------------------------------------------------------------------------------ | -------- | -------- |
|![](https://hackmd.io/_uploads/ryXl-uWZp.png)| ![](https://hackmd.io/_uploads/SyFdhdbba.png)|![](https://hackmd.io/_uploads/B1lw2dbba.png)|![](https://hackmd.io/_uploads/S10oh_ZW6.png)
|


|     |Snapshot                                                                                    | 
| --- | ------------------------------------------------------------------------------------------ | 
|$\beta \epsilon = -1$, $\beta P = 3.0$    |![](https://hackmd.io/_uploads/B1uHTu-Zp.png)|
|$\beta \epsilon = -3$, $\beta P = 3.3$    |![](https://hackmd.io/_uploads/B1Nkpu-b6.png)|
|$\beta \epsilon = -3$, $\beta P = 3.5$    |![](https://hackmd.io/_uploads/HyMGpO-Zp.png)|
|$\beta \epsilon = -9$, $\beta P = 3.4$    |![](https://hackmd.io/_uploads/ryc_p_Zb6.png)|