# Advances in the Implementation of the Exactly Energy Conserving Semi-Implicit (ECsim) Particle-in-Cell Method

## Abstract

**:**

## 1. Introduction

## 2. Summary of the ECsim Method

## 3. Smoothing with the Mass Matrix Formulation

## 4. Sub-Cycling with the Mass Matrix Formulation

## 5. Simplification of the Mass Matrix: The Limit of the Implicit Moment Method

## 6. Results

#### 6.1. Effects of Sub-Cycling

#### 6.2. Effects of Smoothing

## 7. Discussion

## Funding

## Data Availability Statement

## Conflicts of Interest

## References

- Lapenta, G. Exactly energy conserving semi-implicit particle in cell formulation. J. Comput. Phys.
**2017**, 334, 349–366. [Google Scholar] [CrossRef] [Green Version] - Markidis, S.; Lapenta, G. The energy conserving particle-in-cell method. J. Comput. Phys.
**2011**, 230, 7037–7052. [Google Scholar] [CrossRef] [Green Version] - Chen, G.; Chacón, L.; Barnes, D.C. An energy-and charge-conserving, implicit, electrostatic particle-in-cell algorithm. J. Comput. Phys.
**2011**, 230, 7018–7036. [Google Scholar] [CrossRef] [Green Version] - Birdsall, C.K.; Langdon, A.B. Plasma Physics via Computer Simulation; CRC Press/Taylor & Francis Group: Boca Raton, FL, USA, 1991. [Google Scholar] [CrossRef]
- Bowers, K.J.; Albright, B.J.; Yin, L.; Daughton, W.; Roytershteyn, V.; Bergen, B.; Kwan, T.J.T. Advances in petascale kinetic plasma simulation with VPIC and Roadrunner. J. Phys. Conf. Ser.
**2009**, 180, 012055. [Google Scholar] [CrossRef] - Hockney, R.W.; Eastwood, J.W. Computer Simulation Using Particles; CRC Press/Taylor & Francis Group: Boca Raton, FL, USA, 1988. [Google Scholar] [CrossRef]
- Lapenta, G. Particle simulations of space weather. J. Comput. Phys.
**2012**, 231, 795–821. [Google Scholar] [CrossRef] - Xiao, J.; Qin, H.; Liu, J. Structure-preserving geometric particle-in-cell methods for Vlasov-Maxwell systems. Plasma Sci. Technol.
**2018**, 20, 110501. [Google Scholar] [CrossRef] [Green Version] - Brackbill, J.U.; Forslund, D.W. An implicit method for electromagnetic plasma simulation in two dimensions. J. Computat. Phys.
**1982**, 46, 271–310. [Google Scholar] [CrossRef] - Langdon, A.B.; Cohen, B.I.; Friedman, A. Direct implicit large time-step particle simulation of plasmas. J. Computat. Phys.
**1983**, 51, 107–138. [Google Scholar] [CrossRef] - Lapenta, G.; Gonzalez-Herrero, D.; Boella, E. Multiple-scale kinetic simulations with the energy conserving semi-implicit particle in cell method. J. Plasma Phys.
**2017**, 83, 705830205. [Google Scholar] [CrossRef] [Green Version] - Walker, R.J.; Lapenta, G.; Berchem, J.; El-Alaoui, M.; Schriver, D. Embedding particle-in-cell simulations in global magnetohydrodynamic simulations of the magnetosphere. J. Plasma Phys.
**2019**, 85, 905850109. [Google Scholar] [CrossRef] [Green Version] - Zhou, H.; Tóth, G.; Jia, X.; Chen, Y.; Markidis, S. Embedded kinetic simulation of Ganymede’s magnetosphere: Improvements and inferences. J. Geophys. Res. Space Phys.
**2019**, 124, 5441–5460. [Google Scholar] [CrossRef] - Lapenta, G.; El Alaoui, M.; Berchem, J.; Walker, R. Multiscale MHD-kinetic PIC study of energy fluxes caused by reconnection. J. Geophys. Res. Space Phys.
**2020**, 125, e2019JA027276. [Google Scholar] [CrossRef] - Lapenta, G.; Schriver, D.; Walker, R.J.; Berchem, J.; Echterling, N.F.; El Alaoui, M.; Travnicek, P. Do we need to consider electrons’ kinetic effects to properly model a planetary magnetosphere: The case of Mercury. J. Geophys. Res. Space Phys.
**2022**, 127, e2021JA030241. [Google Scholar] [CrossRef] - Gonzalez-Herrero, D.; Micera, A.; Boella, E.; Park, J.; Lapenta, G. ECsim-CYL: Energy Conserving Semi-Implicit particle in cell simulation in axially symmetric cylindrical coordinates. Comput. Phys. Commun.
**2019**, 236, 153–163. [Google Scholar] [CrossRef] [Green Version] - Park, J.; Lapenta, G.; Gonzalez-Herrero, D.; Krall, N.A. Discovery of an electron gyroradius scale current layer: Its relevance to magnetic fusion energy, Earth’s magnetosphere, and sunspots. Front. Astron. Space Sci.
**2019**, 6, 74. [Google Scholar] [CrossRef] [Green Version] - Chen, Y.; Tóth, G. Gauss’s law satisfying energy-conserving semi-implicit particle-in-cell method. J. Comput. Phys.
**2019**, 386, 632–652. [Google Scholar] [CrossRef] [Green Version] - Campos Pinto, M.; Pagès, V. A semi-implicit electromagnetic FEM-PIC scheme with exact energy and charge conservation. J. Comput. Phys.
**2022**, 453, 110912. [Google Scholar] [CrossRef] - Boris, J.P. Relativistic plasma simulation-optimization of a hybrid code. In Proceedings of the Fourth Conference on Numerical Simulation of Plasmas, Washington, DC, USA, 2–3 November 1970; pp. 3–67. [Google Scholar]
- Brackbill, J.U.; Cohen, B.I. (Eds.) Multiple Time Scales; Academic Press, Inc.: Orlando, FL, USA, 1985. [Google Scholar] [CrossRef]
- Vu, H.X.; Brackbill, J.U. Accurate numerical solution of charged particle motion in a magnetic field. J. Comput. Phys.
**1995**, 116, 384–387. [Google Scholar] [CrossRef] - Lapenta, G.; Brackbill, J.U.; Ricci, P. Kinetic approach to microscopic-macroscopic coupling in space and laboratory plasmas. Phys. Plasmas
**2006**, 13, 055904. [Google Scholar] [CrossRef] [Green Version] - Markidis, S.; Lapenta, G.; Rizwan-uddin. Multi-scale simulations of plasma with iPIC3D. Math. Comput. Simul.
**2010**, 80, 1509–1519. [Google Scholar] [CrossRef] [Green Version] - Gonzalez-Herrero, D.; Boella, E.; Lapenta, G. Performance analysis and implementation details of the Energy Conserving Semi-Implicit Method code (ECsim). Comput. Phys. Commun.
**2018**, 229, 162–169. [Google Scholar] [CrossRef] [Green Version] - de Boor, C. A Practical Guide to Splines; Springer: New York, NY, USA, 1978. [Google Scholar]
- Vu, H.X.; Brackbill, J.U. CELEST1D: An implicit, fully kinetic model for low-frequency, electromagnetic plasma simulation. Comput. Phys. Comm.
**1992**, 69, 253–276. [Google Scholar] [CrossRef] - Burgess, D.; Sulsky, D.; Brackbill, J.U. Mass matrix formulation of the FLIP particle-in-cell method. J. Comput. Phys.
**1992**, 103, 1–15. [Google Scholar] [CrossRef] - Boella, E.; Innocenti, M.E.; Bettencourt, M.; Chimeh, M.; Lapenta, G.; Parodi, P.; Shukla, N.; Spiga, F. On Adding GPU Support to the Particle-in-Cell code ECsim. OpenACC and Hackathons Summit 2022, 2 August 2022, Virtual. Available online: https://www.youtube.com/watch?v=9FK8zty8BgA (accessed on 15 December 2022).
- Lee, W.W. Gyrokinetic particle simulation model. J. Comput. Phys.
**1987**, 72, 243–269. [Google Scholar] [CrossRef] [Green Version] - Ricci, P.; Lapenta, G.; Brackbill, J.U. A simplified implicit Maxwell solver. J. Computat. Phys.
**2002**, 183, 117–141. [Google Scholar] [CrossRef] [Green Version] - OpenACC. Available online: https://www.openacc.org/ (accessed on 15 December 2022).
- CUDA Zone. Available online: https://developer.nvidia.com/cuda-zone (accessed on 15 December 2022).
- Lapenta, G.; Markidis, S.; Marocchino, A.; Kaniadakis, G. Relaxation of relativistic plasmas under the effect of wave-particle interactions. Astrophys. J.
**2007**, 666, 949–954. [Google Scholar] [CrossRef] - Fried, B.D. Mechanism for instability of transverse plasma waves. Phys. Fluids
**1959**, 2, 337. [Google Scholar] [CrossRef] - Lazar, M.; Schlickeiser, R.; Wielebinski, R.; Poedts, S. Cosmological effects of Weibel-type instabilities. Astrophys. J.
**2009**, 693, 1133–1141. [Google Scholar] [CrossRef] [Green Version] - Innocenti, M.E.; Lazar, M.; Markidis, S.; Lapenta, G.; Poedts, S. Electron streams formation and secondary two stream instability onset in the post-saturation regime of the classical Weibel instability. Phys. Plasmas
**2011**, 18, 052104. [Google Scholar] [CrossRef] [Green Version] - Nevins, W.M.; Hammett, G.W.; Dimits, A.M.; Dorland, W.; Shumaker, D.E. Discrete particle noise in particle-in-cell simulations of plasma microturbulence. Phys. Plasmas
**2005**, 12, 122305. [Google Scholar] [CrossRef]

**Figure 1.**Particle velocity distribution at the end of 10 different simulations of same total duration varying the number of sub-cycles, ${N}_{\nu}=1$ (

**top)**, 2, 3 to 10 (

**bottom**), and correspondingly increasing time step, $\mathsf{\Delta}t$, by the same factor. See text for details.

**Figure 2.**Scatter plot of the phase space for the particles at the end of 10 different simulations of same total duration varying the number of sub-cycles, ${N}_{\nu}=1$ (

**top)**, 2, 3 to 10 (

**bottom**), and correspondingly increasing $\mathsf{\Delta}t$ by the same factor. See text for details.

**Figure 3.**Evolution of the phase space section $(x,{v}_{x})$ in the transverse counter-streaming instability. The red particles have ${v}_{y}<0$, and the blue particles have ${v}_{y}>0$. Three times are shown, and the

**left**(

**right**) panels report the non-smoothed (smoothed) run: ${\omega}_{pe}t=6.35$ (

**a**,

**b**), 25 (

**c**,

**d**), $43.75$ (

**e**,

**f**), and $62.5$ (

**g**,

**h**). See text for details.

**Figure 4.**Evolution of the energy in the transverse counter-streaming instability without smoothing (

**left**) and with smoothing (

**right**) with the exchange between kinetic and magnetic energy, with a minority contribution going to the electric field energy (

**top**) and the total energy conservation (

**bottom**).

**Figure 5.**Transverse counter-streaming instability in absence of smoothing for ${E}_{x}$ (

**left**,) ${E}_{z}$ (

**middle**), and ${B}_{y}$ (

**right**) in the spatiotemporal plane $(x,t)$ (

**top**) and in the spectral plane $(k,\omega )$ (

**bottom**). See text for details.

**Figure 6.**Transverse counter-streaming instability in presence of smoothing. Three fields are shown from left to right: ${E}_{x}$, ${E}_{z}$ and ${B}_{y}$. The top row shows the spatiotemporal plane $(x,t)$, and the bottom row shows the spectral plane $(k,\omega )$. ${E}_{x}$ (

**left**), ${E}_{z}$ (

**middle**), and ${B}_{y}$ (

**right**) in the spatiotemporal plane $(x,t)$ (

**top**) and in the spectral plane $(k,\omega )$ (

**bottom**).

**Table 1.**Effect of sub-cycling on a two-stream instability run. Values attained while varying the number ${N}_{\nu}$ of sub-cycles, from 1 to 10 and correspondingly increasing the duration of the simulation in seconds, the seconds spent per the time step, $\mathsf{\Delta}t$, and the energy error, $\mathsf{\Delta}E$, by the same factor $\mathsf{\Delta}t$ are reported.

${\mathit{N}}_{\mathit{\nu}}$ | Time (s) | Seconds/$\mathbf{\Delta}\mathit{t}$ | $\mathbf{\Delta}\mathit{E}$ |
---|---|---|---|

1.0 | 42.73 | 0.08395 | $1.75\phantom{\rule{0.166667em}{0ex}}\times {10}^{-16}$ |

2.0 | 20.94 | 0.08244 | $1.1\phantom{\rule{0.166667em}{0ex}}\times {10}^{-16}$ |

3.0 | 14.63 | 0.08657 | $1.015\phantom{\rule{0.166667em}{0ex}}\times {10}^{-16}$ |

4.0 | 10.88 | 0.08567 | $7.388\phantom{\rule{0.166667em}{0ex}}\times {10}^{-17}$ |

5.0 | 8.97 | 0.08881 | $6.764\phantom{\rule{0.166667em}{0ex}}\times {10}^{-17}$ |

6.0 | 7.36 | 0.08762 | $8.342\phantom{\rule{0.166667em}{0ex}}\times {10}^{-17}$ |

7.0 | 6.46 | 0.08972 | $7.988\phantom{\rule{0.166667em}{0ex}}\times {10}^{-17}$ |

8.0 | 5.74 | 0.09111 | $8.492\phantom{\rule{0.166667em}{0ex}}\times {10}^{-17}$ |

9.0 | 5.27 | 0.09411 | $8.14\phantom{\rule{0.166667em}{0ex}}\times {10}^{-17}$ |

10.0 | 4.79 | 0.0958 | $8.61\phantom{\rule{0.166667em}{0ex}}\times {10}^{-17}$ |

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |

© 2023 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Lapenta, G.
Advances in the Implementation of the Exactly Energy Conserving Semi-Implicit (ECsim) Particle-in-Cell Method. *Physics* **2023**, *5*, 72-89.
https://doi.org/10.3390/physics5010007

**AMA Style**

Lapenta G.
Advances in the Implementation of the Exactly Energy Conserving Semi-Implicit (ECsim) Particle-in-Cell Method. *Physics*. 2023; 5(1):72-89.
https://doi.org/10.3390/physics5010007

**Chicago/Turabian Style**

Lapenta, Giovanni.
2023. "Advances in the Implementation of the Exactly Energy Conserving Semi-Implicit (ECsim) Particle-in-Cell Method" *Physics* 5, no. 1: 72-89.
https://doi.org/10.3390/physics5010007