---
# System prepended metadata

title: Voronoi model
tags: [Reversible to irreversible]

---

# Voronoi model

Github link: https://github.com/Syrocco/Voronoi

Forces derived from:
$E = \sum_i K_A(A_i-A_0)^2+K_p (P_i -P_0)^2$

Periodic boundary conditions


### Equilibrium

Some test at small temperature (overdamped with kind of a langevin bath). $dt = 0.1$, $A_0=1$, $K_A=1$ and $K_p=1$.

|  what am i looking at   | $p_0=3.6$                                           | $p_0=4.2$                                           |
| --- | --------------------------------------------------- | --------------------------------------------------- |
|  Voronoi diagram   | ![image](https://hackmd.io/_uploads/Bknkzv4sJg.png) $~$| ![image](https://hackmd.io/_uploads/SkozGwVj1x.png)$~~~~~~~~~~~~~~~~~~~~~~~~~$ |
|  Position of selected particle (red) with time |   ![image](https://hackmd.io/_uploads/B175QD4jyx.png)  |                               ![image](https://hackmd.io/_uploads/H1SMQD4sJl.png)                      |

### Sheared

$p_0=3.6$, overdamped without langevin bath

| $\gamma$| $\sim 1/4$ | $\sim 1/2$ | $\sim 1$ |
| --- | ---------- | -------- | -------- |
| Usual time  | ![](https://imgur.com/D6GPVtA.gif)       | ![](https://imgur.com/18ZA49h.gif)    | ![](https://imgur.com/llJUEln.gif)    |
| Strobo | ![small strobo](https://hackmd.io/_uploads/HJ0QwFVokl.gif)|![mid strobo](https://hackmd.io/_uploads/r1m2wYNoyl.gif)|![](https://imgur.com/Mv7muvn.gif)|

$p_0=4.1$



| $\gamma$ | $\sim 1/4$ |
| -------- | -------- |
| Usual time     | ![](https://imgur.com/SETd92M.gif)    |
|Strobo|![](https://imgur.com/uGnC7cA.gif) |

Appears irreversible, probably still irreversible with dt and $\dot\gamma$ small enough.

________________________________________

What about bidisperse?

$E = \sum_i K_A(A_i-A_{0, i})^2+K_p (P_i - q_0\sqrt{A_{0, i}})^2$


Bidisperse ratio of area =  4/3, $q_0=3.65$ leads to a frustrated/glassy state.

Unfortunately it does not seem to help to reach an irreversible state:

|                                         | Monodisperse                       | Bidisperse                                          |
| --------------------------------------- | ---------------------------------- | --------------------------------------------------- |
| Unsheared                               | ![](https://imgur.com/okdaN3I.gif) | ![](https://imgur.com/UN0MRvu.gif)                  |
| Sheared $\gamma=1$: absorbing state  |   ![image](https://hackmd.io/_uploads/ByV8A4hsyg.png)  |$~~~~~~~~~~~~~~~~~~~~~~~$ ![image](https://hackmd.io/_uploads/SJB4p4hike.png) |
| Sheared $\gamma = 0.5$: absorbing state                                        | ![image](https://hackmd.io/_uploads/HJpDAE3jkx.png)|                                     ![image](https://hackmd.io/_uploads/rJ85pVniJg.png)|

### FIRE:

Now, we minimize the energy using FIRE.

|                                         | Monodisperse                       | Bidisperse                                          |
| --------------------------------------- | ---------------------------------- | --------------------------------------------------- |
| Sheared $\gamma=1$: absorbing state  |   ![image](https://hackmd.io/_uploads/ByV8A4hsyg.png)  |$~~~~~~~~~~~~~~~~~~~~~~~$ ![image](https://hackmd.io/_uploads/SJB4p4hike.png) |
| Sheared $\gamma = 0.5$: absorbing state                                        | ![image](https://hackmd.io/_uploads/S1xxKSB2i1e.png)| ![image](https://hackmd.io/_uploads/Sk5prShiyl.png)|



____________________



| large $\gamma_{max}$                                | small $\gamma_{max}$ |
| --------------------------------------------------- | -------------------- |
| ![image](https://hackmd.io/_uploads/SJNkbshske.png) | ![image](https://hackmd.io/_uploads/BJ0XWj2j1e.png)



#### Problem with Fire:

In the solid region at $f_{norm}~\sim 10^{-12}$, $f_{norm}$ does not decrease anymore, smaller dt does not seem to help:

$q_0=3.65$ (forces = green, velocities = orange)
![](https://imgur.com/qPoNjJe.gif)

In the liquid, at $f_{norm}~\sim 10^{-3}$, $f_{norm}$ does not decrease anymore, smaller dt does not seem to help:

$q_0=3.9$
![](https://imgur.com/aqOy3Nz.gif)
![image](https://hackmd.io/_uploads/rk3YDihsJg.png)
Problem seems to be around T1: zoom ![image](https://hackmd.io/_uploads/HywiPs3i1g.png)

Note that an overdamped dynamics is able to relax it below what FIRE can do and seem to always decrease the energy:


| Evolution energy| Evolution force |
| -------- | -------- |
| ![image](https://hackmd.io/_uploads/B1cvYi2ikg.png)    | ![Text](https://imgur.com/JLADOPr.gif)    |

#### Comparison simple shear:

$K_A=0$ monodisperse, $f_{norm}=10^{-7}$ (seems independent on $f_{norm}$):

![image](https://hackmd.io/_uploads/H1MIu71hke.png)

Not the same...

Close to the solid same initial condition but different $\gamma$ step:

| ![image](https://hackmd.io/_uploads/SkVhcmyhkx.png) | ![image](https://hackmd.io/_uploads/rkb1oQ1nJg.png) | ![image](https://hackmd.io/_uploads/rJfbjm1hke.png) |
| -------- | -------- | -------- |

In between 

| ![image](https://hackmd.io/_uploads/BJeSimJ3Jg.png) | ![image](https://hackmd.io/_uploads/H1xwiXJnkg.png) | ![image](https://hackmd.io/_uploads/H1TOimJhyl.png) |
| -------- | -------- | -------- |

Close to the liquid:
![image](https://hackmd.io/_uploads/SJ72s7ynJg.png)

#### Choice of fnorm:

$\Delta \gamma = 0.007075$

| ![image](https://hackmd.io/_uploads/Hk3PwEJ2kx.png) | ![image](https://hackmd.io/_uploads/r1EtDNkh1x.png) |  ![image](https://hackmd.io/_uploads/B1hNDEJnye.png)   | ![image](https://hackmd.io/_uploads/Bk0LD4kn1l.png) |
| -------- | -------- | --- | -------- |


$\Delta\gamma = 0.001$ not really helping


![image](https://hackmd.io/_uploads/B1qJEr1hJl.png)



#### $K_a=0$ vs $K_a=1$



| $K_a=0$  | $K_a = 1$|
| -------- | -------- |
| ![](https://imgur.com/V9A3XQW.gif)    | ![](https://imgur.com/rFMJEUr.gif)|



#### Problem with intermediate dt:

Here is a pure gradient descent with a small dt step:

| $dt=0.01$  | $dt=0.001$|
| -------- | -------- |
| ![](https://imgur.com/YOxBYBT.gif)    | ![](https://imgur.com/Ij4ym35.gif)|




#### FIRE vs Conjugate gradient descent.

As FIRE cannot resolve nicely the T1, we tried Conjugate Gradient descent. Which is just a fancy gradient descent without inertia.

CG:
- Starting from a given configuration, pick a direction for which the energy decreases (Hence: close to the gradient direction)
- Search an approximation for this minimum along this direction ![image](https://hackmd.io/_uploads/HkEa6DZhke.png)
- Iterate

One problem is that in the search of an approximation for the minimum along the choosen direction, we can overshoot the local minimum...

Anyway.

FIRE does not manage to minimize correctly the energy around T1 except by pushing the particles close to a T1 using a large $dt$, this is problematic because it is arbitrary and most importantly, T1 should be induced by the modification of the potential landscape and not by the algorithm.

CG manages to minimize the energy up to a given point in which the configuration always end up with particles that would like to do a T1:

![image](https://hackmd.io/_uploads/BJ20APW3yg.png)
![image](https://hackmd.io/_uploads/BJl2yOW3ye.png)

The forces obtained from the theory here, are wrong as the gradient descent performed along this force never decrease the energy. This is due to the fact that the forces computed analytically do not take into account the change of topology of the graph during a T1.


#### Comparison between CG and FIRE
Binary mixture

##### $q_0=3.7$ 
![image](https://hackmd.io/_uploads/HJmdg5b2kl.png)

Note that for FIRE, all large drops seem to correspond to the unphysical resolution of T1:
![image](https://hackmd.io/_uploads/HJ6XTqbhke.png)


##### $q_0=3.85$

![image](https://hackmd.io/_uploads/S1yhT5Znke.png)



##### Quick simulations for absorbing state in bidisperse ($K_A=1$):

FIRE (crashes in the active region):

![image](https://hackmd.io/_uploads/BkljMOSn1x.png)

Largest $\gamma_{max}$ with an absorbing state:



| $\Delta\gamma = 0.001$ | $\Delta\gamma = 0.01$ |
| -------- | -------- |
| ![image](https://hackmd.io/_uploads/HkVEN_B2yl.png)     |   ![image](https://hackmd.io/_uploads/BJ7O4uBhkx.png) ![image](https://hackmd.io/_uploads/r19KEOH31g.png)  |

_________________________________________

CONJUGATE GRADIENT:
![image](https://hackmd.io/_uploads/rkqrGYS2Je.png)

First active state:
| Strobo | Steady state |
| -------- | -------- |
|![](https://imgur.com/z8cnaEr.gif)     | ![image](https://hackmd.io/_uploads/HJuw7Krnkg.png)     |

Last absorbing state:


| Strobo | Steady state |
| -------- | -------- |
| ![image](https://hackmd.io/_uploads/r1dxVtH21e.png) | ![image](https://hackmd.io/_uploads/BkNsQtH3kx.png)    |


The transition is a trivial one, we lose reversibility when it yields. It is plausible that the irreversibility we observe comes from the problems of the algorithm and not of the system itself.


### Testing more parameters

Conjugate Gradient:

![main](https://hackmd.io/_uploads/ByDXB4_h1l.png)

#### Last absorbing state:
shear vs strain:
![nice](https://hackmd.io/_uploads/ByvqN4O2ye.png)

stroboscopic energy evolution:
![energy](https://hackmd.io/_uploads/rJ23NEOhJe.png)

#### First active state:
shear vs strain:
![nice2](https://hackmd.io/_uploads/r1KoN4d2yg.png)
stroboscopic energy evolution:
![energy2](https://hackmd.io/_uploads/SkWhE4_nJg.png)

_____________________________________

FIRE:
![main](https://hackmd.io/_uploads/ryeIdakjpkg.png)

#### Last absorbing state:
shear vs strain:
![nice](https://hackmd.io/_uploads/r10OTJopJg.png)
stroboscopic energy evolution:
![nice2](https://hackmd.io/_uploads/H1xYp1jpyx.png)

#### First active state:
shear vs strain:
![energy](https://hackmd.io/_uploads/ryfF61i61e.png)
stroboscopic energy evolution:
![energy2](https://hackmd.io/_uploads/ByEF6JoTkg.png)

#### What the hell is wrong with the energy?

I'll be shoing configurations in which CG does not manage to find a minimum of energy. This happens around $f_{norm}\sim 10^{-7}$, the difference in energy between neighboring points will be around $10^{-14}$. This is however not the case at large $q_0$ for which, even at $f_{norm}\sim 10^{-2}$ we don't converge anymore. This is really due to a T1.


Monodisperse $K_A = 1$:
| $q_0=3.$ | $q_0=3.65$ | $q_0=4.$ |
| ------- | ---------- | ------- |
| ![image](https://hackmd.io/_uploads/HyHg_EnTke.png)| ![image](https://hackmd.io/_uploads/SJcswN2ayg.png)|![image](https://hackmd.io/_uploads/H1SzHEhTJe.png) WTF|
| ![image](https://hackmd.io/_uploads/SJ7kdN2pye.png)||![image](https://hackmd.io/_uploads/HJNZ8Enpke.png) $f_{norm}\sim 10^{-4}$|


Monodisperse $K_A = 0$:
| $q_0=3.65$                                          | $q_0=3.8$    | $q_0=4.$                                                                    |
| --------------------------------------------------- | --- | --------------------------------------------------------------------------- |
| ![image](https://hackmd.io/_uploads/B190ONnpyx.png) | ![image](https://hackmd.io/_uploads/rkXy543a1g.png) | converges                                                                   |
| ![image](https://hackmd.io/_uploads/H1hv_Vnp1e.png) |     | ![image](https://hackmd.io/_uploads/SJS-tVh6Jx.png) $f_{norm}\sim 10^{-10}$ |

Bidisperse:



| $q_0=3.$ | $q_0=3.65$ | $q_0=4.$ |
| ------- | ---------- | ------- |
|  ![image](https://hackmd.io/_uploads/By3-eN36Jl.png)|       ![image](https://hackmd.io/_uploads/HJsQJVnpJe.png)   | ![image](https://hackmd.io/_uploads/H18ReNhaJg.png) ![image](https://hackmd.io/_uploads/B1Ds-V2T1x.png)![image](https://hackmd.io/_uploads/Hy-MNN26yl.png)|
| ![image](https://hackmd.io/_uploads/r1WeeVnp1g.png)    |![image](https://hackmd.io/_uploads/HyRHJV36Jx.png)      | ![image](https://hackmd.io/_uploads/rk2PxN2pJg.png) ![image](https://hackmd.io/_uploads/Bkghg43TJl.png)|

for $q_0=4$, the forces computed theoretically are the right one as I verified them numerically by finite difference.

### 64-bits, 80-bits and 128-bits

The problem lies into the machine precision. Here, i'm running different minimization and looking at the energy landscape in the direction of the force gradient when $f_{norm}\simeq 5\times 10^{-7}$. Comparing the exact same system necessitated to be very precise with the position saving, i was lazy.

Don't compare the energy, I had to do some shenanigans to plot them for 80b and 128b systems.

|precision: | double (hardware accelerated with SIMD, 64-bits) | long double (hardware accelerated, 80-bits) | quad (software emulated, 128-bits) |
|-------| -------- | -------- | -------- |
|energy landscape|![image](https://hackmd.io/_uploads/HJ2dYD-Cyl.png) |![image](https://hackmd.io/_uploads/rJL7cP-R1e.png)| ![image](https://hackmd.io/_uploads/ByxwKv-RJl.png)   |
|$\epsilon$ precision|$2\times10^{-16}$|$1\times 10^{-19}$|$2\times 10^{-34}$|
|Minimal $f_{norm}$ we can obtain with energy based CG|$f_{norm}^{min}\simeq 5\times 10^{-7}$|$f_{norm}^{min}\simeq  10^{-9\sim 10}$|$f_{norm}^{min}\simeq  10^{-15\sim?}$|
|relative slowdown with respect to double precision|$1\times$slower|$1.5\times$slower|$5.5\times$slower|

Long double is hardware accelerated by x87 instructions. SIMD not available, this is getting optimized, most loops are too:
![image](https://hackmd.io/_uploads/ByCfSUMRkx.png)
Hot parts are linked list backed by arrays and cannot be SIMDed so the perf gain is not too dramatic

### Problem with minimizer 
![image](https://hackmd.io/_uploads/By9pqtG01l.png)

![image](https://hackmd.io/_uploads/S1PjHKGAkx.png)
[Mirages in the Energy Landscape of Soft Sphere Packings](https://arxiv.org/pdf/2409.12113). Fast minimizers are not accuratly staying in the same local minima.

#### Fire:
##### PRO:
- Fast
- Force based, machine precision not too problematic
##### CONS:
- Possible use of large $dt$ to make convergence fast can make the system fly over minima.
- Convergence problem around T1s when particles are close.
- Large $dt$ (or maybe arbitrarly small ones?), can induce fake T1s when particles are very close to each others. Said differently, I think a T1 should be resolved at the first initial steps of the minimizations (due to an energy landscape change), not in the middle of the minimzation where a T1 can probbly only be induced by a (problematic) potential barrier jump.

____________________

#### Conjugate Gradient:
Select a direction in the energy landscape (usually close to the gradient descent direction) and perform a line search along this direction.
##### Energy based minimizations
BACKWARD SEARCH:
![image](https://hackmd.io/_uploads/B1rCDYfRyg.png)
##### Pros:
- Less problem than FIRE to converge (deal with particles close to each others a bit bette)
##### Cons:
- ![image](https://hackmd.io/_uploads/BkhZ_FGAJl.png)
- ~$5$ times slower than FIRE.
- Double precision is not enough for accurate energy minimizations (factor: $^2$ compared to force based minimizations)
____________________________________________________________

FORWARD SEARCH:

![image](https://hackmd.io/_uploads/ryRn_YM0ye.png)
Qualitatively different than backjward search (compare purple (forward) vs green and red (backward)):
![image](https://hackmd.io/_uploads/BJ4UKtGR1e.png)

##### Pro
- Less problem than FIRE to converge (deal with particles close to each others a bit bette)
- Converge a bit faster than backward
- Probably jump less over minima than backward search

##### Cons
- Double not enough for energy minimizations


#### Force based minimizations:
Based on a Fortran routine in DYNAMO, [reimplemented in LAMMPS ](https://github.com/lammps/lammps/blob/develop/src/min_linesearch.cpp)
Here, we try to reduce the FORCE, not the energy. 
##### Pro:
- Better convergence without double
##### Cons:
- Horribly slow (have to compute force, which are costly compared to energy)

### Single shear comparison energy minimization method


RKF45:

We solve the dynamics:

$$\Gamma d r_i/dt = F_i ~~~~\text{ along }~~~~ d\gamma/dt = \dot{\gamma}$$

by integrating these equations and advancing time with a small $dt$.
The solver is adaptative, we solve at order 4 and check accuracy at order 5. If order 4 - order 5 is above some small threshold, we take a smaller dt
##### Bidisperse, $q_0=3.5$

![image](https://hackmd.io/_uploads/rJ2fBEBCkg.png)

Individual realization:

| Fire dt=0.1 | fire dt=0.01 |   Conjugate gradient  | RK45 adaptative |
| -------- | -------- | --- | -------- |
|![image](https://hackmd.io/_uploads/BJCvrVH01e.png)|![image](https://hackmd.io/_uploads/BJRrHNHRye.png) |![image](https://hackmd.io/_uploads/Skl9rNrCkx.png)| ![image](https://hackmd.io/_uploads/rJXSUEBCyl.png) (don't mind the weird zoom) |
||![image](https://hackmd.io/_uploads/Hkuc84SAJg.png)||![image](https://hackmd.io/_uploads/rktzw4H0yx.png)|

With RK45, we can see what is the optimal dt for a given error, here with an error between the 4th and 5th order term below $10^{-6}$, we obtain:
![image](https://hackmd.io/_uploads/Hk8mdEB0Je.png)

##### Monodisperse, $q_0=3.9$ and $K_A=0$


![image](https://hackmd.io/_uploads/Hye2uLrAkg.png)


Individual realization:

| Fire dt=0.1                                         | fire dt=0.01                                        | RK45 $\dot\gamma = 0.0003$                         |RK45 $\dot\gamma = 0.003$  |
| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --- |
| ![image](https://hackmd.io/_uploads/HkB8h4SCJx.png) | ![image](https://hackmd.io/_uploads/SJ9vnVSC1x.png) |![image](https://hackmd.io/_uploads/SkwYOLB0yg.png) |![image](https://hackmd.io/_uploads/HkcPdUrC1x.png)|
| ![image](https://hackmd.io/_uploads/BJoyRVBR1e.png) | ![image](https://hackmd.io/_uploads/S1b3T4HCke.png) | ![image](https://hackmd.io/_uploads/r1E_6ESCke.png) |     |

Concerning the optimal dt with rk4:

| Column 1 | Column 2 |
| -------- | -------- |
| ![image](https://hackmd.io/_uploads/H1YyyHH0Jg.png)    | ![image](https://hackmd.io/_uploads/SJnEA4SRJg.png)    |

singular force to perform a T1:


| snapshot                           | zoom                               | stress | dt |
| ---------------------------------- | ---------------------------------- | --- | --- |
| ![](https://imgur.com/8FpESbQ.gif) | ![](https://imgur.com/D8oF7Tw.gif) |![image](https://hackmd.io/_uploads/BkXm8SrA1g.png)|![image](https://hackmd.io/_uploads/Sy3D8SHRyg.png)|

Local rearrangment after the singular force is gotten rid off by the shear: 

![](https://imgur.com/Vwk6WC5.gif)
![](https://imgur.com/PuZQUUE.gif)
(individual images here: https://drive.google.com/drive/folders/14r4J-b-pgYFYbe-Y9EuGzi7kLaRzLFkB)
They arange as a long defect:
![image](https://hackmd.io/_uploads/SkNbQHHRJl.png)


## Adding soft cores

Runge kutta soft cores:
![image](https://hackmd.io/_uploads/rJHUp6NxZe.png)

![image](https://hackmd.io/_uploads/HJKj064l-e.png)


Still  the same problem. No overlaping anymore but still ill defined lattice.