원시데이터 수집 시스템
선정목록으로

Reversible Simulations of Elastic Collisions

관련 필름·전자재료 · (13) 프리즘 필름

기본 정보

저자
  1. Perumalla, Kalyan S.
  2. Protopopescu, Vladimir A
DOI
10.48550/arxiv.1302.1126
저널
arXiv (Cornell University)
발행년도
2022
발행기관
Cornell University
피인용수
0
라이선스
0
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.48550/arxiv.1302.1126
토픽
Composite Material Mechanics
OpenAlex ID
W6910667425

평가 내용

관련도
관련
사업분야
필름·전자재료 · (13) 프리즘 필름
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '필름·전자재료 > 프리즘 필름' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

Consider a system of N identical hard spherical particles moving in a d-dimensional box and undergoing elastic, possibly multi-particle, collisions. We develop a new algorithm that recovers the pre-collision state from the post-collision state of the system, across a series of consecutive collisions, with essentially no memory overhead. The challenge in achieving reversibility for an n-particle collision (where, n << N) arises from the presence of nd-d-1 degrees of freedom during each collision, and from the complex geometrical constraints placed on the colliding particles. To reverse the collisions in a traditional simulation setting, all of the particular realizations of these degrees of freedom during the forward simulation must be saved. This limitation is addressed here by first performing a pseudo-randomization of angles, ensuring determinism in the reverse path for any values of n and d. To address the more difficult problem of geometrical and dynamic constraints, a new approach is developed which correctly samples the constrained phase space. Upon combining the pseudo-randomization with correct phase space sampling, perfect reversibility of collisions is achieved, as illustrated for n <= 3, d=2, and n=2, d=3 (and, in principle, generalizable to larger n). This result enables for the first time reversible simulations of elastic collisions with essentially zero memory accumulation. The reverse computation methodology uncovers important issues of irreversibility in conventional models, and the difficulties encountered in arriving at a reversible model for one of the most basic physical system processes, namely, elastic collisions for hard spheres. Insights and solution methodologies, with regard to accurate phase space coverage with reversible random sampling proposed in this context, can help serve as models and/or starting points for other reversible simulations.

본문 119,291자

본문 펼치기
### Reversible Simulations of Elastic Collisions ∗ Kalyan S. Perumalla <sup>†</sup> Vladimir A. Protopopescu Oak Ridge National Laboratory One Bethel Valley Rd, Oak Ridge, TN 37831-6085, USA July 14, 2018 Abstract Consider a system of N identical hard spherical particles moving in a d-dimensional box and undergoing elastic, possibly multi-particle, collisions. We develop a new algorithm that recovers the pre-collision state from the post-collision state of the system, across a series of consecutive collisions, with essentially no memory overhead. The challenge in achieving reversibility for an n-particle collision (where, in general, n ≪ N ) arises from the presence of nd−d−1 degrees of freedom (arbitrary angles) during each collision, as well as from the complex geometrical constraints placed on the colliding particles. To reverse the collisions in a traditional simulation setting, all of the particular realizations of these degrees of freedom (angles) during the forward simulation must be tracked. This requires memory proportional to the number of collisions, which grows very fast with N and d, thereby severely limiting the de facto applicability of the scheme. This limitation is addressed here by first performing a pseudo-randomization of angles, which ensures determinism in the reverse path for any values of n and d. To address the more difficult problem of geometrical and dynamic constraints, a new approach is developed which correctly samples the constrained phase space. Upon combining the pseudo-randomization with correct phase space sampling, perfect reversibility of collisions is achieved, as illustrated for n ≤ 3, d = 2, and n = 2, d = 3. This result enables, for the first time, reversible simulations of elastic collisions with essentially zero memory accumulation. In principle, the approach presented here could be generalized to larger values of n. The reverse computation methodology presented here uncovers important issues of irreversibility in conventional models, and the difficulties encountered in arriving at a reversible model for one of the most basic and widely used physical system processes, namely, elastic collisions for hard spheres. Insights and solution methodologies, with regard to accurate phase space coverage with reversible random sampling proposed in this context, can help serve as models and/or starting points for other reversible simulations. ∗Association for Computing Machinery Transactions on Modeling and Computer Simulation (ACM TOMACS) Vol. 23, No. 2, 2013 †perumallaks@ornl.gov 1 #### Contents 1 Introduction 3 1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2 Problem Definition and Terminology 3 2.1 Reversibility Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2 Collision Configurations and Constraints . . . . . . . . . . . . . . . . . . . 4 2.3 Dynamics and Geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.4 Simplified Notation for 2 ≤ n ≤ 3, 1 ≤ d ≤ 3 . . . . . . . . . . . . . . . . . 6 3 Skeleton of the Algorithm 6 3.1 Reversible Collision Operation . . . . . . . . . . . . . . . . . . . . . . . . 6 3.2 Collision Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.3 General and Specific Settings . . . . . . . . . . . . . . . . . . . . . . . . . 7 4 Algorithm Implementation 7 4.1 Reversal for 2-Particle Collisions in 1 Dimension . . . . . . . . . . . . . . 7 4.2 Reversal for 2-Particle Collisions in 2 Dimensions . . . . . . . . . . . . . . 8 4.3 Reversal for 2-Particle Collisions in 3 Dimensions . . . . . . . . . . . . . . 11 4.4 Reversal for 3-Particle Collisions in 1 Dimension . . . . . . . . . . . . . . 12 4.4.1 Solving the Equations of Motion . . . . . . . . . . . . . . . . . . . 12 4.4.2 Sampling the Ψ Phase Space . . . . . . . . . . . . . . . . . . . . . 13 4.4.3 Sampling the Circumference of the Ellipse . . . . . . . . . . . . . . 13 4.4.4 Resolving the Geometrical Constraints . . . . . . . . . . . . . . . . 14 4.4.5 Combining Dynamics and Geometry . . . . . . . . . . . . . . . . . 18 4.5 Reversal for 3-Particle Collisions in 2 Dimensions . . . . . . . . . . . . . . 18 4.5.1 Possible Geometries . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.5.2 Sampling the Ψ Phase Space . . . . . . . . . . . . . . . . . . . . . 21 4.5.3 Configuration C1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 4.5.4 Configuration C2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 4.5.5 Configuration C3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 4.5.6 Configuration C4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4.6 Random Number Generation . . . . . . . . . . . . . . . . . . . . . . . . . 27 5 Implementation Results 29 5.1 Collision Sequence Reversal . . . . . . . . . . . . . . . . . . . . . . . . . . 29 5.2 Randomness Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 6 Performance Estimation 32 7 Summary 36 2 #### 1 Introduction 1.1 Background Modeling and simulation of particle collisions for a wide range of collision types has been a subject of scientific interest for a long time. However, while the forward simulation of collisions is relatively well understood, their reversible simulation is much less so. Here, we study the problem of modeling and simulating elastic collisions reversibly. In a system of N identical hard spherical particles colliding with each other in a d-dimensional box, every elastic collision, in general, yields an underspecified system of equations and inequalities [TM80]. The underspecified nature of the system gives rise to interesting challenges for reversibility, such as the issue of memory accumulation and the need for unbiased phase space coverage. In each multi-particle collision of n ≪ N hard particles in d dimensions, the velocities represent nd variables in the post-collision state, which are related to the nd velocities in the pre-collision state via conservation laws. Upon applying conservation of momenta and kinetic energy, one is left with nd − d − 1 unspecified degrees of freedom. Deterministic solutions to this underspecified system add new constraints that correspond to specific additional assumptions on the collisions. For example, in a 2-particle collision, determinism may be induced by exchanging velocity components along the line joining the centers of the two particles [Lub91, Mar97a, Mar97b, HBD <sup>+</sup> 89]. Non-deterministic solutions can be obtained by infusing the appropriate amount of randomization needed to cover the phase space of the underspecified system in a complete and unbiased manner. Of particular concern, is accounting for geometric constraints, e.g., disallowing particle-overlapping at all times. The goal of our work is to develop a modeling and simulation framework which accurately and completely recovers the pre-collision state from the post-collision state of all particles involved in every collision in a sequence of collisions in the system, with essentially no memory overhead. 1.2 Organization In Section 2, the problem is defined and terminology is introduced. The basic outline of our approach to reversal of elastic collisions is outlined in Section 3. This is followed by Section 4 which gives detailed reversal algorithms for 2-particle collisions (up to 3 dimensions) and 3-particle collisions (up to 2 dimensions). Results from experiments with a software realization of the algorithms are presented in Section 5. An estimation of the potential performance gains from reverse computation, in comparison to conventional state saving approaches, is given in Section 6. The findings are summarized in Section 7. #### 2 Problem Definition and Terminology 2.1 Reversibility Problem Consider a system consisting of N identical hard spheres of diameter D in a d dimensional cubic box undergoing elastic collisions among themselves and/or with the walls of the box. Reversible simulation of particle collisions in the system means that, at any moment, the simulation can be stopped and executed backwards to arbitrary points in 3 the past, potentially all the way to the initial state, such that the positions and velocities of particles are restored to the same values that the particles had at the chosen point in the past. The problem is to achieve this reversible simulation with minimal or, ideally, no memory overhead. The reversal scheme must support starting the system with arbitrary initial configurations, and must be able to evolve the system to arbitrary numbers of collisions into the future. Moreover, given that particles are marked with identifiers from 1 to N, the system state must be restored to the correct initial identifier assignation. An important requirement of the collision model is the uniform (unbiased) coverage of all available phase space. In particular, the scattering law upon each collision must uniformly sample the full range of restitution angles available to each pair of particles upon their collision. 2.2 Collision Configurations and Constraints Here we consider collisions of three types: (1) single particle-wall collisions, (2) nparticle-wall collisions, and (3) n-particle collisions (n > 1). The first type is straightforward to reverse. The second type is treated, without loss of generality, as a simultaneous set of individual wall-particle collisions, followed by n-particle collision (for any collisions that remain after the application of individual wall-particle collisions). The third is the more complex problem treated in the remainder of the paper. The collision of a particle with a wall is modeled by changing the sign of the velocity component that is orthogonal to the wall. If a particle touches more than one wall simultaneously at an edge or a corner of the box, all the appropriate velocity components change their sign. Other commonly used deterministic boundary conditions such as periodic wall boundaries [Lub91, Mar97a, Mar97b, Kra96] can be reversed analogously. For completeness, we list here the set of system configurations that are either trivial configurations that are not of interest, or are simple to solve separately without needing the complexity of our algorithm. - Trivial or degenerate situations, in which particles never come in contact. Examples include all particles being at rest (zero kinetic energy), which is clearly an uninteresting case. - Situations in which particles do come in contact, but do not exchange momentum. Examples in the first category include initial conditions in which: - all particles are at rest, or - all N particles have velocities along one coordinate axis (say x) and the area of the particles’ projections on the (y, z) plane is <sup>πND</sup> 4 <sup>2</sup> (this perpetually collides particles with walls but never results in any particle-particle collisions). Examples in the second category include grazing collisions, for which the line passing through the particles’ centers at the encounter time is perpendicular to their (parallel or anti-parallel) velocities. This condition is easily detected and either ignored or a degenerate collision operator can be defined separately and applied. 4 2.3 Dynamics and Geometry In an n-particle collision, let⃗V <sup>′</sup> i be the pre-collision velocity of particle i, and⃗Vi its postcollision velocity. For every pair of particles i and j that are in contact in the collision, let⃗rji be the vector from center of particle j to that of particle i at the collision moment. Let the total momentum of the n colliding particles be⃗M and their total kinetic energy be E. Then, the dynamics and geometry require the following: 2 = E - 0   V <sup>′</sup> i = n i=1 i=1 Vi =⃗M n i=1 n i=1 Dynamics, (1) (⃗V <sup>′</sup> i) <sup>2</sup> = n i=1 i=1 (⃗Vi)  rji · (⃗V <sup>′</sup> i −⃗V <sup>′</sup> j) < 0 (pre-collision) rji · (⃗Vi −⃗Vj ) > 0 (post-collision) ����� of the inequalities (< instead of ∀i, j such that particles i and j are in contact ∀i, j such that particles rji · (⃗Vi −⃗Vj ) > 0 (post-collision) Geometry. (2) In Equation (2), the strictness of the inequalities (< instead of ≤, and - instead of ≥) ensures that grazing collisions are excluded. Let dn = nd − d − 1 denote the number of degrees of freedom in the collision. Denote by Φ = {φk|1 ≤ k ≤ dn} the set of “parameters” that, given⃗M and E, uniquely determines the set of velocities V = {⃗Vi|1 ≤ i ≤ n} of all particles in an n-particle collision. Let Φ′ correspond to the parameters encoding the pre-collision uniquely determines the set of velocities V = {⃗Vi|1 ≤ i ≤ n} of all particles in an n-particle collision. Let Φ′ correspond to the parameters encoding the pre-collision velocities, and let Φ (or, where ambiguous, Φ′′ ) encode the post-collision velocities. In velocities, and let Φ (or, where ambiguous, Φ′′ ) encode the post-collision velocities. In 2-particle collisions, the parameters correspond to geometrical angles of points on the surface of a dn-sphere, whereas, in 3-particle collisions, the parameters are different from the geometrical angles of points on the surface of a (dn + 1)-dimensional ellipsoid. In randomly sampling the phase space spanned by the dn parameters, at least dn random numbers must be generated per collision. Reversible random number generators are used to generate the needed random samples per collision, each sample value uniformly distributed in [0, 1). The generators themselves require only a constant amount of memory. In practice, the memory per generator is often only a few bytes long. In theory, the memory only needs to be independent of the number of collisions being simulated. Additional considerations in random number generation that are critical to reversibility are discussed in Section 4.6. Our reversible collision algorithm uses the following mappings. V -to-Φ: Given V, this mapping determines the set of angles Φ that uniquely determines V . In forward execution, this mapping will be applied on pre-collision velocities V <sup>′</sup> to obtain Φ′. In reverse execution, this mapping function will be used to determine Φ from the post-collision velocities V in a collision. Φ-to-V : Given the angles Φ, together with⃗M and E, this mapping reconstructs all corresponding V . In forward execution, this mapping will be used to generate the post-collision velocities V based on reversibly computed values of Φ. The same mapping function will also be used in reverse execution to determine the pre-collision velocities V <sup>′</sup> from the recovered value of Φ′ of a collision. G: Let G = {Gk|1 ≤ k ≤ dn} denote the set of pseudo random numbers generated for each collision, where each Gk ∈ [0, 1). The generator used to generate G is reversible, of high quality, and with a sufficiently long period. The generator can either be a single stream or contain dn independent, parallel streams. 5 G-to-Ψ: Further, let Ψ = {ψk|1 ≤ k ≤ dn}, be the set of angle offsets generated from random numbers G. In both forward as well as reverse execution, the G-to-Ψ function will be used as a deterministic mapping from uniform random numbers to angle offsets. The specific mapping function depends on n and d, but the function only depends on the (reversible) random numbers, total momenta and total energy; it does not depend on the individual velocities of particles in collision. In the remainder of the article, unless otherwise specified, all arithmetic on the angles will be performed modulo 2π. 2.4 Simplified Notation for 2 ≤ n ≤ 3, 1 ≤ d ≤ 3 When dealing with collisions in which at most three particles are in contact with each other, in 1- or 2-dimensional space (and also in the case in which two particles are in contact with each other in 3-dimensional space), a simplified notation is used in the remaining of the article to refer to their velocities, momenta, and energy. The letters a–f will be used to refer to the components of the velocities along the x, y, and z directions. The letters a <sup>′</sup> –f <sup>′</sup> will be used to refer to the corresponding pre-collision values of the velocity components. The letters α, β, and γ will be used as the sums of momenta along the x, y and z spatial directions respectively, and δ will be used for total kinetic energy. Thus, for example, in a 2-dimensional, 2-particle collision, the post-collision equations will be written as a + b = α (total momentum in the x-direction), c + d = β (total momentum in the y-direction), and a <sup>2</sup> + b <sup>2</sup> + c <sup>2</sup> + d <sup>2</sup> = δ (total energy), where a = V1x, b = V2x, c = V1y and d = V2y are the velocities of the two particles in the x and y directions. In the remainder of the article, note that δ - 0, since the system must have non-zero kinetic energy for collisions to occur. #### 3 Skeleton of the Algorithm In any n-particle collision, the information available at hand during forward execution are the pre-collision velocities as well as the ranges of the angles that determine the range of permissible post-collision velocities. The pre-collision velocity configuration of all the n colliding particles can be uniquely encoded in terms of the total momentum, total energy, and the specific values of the free angles. Since all collisions are elastic, the total momentum and energy do not need any memory to recover. The problem thus reduces to that of developing a one-to-one mapping of pre-collision and post-collision angles, while still uniformly sampling all available phase space for the angles at every collision. In order to properly sample the available phase space, we use pseudo random numbers to select the angle values from the permissible ranges. The reversibility of the pseudo random number generators ensures the ability to go forward as well as backward in the random number sequence as needed, during forward and reverse execution, respectively. 3.1 Reversible Collision Operation The problem reduces now to developing a collision algorithm that (a) takes dn pseudo random numbers, each uniformly distributed in [0, 1), and gives dn reversible random angle offsets that satisfy the pre-collision phase space constraints, and (b) recovers the pre-collision angles from the random offsets recovered upon backward execution. 6 Once such a collision algorithm is developed, it can be used to uniquely recover the pre-collision velocities as follows. First, the random number sequence is reversed, thereby recovering the random numbers that were used in the forward execution. These are then used to recreate the random offsets that were used in the forward execution. The random offsets are applied in the opposite direction on the post-collision values of the free angles to uniquely recover the pre-collision values of the free angles, which in turn uniquely give the pre-collision velocities. 3.2 Collision Sequences Collision sequences are modeled using standard techniques [Lub91, ML04, Kra96], by which, at every step of forward evolution, the time for next collision of each particle is determined, time is advanced to the earliest collision time, the particles undergoing collision are determined, their pre-collision velocities are transformed by our reversible algorithm to give post-collision velocities, and the process is repeated. In order to reverse the collision sequence, it is necessary to recover the most recent collision event in the past. That event is obtained by reversing the direction of all particles’ velocities and employing the usual forward algorithm for determining the next earliest collision. The event represents information on the amount of time, dt, to go back in time, and the identities of the colliding particles. The system is then stepped back in time by dt units by changing the sign of the velocities of all particles, and linearly transporting them for dt units. At that moment, clearly, the colliding particles would be found to be in contact. The reverse collision algorithm is then applied on the particles in contact. This process is repeated iteratively until the time of interest in the past is reached. 3.3 General and Specific Settings This general reversal scheme is applicable in principle to any values of n and d. However, the actual permissible ranges of the free angle values remain to be determined for each (n, d) pair. As illustrations, we develop the geometrical constraints for the subsets n ≤ 3, d ≤ 2 and n = 2, d = 3. While the development of the permissible angle ranges for n = 2 is relatively straightforward, those for n = 3 become complex starting even from d = 1. #### 4 Algorithm Implementation Here, we determine the phase space of the permissible reversible random offsets that need to be sampled for 2-particle collisions in 1, 2, and 3 dimensions, and for 3 particles in 1 and 2 dimension. 4.1 Reversal for 2-Particle Collisions in 1 Dimension In a collision of 2 particles in 1-dimensional space, as shown in Figure 1, let P1 be the particle on the right moving with velocity a, and P2 be the particle on the left moving with velocity b. The constraints on dynamics and post-collision geometry are: 7 b P2 P1 a r21 Figure 1: Canonical configuration of 2 particles in 1 dimension a + b = α a <sup>2</sup> + b <sup>2</sup> = δ, 2δ - α <sup>2</sup> Dynamics, (3) r21 · (a − b) > 0 for r21 = D - 0� Geometry. (4) The pre-collision geometrical constraints are obtained by replacing - 0 by < 0 in the post-collision constraints. The system is fully defined without any free angles, giving deterministic one-to-one mapping from pre-collision to post-collision velocities and hence reversibility is unambiguous. Nevertheless, this configuration is treated here for completeness. The equations of motion imply that: - α <sup>2</sup>, and b = <sup>α</sup> 2 2 <sup>α</sup> 2 <sup>−</sup> a = <sup>α</sup> 2 <sup>+</sup> √ 2δ − α <sup>2</sup> 2 √ 2δ − α <sup>2</sup> Dynamics, (5) �geometrical2δ − α <sup>2</sup> - 0constraint.� Geometry, (6) r21 · (a − b) = +r21 i.e., the dynamical solution satisfies the geometrical constraint. 4.2 Reversal for 2-Particle Collisions in 2 Dimensions In a collision of 2 particles in 2-dimensional space, let a and c be the x and y velocity components of the particle with the smaller identifier, and b and d be the corresponding velocity components of the other particle. The equations of motion and post-collision geometry are: a + b = α, c + d = β a <sup>2</sup> + b <sup>2</sup> + c <sup>2</sup> + d <sup>2</sup> = δ, and 2δ - α <sup>2</sup> + β <sup>2</sup> Dynamics, (7) r21x · (a − b) + r21y - (c − d) > 0 for some r21x, r21y - 0 Geometry. (8) The pre-collision geometrical constraints are obtained by replacing > 0 by < 0 in the post-collision constraints. The equations of motion imply that: �a − <sup>α</sup> 2 + �2 = <sup>2δ −</sup> <sup>(α2 + β2)</sup> 4 �2 2 �c − <sup>β</sup> 2 2 <sup>2 + β2)</sup> = R <sup>2</sup>, (9) 4 i.e., the point (a, c) lies on a circle of radius R = 2δ − (α <sup>2</sup> + β <sup>2</sup> + γ <sup>2</sup> )/2 centered at (α/2, β/2), whose parametric equations are given by: i.e., the point (a, c) lies on a circle of radius R = 8 a = <sup>α</sup> 2 <sup>β</sup> (10) 2 <sup>+ R sin φ1</sup> <sup>,</sup> <sup>and</sup> <sup>φ1</sup> <sup>∈</sup> <sup>[0, 2π).</sup> <sup>α</sup> = <sup>β</sup> 2 <sup>+ R cos φ1</sup> <sup>,</sup> <sup>c</sup> 2 Equation2-particle collisions.(10) providesGiven (the aV <sup>′</sup> -to-Φ, b <sup>′</sup>, c <sup>′</sup>, dand <sup>′</sup> ), a uniqueΦ-to-V φmapping′1 <sup>can be determined.</sup> functions for <sup>Similarly, given</sup> 2-dimensional (φ1, α, β, δ), (a, b, c, d) can be uniquely determined. #### _P1_ r21 _-R_ _Φ1'_ _Ψ_ #### _P2_ _Φ1'_ _R_ _Ψ_ _Phase space of_ _post-collision Φ1_ Figure 2: Configuration of 2 particle collision in 2 dimensions in the center-of-mass frame random offsetGiven the pre-collision angleψ from φ′1 <sup>to</sup> <sup>give</sup> φ <sup>the</sup> ′1 <sup>, the problem at hand is the generation of a reversiblepost-collision</sup> <sup>angle</sup> <sup>φ1</sup> <sup>= φ</sup> ′1 <sup>+ ψ</sup> <sup>which</sup> <sup>can</sup> <sup>then</sup> <sup>be</sup> Given the pre-collision angle φ random offset ψ from φ′1 <sup>to</sup> <sup>give</sup> <sup>the</sup> <sup>post-collision</sup> <sup>angle</sup> <sup>φ1</sup> <sup>= φ</sup> ′1 <sup>+ ψ</sup> <sup>which</sup> <sup>can</sup> <sup>then</sup> <sup>be</sup> used to determine the post-collision velocities. Since the phase space of φ1 is [0, 2π), it isfullnecessaryphase spaceto samplecoverage independentthe random offsetof ψφ′1also from <sup>.</sup> <sup>This</sup> <sup>is</sup> <sup>illustrated</sup> the same range, <sup>in</sup> <sup>Figure</sup> in order <sup>2</sup> <sup>in</sup> <sup>which</sup> to ensure <sup>the</sup> full phase space coverage independent of φ′1 <sup>.</sup> <sup>This</sup> <sup>is</sup> <sup>illustrated</sup> <sup>in</sup> <sup>Figure</sup> <sup>2</sup> <sup>in</sup> <sup>which</sup> <sup>the</sup> colliding pair is visualized in its center-of-mass frame of reference (in this particular case of 2-particles in 2-dimensions, the geometric angle φ1 indeed corresponds to the degree of freedom, but this does is not true in general). Moreover since the circumference of the circle is uniformly sampled by uniformly sampling the angle subtended at the center, it is sufficient to generate ψ uniformly from 0 to 2π. Thus, ψ ∈ [0, 2π) is generated with a G-to-Ψ mapping given by ψ = 2Gπ, with a uniformly distributed random number G ∈ [0, 1). However, the φ1 value thus computed may violate the geometry constraint Equation (8) on post-collision velocities. If such a violation occurs with the generated random offset, the φ1 value can be “corrected” by adding π to it; the addition of π guarantees satisfaction of the geometry constraint on post-collision velocities because of the following observations: Since (a − b) = 2R cos φ1, and (c − d) = 2R sin φ1, if r21x · (a − b) + r21y - (c − d) < 0 then r21x · (2R cos φ1) + r21y - (2R sin φ1) < 0 (11) =⇒ r21x · (2R cos(φ1 + π)) + r21y - (2R sin(φ1 + π)) - 0. F :Thus, the post-collision angle, using the random angle offsetφ1 = φ′1 <sup>+ ψ</sup> <sup>or Fπ</sup> <sup>:</sup> <sup>φ1</sup> <sup>= φ</sup> ′1 <sup>+ ψ + π.</sup> <sup>In</sup> <sup>reverse execution,</sup> <sup>the</sup> ψ, is computed as either <sup>pre-collision angle φ</sup> ′1 isF recovered: φ1 = φ′1 <sup>+</sup> as <sup>ψ</sup> R <sup>or</sup> : <sup>F</sup> φ′1 <sup>π</sup> <sup>=:</sup> <sup>φ φ11=− φψ</sup> ′1 <sup>+or ψR +π π:.</sup> <sup>φIn</sup> ′1 <sup>=reverse execution, φ1</sup> <sup>−</sup> <sup>ψ −</sup> <sup>π.</sup> <sup>If</sup> <sup>thethefactpre-collision anglethat</sup> <sup>π</sup> <sup>was</sup> <sup>added φ</sup> ′1 is recovered as R : φ′1 <sup>= φ1</sup> <sup>−</sup> <sup>ψ</sup> <sup>or</sup> <sup>Rπ</sup> <sup>:</sup> <sup>φ</sup> ′1 <sup>= φ1</sup> <sup>−</sup> <sup>ψ −</sup> <sup>π.</sup> <sup>If</sup> <sup>the</sup> <sup>fact</sup> <sup>that</sup> <sup>π</sup> <sup>was</sup> <sup>added</sup> by the forward execution is somehow remembered (i.e., whether F or Fπ was applied), then the correct pre-collision angle can be recovered during reversal (by applying R or Rπ respectively). 9 Our key observation here is that it is possible to avoid having to “remember” whether the π offset was added or not. If π was added in forward execution, then, in reverse execution, the fact that ψ + π must be used, as opposed to ψ, can be detected by a violation of the geometry constraint on the pre-collision velocities ifcorrect value of φ′1 <sup>= φ1</sup> <sup>−</sup> <sup>ψ −</sup> <sup>π</sup> <sup>is</sup> <sup>thus</sup> <sup>possible</sup> <sup>to</sup> <sup>be</sup> <sup>recovered</sup> <sup>correctly.</sup> π is not added. The To adopt this approach, it is necessary and sufficient to show that no ambiguity exists during the reverse execution regarding which of F or Fπ was executed in the forward execution, so that the correct operation, R or Rπ, is applied for correct reversal. In other words, it is necessary and sufficient to satisfy the following conditions: - R(F (φ)) = φ - Rπ(F (φ))̸ = φ - Rπ(Fπ(φ)) = φ - R(Fπ(φ))̸ = φ - F (φ)̸ = Fπ(φ)) - R(φ)̸ = Rπ(φ)). These conditions can be proven as follows. Let CS(φ) = r21x - (2R cos φ) + r21y (2R sin φ). We know that F and Fπ are exclusive with respect to satisfaction of EquaSimilarly,tion (8) withR andφ1, Ri.e.π,′areF exclusivesatisfies CSwith(φ1respect) - 0, iftoandsatisfactiononly if′ Fofπ Equationsatisfies CS(8)(φwith1) <φ0.′1 <sup>,</sup> i.e.Similarly,, R satisfiesR andCSR(πφ′1are <sup>) <</sup> exclusive <sup>0,</sup> <sup>if</sup> <sup>and</sup> with <sup>only</sup> respect <sup>if</sup> <sup>Rπ</sup> <sup>satisfies</sup> to satisfaction <sup>CS(φ</sup> ′1 <sup>) ></sup> of <sup>0.</sup> Equation (8) with φ′1 <sup>,</sup> i.e., R satisfies CS(φ′1 <sup>) < 0,</sup> <sup>if</sup> <sup>and</sup> <sup>only</sup> <sup>if</sup> <sup>Rπ</sup> <sup>satisfies</sup> <sup>CS(φ</sup> ′1 <sup>) > 0.</sup> 0 andThe geometrical constraints require that the post-collision velocities satisfythe pre-collision velocities satisfy CS(φ′1 <sup>) < 0.</sup> <sup>These</sup> <sup>requirements</sup> <sup>are</sup> CS <sup>satisfied</sup> (φ1) > <sup>if</sup> R is used to reverse F, or Rπ is used to reverse Fπ, respectively. In other words, from Equation (11), we know that: ′1 <sup>) <</sup> ′ <sup>0</sup> <sup>in</sup> <sup>reverse,</sup> <sup>and</sup> - if F satisfies CS(φ1) > 0 in forward, then R satisfies CS(φ - if Fπ satisfies CS(φ1) > 0 in forward, then Rπ satisfies CS(φ1 <sup>) < 0</sup> <sup>in</sup> <sup>reverse.</sup> Finally, the ambiguity is fully resolved when the following′′1 <sup>) < 0.</sup> are also satisfied: - If F satisfies CS(φ1) > 0, then Rπ violates CS(φ - If Fπ satisfies CS(φ1) > 0, then R violates CS(φ1 <sup>) < 0.</sup> lines:TheSinceformerCS(canφ′1 <sup>)</sup> be <sup><</sup> <sup>0</sup> proved <sup>(pre-collision),</sup> as follows, <sup>and</sup> and <sup>F</sup> the <sup>gives</sup> latter <sup>CS(</sup> can <sup>φ1)</sup> <sup>></sup> be <sup>0</sup> proved <sup>(post-collision),</sup> along similar <sup>Rπ</sup> lines: ′ Since CS(φ′′1 <sup>)</sup> <sup><</sup> <sup>0</sup> <sup>(pre-collision),</sup> ′ <sup>and</sup> <sup>F</sup> <sup>gives</sup> <sup>CS</sup> ′ <sup>(φ1)</sup> <sup>></sup> <sup>0</sup> <sup>(post-collision),</sup> ′1 <sup>).</sup> <sup>This</sup> <sup>impliesRπ</sup> gives CS(φ1 − ψ − π) = CS(φ1 <sup>+ ψ −</sup> <sup>ψ −</sup> <sup>π)</sup> <sup>=</sup> <sup>CS(φ</sup> 1 <sup>−</sup> <sup>π)</sup> <sup>=</sup> <sup>−CS(φ</sup> CS(φ ′ ′ ′ ′ ′1 <sup>).</sup> <sup>This</sup> <sup>implies</sup> gives CS(φ1 − ψ − π) = CS(φ1 <sup>+ ψ −</sup> <sup>ψ −</sup> <sup>π)</sup> <sup>=</sup> <sup>CS(φ</sup> 1 <sup>−</sup> <sup>π)</sup> <sup>=</sup> <sup>−CS(φ</sup> CS(φ1 <sup>) = −CS(φ</sup> 1 <sup>),</sup> <sup>which</sup> <sup>is</sup> <sup>a</sup> <sup>contradiction.</sup> CS(φ′1 <sup>) = −CS(φ</sup> ′1 <sup>),</sup> <sup>which</sup> <sup>is</sup> <sup>a</sup> <sup>contradiction.</sup> The forward and reverse algorithms are given in Procedure 1 and Procedure 2 respectively. This completes the generation of reversible random offsets for all configurations of 2-particle collisions in 2 dimensions, ensuring full phase space coverage with zero memory overhead. ′1 <sup>−→</sup> <sup>φ1):</sup> <sup>Forward</sup> <sup>Function</sup> <sup>for</sup> <sup>2-Particle</sup> <sup>in</sup> <sup>2</sup> <sup>Dimensions</sup> Procedure 1 (φ ′ 1: ψ ← 2Gπ {generate a random offset from [0, 2π)} 2: φ1 ← (φ1 <sup>+ ψ)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{post-collision</sup> <sup>is</sup> <sup>pre-collision</sup> <sup>offset</sup> <sup>by</sup> <sup>randomized</sup> <sup>ψ}</sup> 3: {Next, if post-collision is converging, correct it to be diverging} 4:5:6: ifendφr211 if←x · cos(φ1 φ +1 π +) r21mody - sin2π φ1 < 0 then 6: end if 10 ′1 <sup>):</sup> <sup>Reverse</sup> <sup>Function</sup> <sup>for</sup> <sup>2-Particle</sup> <sup>in</sup> <sup>2</sup> <sup>Dimensions</sup> Procedure 2 (φ1 −→ φ ′ 1: ψ ← 2Gπ {recover the random offset} 2: φ1 <sup>←</sup> <sup>(φ1 −</sup> <sup>ψ)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{initial</sup> <sup>guess</sup> <sup>at</sup> <sup>pre-collision</sup> <sup>angle}</sup> 3: {Next, if pre-collision is diverging, correct it to be converging} ′ ′ 4: if r21x · cos φ1 + r21y - sin φ1 - 0 then φ ′ ′ 5:6: endφ1 if <sup>←</sup> <sup>(φ</sup> 1 <sup>−</sup> <sup>π)</sup> <sup>mod</sup> <sup>2π</sup> 5: φ 4.3 Reversal for 2-Particle Collisions in 3 Dimensions In a collision of 2 particles in 3-dimensional space, the equations of motion and postcollision geometry are: a + b = α, c + d = β, e + f = γ a <sup>2</sup> + b <sup>2</sup> + c <sup>2</sup> + d <sup>2</sup> + e <sup>2</sup> + f <sup>2</sup> = δ, and 2δ - α <sup>2</sup> + β <sup>2</sup> + γ <sup>2</sup> Dynamics, (12) r21x · (a − b) + r21y - (c − d) + r21z - (e − f ) > 0 for some r21x, r21y, r21z - 0 Geometry. (13) The pre-collision geometrical constraints are obtained by replacing > 0 by < 0 in the post-collision constraints. The equations of motion imply that: �e − <sup>γ</sup> 2 + �2 �c − <sup>β</sup> 2 �a − <sup>α</sup> 2 2 + �2 2 = <sup>2δ −</sup> <sup>(α2 + β2 + γ2)</sup> 4 �2 <sup>β2 + γ2)</sup> = R <sup>2</sup>, (14) 4 i.e., the point (a, c, e) lies on a sphere of radius R = 2 <sup>1</sup> 2δ − (α <sup>2</sup> + β <sup>2</sup> + γ <sup>2</sup> ) centered at ( <sup>α</sup> 2 <sup>,</sup> <sup>β</sup> 2 <sup>,</sup> <sup>γ</sup> 2 <sup>).</sup> <sup>whose</sup> <sup>parametric</sup> <sup>equations</sup> <sup>are</sup> <sup>given</sup> <sup>by:</sup> i.e., the point (a, c, e) lies on a sphere of radius R = 2 <sup>1</sup> <sup>α</sup> 2 <sup>,</sup> <sup>β</sup> 2 <sup>,</sup> <sup>γ</sup> 2 <sup>).</sup> <sup>whose</sup> <sup>parametric</sup> <sup>equations</sup> <sup>are</sup> <sup>given</sup> <sup>by:</sup> a = <sup>α</sup> 2 <sup>+ R sin φ1 sin φ2,</sup> <sup>c =</sup> <sup>β</sup> 2 <sup>+ R sin φ1 cos φ2,</sup> <sup>e =</sup> <sup>γ</sup> 2 <sup>+ R cos φ1,</sup> (15) φ1 ∈ [0, π], and φ2 ∈ [0, 2π) . Equation (15) provides the V -to-Φ and Φ-to-V mapping functions for 2-particle collisions in 3 dimensions. In thatIn determiningcase, we chooseΦ′ fromtoVset, ifφφ21 == 0.0 orSettingφ1 = πφ, 2then,thus,thewithoutvalue ofregardφ2 is toimmaterial.φ′2 <sup>,</sup> <sup>loses</sup> φ1 ∈ [0, π], and φ2 ∈ [0, 2π) . Ininformationthat case,aboutwe chooseφ′2 <sup>when</sup> to set <sup>φ1</sup> φ <sup>=</sup> 2 <sup>0.</sup> = <sup>To</sup> 0. <sup>deal</sup> Setting <sup>with</sup> φ2 <sup>this</sup> thus, <sup>rare</sup> without <sup>special</sup> regard <sup>case,</sup> <sup>the</sup> to φ <sup>value</sup> ′2 <sup>,</sup> <sup>losesof</sup> φinformation′2 <sup>can</sup> <sup>be</sup> <sup>logged</sup> about <sup>in</sup> φ′2 <sup>thewhenforwardφ1</sup> <sup>=collision,0.</sup> <sup>To</sup> <sup>dealandwithrestoredthis</sup> <sup>rarefromspecialthe</sup> <sup>logcase,in</sup> <sup>thethebackwardvalue</sup> <sup>of</sup> φ′2 <sup>can</sup> <sup>be</sup> <sup>logged</sup> <sup>in</sup> <sup>the</sup> <sup>forward</sup> <sup>collision,</sup> <sup>and</sup> <sup>restored</sup> <sup>from</sup> <sup>the</sup> <sup>log</sup> <sup>in</sup> <sup>the</sup> <sup>backward</sup> collision.collision. NoteIn thethatreversethis execution,is logged inφforward execution′2 <sup>is</sup> <sup>recovered</sup> <sup>from</sup> only <sup>the</sup> <sup>log</sup> if φ1 <sup>only</sup> = 0, <sup>if</sup> and <sup>φ1</sup> <sup>= 0.</sup> not for every collision. In the reverse execution, φ′2 <sup>is</sup> <sup>recovered</sup> <sup>from</sup> <sup>the</sup> <sup>log</sup> <sup>only</sup> <sup>if</sup> <sup>φ1</sup> <sup>= 0.</sup> For the G-to-Ψ mapping, the offsets ψ1 and ψ2 are obtained by uniformly sampling the surface of a unit sphere. Any algorithm for this purpose can be employed (e.g., [Mar72]), using two random numbers G1 ∈ [0, 1] and G2 ∈ [0, 1). φ1 = (Similar to the 2-dimensional 2-particle case, the post-collision angles are computed asφ′1 <sup>+ψ1)</sup> <sup>mod</sup> <sup>2π or φ1</sup> <sup>= (φ</sup> ′1 <sup>+ψ1+π)</sup> <sup>mod</sup> <sup>2π, and φ2</sup> <sup>= (φ</sup> ′2 <sup>+ψ2)</sup> <sup>mod</sup> <sup>2π.</sup> <sup>The</sup> φ1 = (φ′1 <sup>+ψ1)</sup> <sup>mod</sup> <sup>2π or φ1</sup> <sup>= (φ</sup> ′1 <sup>+ψ1+π)</sup> <sup>mod</sup> <sup>2π, and φ2</sup> <sup>= (φ</sup> ′2 <sup>+ψ2)</sup> <sup>mod</sup> <sup>2π.</sup> <sup>The</sup> choice of whether π is added to ψ is determined by the one that satisfies the geometrical condition given by Equation (13). The proof of reversibility of the computation of φ1 is analogous to the one in the preceding sub-section. 11 This completes the generation of reversible random offsets for all configurations of 2-particle collisions in three dimensions, ensuring full phase space coverage with zero memory overhead. 4.4 Reversal for 3-Particle Collisions in 1 Dimension In this section, we determine the phase space of the permissible reversible random offsets that needs to be sampled for 3-particle collisions in 1 dimension. 4.4.1 Solving the Equations of Motion The equations of motion are: a + b + c = α a <sup>2</sup> + b <sup>2</sup> + c <sup>2</sup> = δ, 3δ - α <sup>2</sup> Dynamics. (16) The post-collision geometrical constraints are given by:   Only two of these three need be satisfied for any given geometric   r21 · (a − b) > 0, r32 · (b − c) > 0, r13 · (c − a) > 0    Geometry. (17) configuration r21, r32, r13 - 0 In Equation (17), when any two inequalities are satisfied, the third one is resulting. This is because the two inequalities that are satisfied imply a specific ordering of the three particles along the single dimension, which in turn automatically satisfies the remaining third constraint. The pre-collision geometrical constraints are obtained by replacing - 0 by < 0 in the post-collision constraints. The solution to the equations of motion satisfies: 2 √     <sup>b</sup>, and <sup>¯</sup> b = <sup>a + b</sup> 2 √2 <sup>b</sup>, (18) 2 a¯ <sup>2</sup> +     = δ − <sup>α</sup> 3 <sup>2</sup> = <sup>a −</sup> <sup>b</sup> 3 <sup>2</sup> <sup>,</sup> <sup>where</sup> <sup>a¯</sup> √2 ¯b − √32 <sup>α</sup> 1 √3 3 which leads to the parametrization: 2√ δ − <sup>α</sup> 3 <sup>2</sup> 3 <sup>2</sup> <sup>,</sup> <sup>and</sup> <sup>φ1</sup> ∈ [0, 2π). <sup>(19)</sup> a¯ = √ <sup>λ</sup> 2 cos φ1, <sup>¯</sup> b = √ 2 λ 3 <sup>α +</sup> √2√ sin φ1, λ = 3 √2 √ Converting to a, b and c, we get: <sup>α</sup> 3 <sup>+</sup> <sup>λ</sup> 2 <sup>(cos φ1 +</sup> √ <sup>1</sup> 3 <sup>sin φ1),</sup> a = <sup>α</sup> 3 3 <sup>sin φ1),</sup> <sup>b =</sup> <sup>α</sup> 3 <sup>+</sup> <sup>λ</sup> 2 <sup>(−</sup> <sup>cos φ1 +</sup> √ <sup>1</sup> (20) <sup>α</sup> 3 <sup>2</sup> <sup>,</sup> <sup>and</sup> <sup>φ1</sup> <sup>∈</sup> <sup>[0, 2π).</sup> c = <sup>α</sup> 3 sin φ1), λ = 3 <sup>α</sup> 3 <sup>+</sup> <sup>λ</sup> 2 <sup>(−</sup> √ <sup>2</sup> δ − <sup>α</sup> 3 <sup>2</sup> √ 2 Equation (20) provides the V -to-Φ and Φ-to-V mapping functions for 1-dimensional 3-particle collisions. 12 4.4.2 Sampling the Ψ Phase Space Analogously to the 2-particle 2-dimensional case, the phase space of the post-collision ′ angle is sampled by generating a random φ1 as a random offset ψ1 ∈ [0, 2π) from the pre-collision angle φ1 <sup>.</sup> <sup>The</sup> <sup>mapping</sup> <sup>function</sup> <sup>from a uniform</sup> <sup>random number</sup> <sup>G ∈</sup> <sup>[0, 1)</sup> to ψ1 is more complex than that for the 2-particle case. In the 2-particle case, the phase space for velocities lies on the circumference of a circle, which can be sampled simply by uniformly sampling the angle subtended at the center. However, the phase space of the velocities in the 3-particle case lies on the circumference of an ellipse, which cannot be sampled simply as ψ1 = 2Gπ. Instead, any correctly unbiased procedure for generating the angle by sampling the circumference of an ellipse can be employed for the purpose of defining the G-to-Ψ mapping function. One such method is described in the next section. 4.4.3 Sampling the Circumference of the Ellipse Here, we present a new procedure for uniformly sampling a point from the perimeter of an ellipse. The procedure is designed to be suitable for use in reversible execution, requiring exactly one random number per sample. While rejection-based procedures exist for this problem, they cannot be used here due to their irreversibility, as explained later in Section 4.6. #### _dx_ #### _r_ _dy_ #### _ψ_ Figure 3: Sampling scheme for a uniformly selected random point on an ellipse y dy ψ, = 1 shown in Figure 3. Let L : ψ → ℓ be �2 0 ≤ ψ < 2π, to the length ℓ of the arc moving + �2 Consider the ellipse x dx a function that maps any angle <sup>1</sup> ψ, 0 ≤ ψ < 2π, to the length ℓ of the arc moving counter-clockwise along the circumference of the ellipse from (dx, 0) to (r cos ψ, r sin ψ), where r <sup>2</sup> = d <sup>2</sup> x <sup>d2</sup> y <sup>/(d2</sup> y <sup>cos ψ2 + d2</sup> x <sup>sin ψ2).</sup> <sup>Let</sup> <sup>L−1</sup> <sup>:</sup> <sup>ℓ</sup> <sup>→</sup> <sup>ψ</sup> <sup>be</sup> <sup>the</sup> <sup>inverse</sup> <sup>function</sup> <sup>that</sup> where r <sup>2</sup> = d <sup>2</sup> x <sup>d2</sup> y <sup>/(d2</sup> y <sup>cos ψ2 + d2</sup> x <sup>sin ψ2).</sup> <sup>Let</sup> <sup>L−1</sup> <sup>:</sup> <sup>ℓ</sup> <sup>→</sup> <sup>ψ</sup> <sup>be</sup> <sup>the</sup> <sup>inverse</sup> <sup>function</sup> <sup>that</sup> determines the angle corresponding to any given arc length ℓ. Thus, L <sup>−1</sup> (L(ψ)) = ψ. A random point on the circumference of the ellipse can be obtained as the end of the arc whose length is G · L(2π), and the angle corresponding to that point can be obtained as ψ1 = L <sup>−1</sup> (G · L(2π)), which serves as the G-to-Ψ mapping for the 3-particle collisions in 1 dimension. The value of L(2π) is computable by different methods. For example, L(2π) = π(dx+ n=0 n (dx+dy) <sup>2, which can be computed to any desired precision.</sup> The value of L <sup>−1</sup> (ℓgiven) can be obtained by a bisection method (binary search) that starts withdy) <sup>�∞</sup> �0the.5�2lowerboundhn, where h ψ =lower(dx−= 0dy)2 upperbound ψupper = 2π, and an initial estimate <sup>2</sup> x <sup>d2</sup> y <sup>2</sup> y <sup>/(d2</sup> y <sup>2</sup> y <sup>cos ψ2 + d2</sup> x n=0 n (dx+dy) <sup>2, which can be computed to any desired precision.</sup> The value of L <sup>−1</sup> (ℓgiven) can be obtained by a bisection method (binary search) that starts withdy) <sup>�∞</sup> �0the.5�2lowerboundhn, where h ψ =lower(dx−= 0dy)2 upperbound ψupper = 2π, and an initial estimate value of ψguess = π, and repeatedly adjusts the lowerbound or upperbound to the guess 1We will use the terms angle and parameter interchangeably, with the understanding that the angle is in fact the parameter in the representation of the point on the ellipse, and not the geometrical angle. 13 n=0 n of �0.5 (dx+dy) <sup>2</sup> L <sup>−1</sup> (ℓgiven) can be �2hn, where h = (dx−dy)2 value (depending on whether L(ψguess) < ℓgiven or ℓgiven < L(ψguess) respectively), until the correct angle corresponding to ℓgiven is determined. onlyFordependthe ellipseon δ andin Equationα, the value(18),of ψd1x can= �beδ −generated <sup>α</sup> 3 <sup>2</sup> and anddy =recovered√dx3 <sup>.</sup> Since(re-generated)dx and dy independently of individual particle velocities. Note that the computational burden in sampling the ellipse occurs both in logbased approaches and in our approach. Thus, the forward portions incur the same computational cost. However, we use the same computational procedure on the reverse path, to re-generate the sample and use it in the reverse procedure. Since log-based approaches rely on memory, they do not incur computational cost on the reverse path, but incur extra memory copying cost in forward execution. In a normal, well-balanced parallel execution, since reversals of collisions are far fewer than forward collisions, the extra computational cost of our approach in the reverse procedure is much less than the savings gained in foward execution compared to log-based approaches, resulting in an overall reduction in run time and memory. 4.4.4 Resolving the Geometrical Constraints collisionNote that,anglewithφ′1the <sup>,</sup> <sup>from</sup> sampled <sup>which</sup> φ <sup>the</sup> 1 = <sup>values</sup> φ′1 <sup>+ ψof</sup> <sup>,theit</sup> <sup>ispre-collisionpossible</sup> <sup>tovelocitiescorrectlycanrecoverbe</sup> <sup>recovered,the</sup> <sup>pre-</sup> For the ellipse in Equation (18), dx = 3 �beδ − <sup>α2</sup> 3 <sup>2</sup> and dy = √dx3 Note that, with the sampled φ1 = φ collision angle φ′1 <sup>,</sup> <sup>from</sup> <sup>which</sup> <sup>the</sup> <sup>values</sup> <sup>of</sup> <sup>the</sup> <sup>pre-collision</sup> <sup>velocities</sup> <sup>can</sup> <sup>be</sup> <sup>recovered,</sup> but not necessarily their correct assignation to the identities of the particles. Thus, there still remains the problem of uniquely recovering the configuration of the particles, since the preceding solution provides for two different but equivalent configurations that only differ in that their left and right particle identities are swapped. Without modifying the procedure, one additional bit of memory would be needed for each collision to disambiguate between the two configurations. Since the aim is to completely eliminate memory accumulation, the model needs additional development for reversibility, as presented next. Equation (20) gives the key terms in the geometrical constraints as: (a − b) = λ cos φ1, (b − c) = λ cos (φ1 − <sup>2</sup> 3 <sup>π</sup> <sup>),</sup> <sup>and</sup> <sup>(c −</sup> <sup>a) = λ cos (φ1 +</sup> <sup>2</sup> 3 <sup>π</sup> <sup>).</sup> (21) Equation (21) indicates the permissible phase space of φ1 with the property that we exploit here for reversibility, namely, that the three terms cos φ, cos(φ − <sup>2</sup> 3 <sup>π</sup> <sup>),</sup> <sup>and</sup> cos(φ + <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>never</sup> <sup>carry</sup> <sup>the</sup> <sup>same</sup> <sup>sign,</sup> <sup>i.e.,</sup> <sup>if</sup> <sup>one</sup> <sup>is</sup> <sup>negative,</sup> <sup>the</sup> <sup>other</sup> <sup>two</sup> <sup>are</sup> <sup>non-</sup> negative, and if one is positive, the other two are non-positive (see Figure 4). From Equation (21), we deduce: (22) cos φ1 + cos (φ1 − <sup>2</sup> 3 <sup>π</sup> <sup>) + cos (φ1 +</sup> <sup>2</sup> 3 <sup>π</sup> <sup>) = 0,</sup> <sup>since</sup> <sup>λ > 0.</sup> Without loss of generality, let a′, b′, and c′ represent the pre-collision velocities of the left, center and right particles, respectively, colliding along the one-dimensional path. Thisand cis, respectively.illustrated inDefineFigurea5.canonicalLet the assignationcorrespondingof φpost-collision′1 <sup>such</sup> <sup>that</sup> <sup>a</sup> velocities′ = Rbe cosa φ, ′1b <sup>,</sup>, ′ - b Without loss of generality, let a ′, b ′, and c ′ = R cos φ and c, respectively.′ Define a canonical assignation′ of φ′1 <sup>such</sup> <sup>that</sup> <sup>a</sup> ′ = R cos φ′1 <sup>,</sup> ′ - b b ′ = R cos (φ 3 <sup>),</sup> <sup>and</sup> <sup>c</sup> ′ = R cos (φ1 <sup>+</sup> <sup>2</sup> 3 <sup>π</sup> <sup>).</sup> <sup>Note</sup> <sup>that</sup> <sup>this</sup> <sup>convention</sup> <sup>fully</sup> ′ − c 1 <sup>−</sup> <sup>2π</sup> ′ - a ′ − c ′ = R cos (φ ′ 3 <sup>),</sup> <sup>and</sup> <sup>c</sup> 1space <sup>−</sup> <sup>2π</sup> of all ′ - a ′ = R cos (φ ′1 <sup>such</sup> <sup>that</sup> <sup>a</sup> ′ - b b ′ = R cos (φ′ 3 <sup>),</sup> <sup>and</sup> <sup>c</sup> ′ = R cos (φ′1 <sup>+</sup> <sup>2</sup> 3 <sup>π</sup> <sup>).</sup> <sup>Note</sup> <sup>that</sup> <sup>this</sup> <sup>convention</sup> <sup>fully</sup> covers′ − c the phase 1space <sup>−</sup> <sup>2π</sup> of all pre-collision′ - a velocities for the given total momentum and kinetic energy, and in that sense, is general and equivalent to any other valid convention. 14 - 0 0 < 0 0 π6 π2 56π π 76π 96π 116π 2π cos(φ) cos(φ − <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> cos(φ + <sup>2π</sup> cos(φ − <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> cos(φ + <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> 3 <sup>π</sup> <sup>)</sup> Figure 4: Variation of the geometrical terms with φ1 in 3-particle collisions in 1 dimension ′ b ′ a ′ c′ Figure 5: Canonical configuration of 3 particles in 1 dimension Pre-collision: For the left and center particles to collide, a′ - b′ - 0. Similarly, for the center and right particles to collide, b′ − c′ - 0. These two conditions constrain the Pre-collision: For the left and center particles to collide, a ′ - b the center ′and right particles to collide, b ′ - 0. These′ two conditions′ constrain′ the ′ − c range of φ1 <sup>to</sup> <sup>[ π</sup> 6 <sup>,</sup> <sup>π</sup> 2 <sup>),</sup> <sup>since</sup> <sup>it</sup> <sup>is</sup> <sup>only</sup> <sup>for</sup> <sup>that</sup> <sup>range</sup> <sup>of</sup> <sup>φ</sup> 1 <sup>that</sup> <sup>cos φ</sup> 1 <sup>and</sup> <sup>cos (φ</sup> 1 <sup>−</sup> <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> ′ − c range of φ′1 <sup>to</sup> <sup>[ π</sup> 6 <sup>,</sup> <sup>π</sup> 2 <sup>),</sup> <sup>since</sup> <sup>it</sup> <sup>is</sup> <sup>only</sup> <sup>for</sup> <sup>that</sup> <sup>range</sup> ′ <sup>of</sup> <sup>φ</sup> ′1 <sup>that</sup> <sup>cos φ</sup> ′1 <sup>and</sup> <sup>cos (φ</sup> ′ 3 <sup>)</sup> 1 <sup>−</sup> <sup>2π</sup> are both non-negative. The exact value of φ1 <sup>in</sup> <sup>that</sup> <sup>range</sup> <sup>is</sup> <sup>determined</sup> <sup>from</sup> <sup>the</sup> are both non-negative. The exact value of φ′1 <sup>in</sup> <sup>that</sup> <sup>range</sup> <sup>is</sup> <sup>determined</sup> <sup>from</sup> <sup>the</sup> following: ′ 32 <sup>α</sup> a¯ √ ′1 <sup>=</sup> ′ ′ - b √ ′ ′ - b √2 b, <sup>¯</sup> b 2 ′ = a ′ ′ + b ′ ′ + b √2 , and tan φ 2 √ 3 �¯b a¯ ′ = a (23) ′ . particlesThus,cananybepre-collision configuration of (uniquely and completely representeda′, b′, c′ ) velocitiesby (φ′1 <sup>,</sup> <sup>α,</sup> of left, <sup>δ),</sup> <sup>where</sup> center, <sup>π</sup> and′1 <sup><</sup> right <sup>π</sup> 2 <sup>.</sup> ′, b ′, c Thus, any pre-collision configuration of (a′ particlesPost-collisioncan be uniquely: For the left and center particles to diverge after collision (i.e., not toand completely represented by (φ′1 <sup>,</sup> <sup>α,</sup> <sup>δ),</sup> <sup>where</sup> <sup>π</sup> 6 <sup>≤</sup> <sup>φ</sup> ′1 <sup><</sup> <sup>π</sup> 2 <sup>.</sup> pass through each other), their post-collision velocities must satisfy a - b < 0. Similarly, ′ for the center and right particles, b − c < 0. These two conditions constrain the range of φ1 to [ <sup>7</sup> 6 <sup>π</sup> <sup>,</sup> <sup>3</sup> 2 <sup>π</sup> <sup>),</sup> <sup>which</sup> <sup>is</sup> <sup>essentially</sup> <sup>offset</sup> <sup>by</sup> <sup>+π</sup> <sup>from</sup> <sup>the</sup> <sup>range</sup> <sup>of</sup> <sup>φ</sup> 1 <sup>.</sup> of φ1 to [ <sup>7</sup> 6 <sup>π</sup> <sup>,</sup> <sup>3</sup> 2 <sup>π</sup> <sup>),</sup> <sup>which</sup> <sup>is</sup> <sup>essentially</sup> <sup>offset</sup> <sup>by</sup> <sup>+π</sup> <sup>from</sup> <sup>the</sup> <sup>range</sup> <sup>of</sup> <sup>φ</sup> ′1 <sup>.</sup> Pictorially, the regions of interest in the [0, 2π) range are given in Figure 6. The full [0collision).π6 <sup>.</sup>, 2 <sup>In</sup> π) <sup>the</sup> range <sup>figure,</sup> Anyis givendivided <sup>R1</sup> <sup>is</sup> angle <sup>the</sup> into <sup>range</sup> φ′1six <sup>in</sup> regions, <sup>Rof1φcorresponds</sup> ′1 <sup>(pre-collision),</sup> each spanning <sup>to</sup> <sup>a</sup> <sup>setand2</sup> 3 <sup>πofS.</sup> <sup>1threeTheis</sup> <sup>thefirstvelocitiesrangeregionof{aφstarts</sup> ′ <sup>1</sup>, b <sup>(post-</sup> ′, c′ <sup>at</sup> }, collision). Any given angle φ′1 <sup>in</sup> <sup>R1</sup> <sup>corresponds</sup> <sup>to</sup> <sup>a</sup> <sup>set</sup> <sup>of</sup> <sup>three</sup> <sup>velocities</sup> <sup>{a</sup> ′, b′, c′}, such that the pre-collision geometrical constraints of Equation (17) are satisfied, implying a specifically ordered sequence of the particles, say, a; b; c, along one dimension. The bregions; c; a, obtained by offsettingR2 and R3 correspond φ′1 <sup>by +</sup> to left-rotation <sup>2</sup> 3 <sup>π</sup> <sup>and −</sup> <sup>2</sup> 3 <sup>π</sup> of <sup>, respectively.</sup> the R1 sequence, <sup>Similarly, the regions</sup> namely, c; a; b and <sup>S2</sup> ′1 <sup>in</sup> <sup>R1</sup> <sup>corresponds</sup> <sup>to</sup> <sup>a</sup> <sup>set</sup> <sup>of</sup> <sup>three</sup> <sup>velocities</sup> <sup>{a</sup> ′, b ′, c b; c; a, obtained by offsetting φ′1 <sup>by + 2</sup> 3 <sup>π</sup> <sup>and −</sup> <sup>2</sup> 3 <sup>π</sup> <sup>, respectively.</sup> <sup>Similarly, the regions S2</sup> and S3 correspond to the right-rotation of the S1 sequence. Note that the pre-collision 15 and post-collision angles only fall in the R1 and S1 regions, respectively, and the other regions are unreachable by the system. They are defined and used in intermediate calculations when computing post-collision angles in forward execution (and recovering pre-collision angles in reverse) while ensuring full phase space coverage. –2 5̟–6 7̟–6 –6̟ 11̟ –6 3̟–2 Figure 6: Division of the angular space for φ1 and φ′1 <sup>in</sup> <sup>3-particle collisions in</sup> <sup>1</sup> <sup>dimen-</sup> sion Reversible Sampling: The problem of making the collision reversible now becomes φequivalentlying′1 <sup>∈</sup> <sup>[</sup> distribution <sup>π</sup> 6 <sup>,</sup> <sup>π</sup> 2 <sup>) to</sup> to defining <sup>a</sup> <sup>random sample</sup> of velocitiesa reversiblealong <sup>of φ</sup> (i.e., <sup>1</sup> the <sup>∈</sup> <sup>[</sup> one-to-one <sup>7</sup> circumference6 <sup>π</sup> <sup>,</sup> <sup>3</sup> 2 <sup>π</sup> <sup>),</sup> <sup>while</sup> and <sup>accurately preserving the</sup> ofonto)the mappingellipse in fromEquationany <sup>under-</sup> given(18). In general, any such bijection could serve the purpose. Here, such a mapping function is providedThe forwardin Procedurefunction 3essentially(forward) rotatesand Procedureφ′1 <sup>uniformly</sup> 4 (reverse). <sup>over</sup> <sup>the</sup> <sup>entire</sup> <sup>range</sup> <sup>[0, 2π)</sup> first, and then makes adjustments reversibly, as needed, to map back to the valid range [ <sup>7</sup> 6 <sup>π</sup> <sup>,</sup> <sup>3</sup> 2 <sup>π</sup> <sup>)</sup> <sup>of</sup> <sup>φ1.</sup> The forward function essentially rotates φ 6 <sup>π</sup> <sup>,</sup> <sup>3</sup> 2 <sup>π</sup> <sup>)</sup> <sup>of</sup> <sup>φ1.</sup> ′1 <sup>−→</sup> <sup>φ1):</sup> <sup>Forward</sup> <sup>Function</sup> <sup>for</sup> <sup>3-Particle</sup> <sup>in</sup> <sup>1</sup> <sup>Dimension</sup> Procedure 3 (φ ℓ ← G · L(2π) {Pick a random arc length on ellipse} ψ1 ← L <sup>−1</sup> (ℓ) {Find angle corresponding to arc length} ′ {Compute post-collision angle} φ1 ← (φ1 <sup>+ ψ1)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{Step</sup> <sup>1}</sup> φ1 ← (φ′1 <sup>+ ψ1)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{Step</sup> <sup>1}</sup> {Adjust post-collision angle if/as necessary} if more than one of cos φ1, cos (φ1 − <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>and</sup> if more than one of cos φ1, cos (φ1 − <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>and</sup> <sup>cos (φ1 +</sup> <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>is</sup> <sup>positive</sup> <sup>then</sup> endφ1 if← (φ1 + π) mod 2π {Step 2} if cos φ1 is positive then φ1 ← (φ1 − <sup>2</sup> 3 <sup>π</sup> φ1 ← (φ1 − <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{Step</sup> <sup>3a}</sup> else if cos (φ1 − <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>is</sup> <sup>positive</sup> <sup>then</sup> endφ1 if← (φ1 + <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{Step</sup> <sup>3b}</sup> if cos (φ1 − <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>is</sup> <sup>positive</sup> <sup>then</sup> φ1 if← (φ1 + <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{Step</sup> <sup>3b</sup> offsetTheinoperation[0, 2π) to ofφ′1Procedure <sup>to</sup> <sup>get</sup> <sup>a</sup> <sup>candidate</sup> 3 is illustrated <sup>sample</sup> in <sup>of</sup> Equation <sup>φ1.</sup> <sup>Clearly,</sup> (24). <sup>the</sup> Step <sup>candidate</sup> 1 adds a <sup>may</sup> random <sup>fall</sup> in any of the six regions shown in Figure 6. The first correction is to detect if the 16 candidate angle maps to R1, R2, or R3, and if so, remap it to S1, S2, or S3 respectively (because post-collision velocities must diverge, which implies that the post-collision free angle cannot be in R1, R2, or R3). This is accomplished in Step 2 by adding π to the candidate. In Step 3, if the candidate happens to already be in S1, then no additional adjustments are needed. Otherwise, if it falls in S3, it is wrapped back to S1 by rotating it counter-clockwise by <sup>2</sup> 3 <sup>π</sup> <sup>(Step</sup> <sup>3a),</sup> <sup>and</sup> <sup>if</sup> <sup>it</sup> <sup>falls</sup> <sup>in</sup> <sup>S2,</sup> <sup>it</sup> <sup>is</sup> <sup>wrapped</sup> <sup>back</sup> <sup>to</sup> <sup>S1</sup> <sup>by</sup> rotating it clockwise by <sup>2</sup> 3 <sup>π</sup> <sup>(Step</sup> <sup>3b).</sup> <sup>To</sup> <sup>summarize:</sup> ′ Step 1 1 <sup>∈{R1}</sup> −−−−−−→randomize φ −−−−−−→randomize <sup>φ1</sup> <sup>∈{S1, S2, S3, R1, R2, R3}</sup> Step 2 - · · −−−−−→maps to <sup>φ1</sup> <sup>∈{S1, S2, S3}</sup> Step 3 −−−−−→maps to −−−−−→maps to <sup>φ1</sup> <sup>∈{S1}</sup> <sup>.</sup> (24) Step 2 −−−−−→maps to <sup>· · ·</sup> reconstructsThe reversea candidatefunction shownφ′1 <sup>.</sup> ItindetectsProcedureadjustments,4 uncoversif any,the randomthat wereoffsetmadefirst,duringand reconstructs a candidate φ′1 <sup>.</sup> It detects adjustments, if any, that were made during forward execution, and then performs the opposite of adjustments to recover the correctoriginal value of φ′1 <sup>.</sup> ′1 <sup>.</sup> ′1 <sup>):</sup> <sup>Reverse</sup> <sup>Function</sup> <sup>for</sup> <sup>3-Particle</sup> <sup>in</sup> <sup>1</sup> <sup>Dimension</sup> Procedure 4 (φ1 −→ φ ℓ ← G · L(2π) {Recover the random arc length on ellipse} ψ1 ← L <sup>−1</sup> (ℓ) {Recover the angle corresponding to arc length} ′ {Compute initial guess of pre-collision angle} φ1 <sup>←</sup> <sup>(φ1</sup> <sup>−</sup> <sup>ψ1)</sup> <sup>mod</sup> <sup>2π</sup> φ′1 <sup>←</sup> <sup>(φ1</sup> <sup>−</sup> <sup>ψ1)</sup> <sup>mod</sup> <sup>2π</sup> {Correct the guess if/as necessary} {Step 1} ′ ′ 3 <sup>)</sup> <sup>and</sup> if more than one of cos φ1, cos (φ1 − <sup>2π</sup> ′ ′ 3 <sup>)</sup> <sup>and</sup> <sup>cos (φ1 +</sup> <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>is</sup> <sup>positive</sup> <sup>then</sup> more than one of cos φ1, cos (φ1 − <sup>2π</sup> φ endφ′1 if <sup>←</sup> <sup>(φ</sup> ′1 <sup>−</sup> <sup>π)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{Step</sup> <sup>2}</sup> if cos φ′1 <sup>is</sup> <sup>negative</sup> <sup>then</sup> φcos′ φ′1 <sup>is</sup> ′1 <sup>negative−</sup> <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>modthen2</sup> φ′ ′ 1 <sup>←</sup> <sup>(φ</sup> 1 <sup>−</sup> ′ <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{Step</sup> <sup>3a}</sup> else′ if cos (′ φ 3 <sup>)</sup> <sup>is</sup> <sup>negative</sup> <sup>then</sup> 1 <sup>−</sup> <sup>2π</sup> endφ1 if <sup>←</sup> <sup>(φ</sup> 1 <sup>+</sup> <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{Step</sup> <sup>3b}</sup> ′ if cos (′ φ′ 3 <sup>)</sup> <sup>is</sup> <sup>negative</sup> <sup>then</sup> 1 <sup>−</sup> <sup>2π</sup> φ 1 <sup>+</sup> <sup>2</sup> 3 <sup>π</sup> <sup>)</sup> <sup>mod</sup> <sup>2π</sup> <sup>{Step</sup> <sup>3b</sup> randomThe operationoffset in [0of, 2Procedureπ) from φ14 tois illustratedget a first inguessEquationof the (25).originalStepφ′1 <sup>.</sup> 1 removes <sup>Clearly,</sup> <sup>the</sup> the random offset in [0, 2π) from φ1 to get a first guess of the original φ′1 <sup>.</sup> <sup>Clearly,</sup> <sup>the</sup> guessed value may fall in any of the six regions shown in Figure 6. The first correction to the guess is to detect if the candidate angle maps to S1, S2, or S3, and if so, remap it to R1, R2, or R3 respectively (because pre-collision velocities must be converging, which implies that the pre-collision free angle cannot be in S1, S2, or S3). This is accomplished alreadyin Step 2bebyinsubtractingR1, then it πalreadyfrom therepresentguessedthevalue.correctIn originalStep 3, ifvaluethe ofguessφ′1 <sup>.</sup> happens <sup>Otherwise,</sup> to already be in R1, then it already represent the correct original value of φ′1 <sup>.</sup> <sup>Otherwise,</sup> if it falls in R2, it is wrapped back to R1 by rotating it clockwise by <sup>2</sup> 3 <sup>π</sup> <sup>(Step</sup> <sup>3a), and</sup> <sup>if</sup> it falls in R3, it is wrapped forward to R1 by rotating it counter-clockwise by <sup>2</sup> 3 <sup>π</sup> <sup>(Step</sup> 3b). To summarize: ′ Step 3 1 <sup>∈{R1}</sup> ←−−−−−maps to ′ Step 2 1 <sup>∈{R1, R2, R3}</sup> ←−−−−−maps to φ ←−−−−−maps to <sup>φ</sup> Step 2 - · · ←−−−−−maps to ′ Step 1 1 <sup>∈{S1, S2, S3, R1, R2, R3}</sup> ←−−−−−−−−de-randomize ←−−−−−maps to <sup>· · ·</sup> ←−−−−−maps to <sup>φ</sup> ←−−−−−−−−de-randomize <sup>φ1</sup> <sup>∈{S1}</sup> <sup>.</sup> (25) 17 4.4.5 Combining Dynamics and Geometry The series of transformations performed in forward and reverse collision operations is summarized in Equation (26), which shows the input of the three pre-collision velocities φ(a′1 <sup>′,</sup>, b <sup>momentum′</sup>, c <sup>′</sup> ) being transformed by the <sup>α,</sup> <sup>and</sup> <sup>energy</sup> <sup>δ.</sup> <sup>These</sup> V -to-Φ <sup>are</sup> mapping into the triple formed by the angle <sup>fed</sup> <sup>into</sup> <sup>the</sup> <sup>forward</sup> <sup>parts</sup> <sup>of</sup> <sup>the</sup> <sup>Function</sup> φ′1 <sup>,</sup> <sup>momentum</sup> <sup>α,</sup> <sup>and</sup> <sup>energy</sup> <sup>δ.</sup> <sup>These</sup> <sup>are</sup> <sup>fed</sup> <sup>into</sup> <sup>the</sup> <sup>forward</sup> <sup>parts</sup> <sup>of</sup> <sup>the</sup> <sup>Function</sup> 1 or Function 2 with an additional input, which is the uniformly distributed random number G. The resulting triple of the post-collision angle φ1 together with momentum and energy are transformed by the Φ-to-V mapping into the post-collision velocities (a, b, c). For reversal, the forward process is inverted by first recovering the angle φ1 upon applying the V -to-Φ mapping on the post-collision velocities. The random number G is recovered by retracing the random number sequence, and the reverse part of the functionis applied to recover φ′1 <sup>,</sup> <sup>from which the</sup> <sup>pre-collision velocities are obtained by</sup> <sup>applying</sup> is applied to recover φ′1 <sup>,</sup> <sup>from which the</sup> <sup>pre-collision velocities are obtained by</sup> <sup>applying</sup> the Φ-to-V mapping on the recovered angle. (26) ′) ′) V -to-Φ ′ Forward −−−−−→ (φ1 <sup>, α, δ)</sup> −−−−−→ (φ1, α, δ) G Φ-to-V ′ Reverse ←−−−−− (φ1 <sup>, α, δ)</sup> ←−−−−− (φ1, α, δ) (a (a ′, b′, c ′, b′, c Φ-to-V −−−−−→ (a, b, c) V -to-Φ � ←−−−−− (a, b, c) 4.5 Reversal for 3-Particle Collisions in 2 Dimensions In a collision of three particles in 2-dimensional space, the equations of motion are:   a + b + c = α d + e + f = β a <sup>2</sup> + b <sup>2</sup> + c <sup>2</sup> + d <sup>2</sup> + e <sup>2</sup> + f <sup>2</sup> = δ 3δ - α <sup>2</sup> + β <sup>2</sup> Dynamics. (27)  The geometrical constraints satisfied by the post-collision velocities are:   r21x · (a − b) + r21y - (d − e) > 0, if P1 and P2 are in contact r32x · (b − c) + r32y - (e − f ) > 0, if P2 and P3 are in contact r13x · (c − a) + r13y - (f - d) > 0 if P3 and P1 are in contact Geometry. (28)  The pre-collision geometrical constraints are obtained by replacing > 0 by < 0 in the post-collision constraints. In Equation (28), we will use K1 to denote the first inequality (P1 and P2 in contact), K2 to denote the second inequality, and K3 to denote the third. The solution to the equations of motion satisfies the hyper-ellipsoid equation: 2 2     3 (29) √ + + 1 - a¯ − 0 �2     ¯b − 3 + �2         √ , = δ − <sup>α2 +</sup> 3 <sup>β2</sup> √32 <sup>α</sup> 1 √3 e¯ − √32 <sup>β</sup> 1 √3 . 2 <sup>e</sup> 1 - d¯ − 0 <sup>b</sup> 2 <sup>,</sup> <sup>¯b =</sup> <sup>a</sup> √ <sup>+</sup> 2 <sup>b</sup> 2 <sup>e</sup> <sup>,</sup> <sup>and</sup> <sup>e¯ =</sup> <sup>d</sup> √ <sup>+</sup> 2 <sup>e</sup> where a¯ = <sup>a −</sup> <sup>b</sup> √2 2 <sup>b</sup> <sup>,</sup> <sup>d¯ =</sup> <sup>d</sup> √ <sup>−</sup> 2 <sup>e</sup> 18 The hyper-ellipsoid can be described via parametic equations with three independent parameters {φ1, φ2, φ3} as the degrees of freedom as follows: a¯ = √ <sup>λ</sup> 2 cos φ1, d¯ = <sup>λ</sup> √ 2 <sup>sin φ1 cos φ2,</sup> (30) sin φ1 sin φ2 sin φ3, where 3 ¯b = e¯ = λ = √ √2 2 λ 3 <sup>α +</sup> √2 2 λ 3 <sup>β +</sup> √2   √ 2√ 2√ 3 <sup>sin φ1 sin φ2 cos φ3,</sup> φ1 ∈ [0, π], φ2 ∈ [0, π], φ3 ∈ [0, 2π).  δ − <sup>α2 +</sup> 3 <sup>β2</sup> , <sup>+</sup> 3 <sup>β2</sup> Based on the preceding parametric equations, the terms in the geometrical constraints can be expressed as: a − b = λ cos φ1 d − e = λ sin φ1 cos φ2 √ <sup>λ</sup> 2 <sup>(</sup> √ <sup>λ</sup> 2 <sup>(</sup> b − c = <sup>λ</sup> 2 e − f = <sup>λ</sup> 2 3 sin φ1 sin φ2 cos φ3 − cos φ1) (31) √ 2 <sup>λ</sup> <sup>(</sup> √ 2 <sup>λ</sup> <sup>(</sup> c − a = <sup>−</sup> 2 <sup>λ</sup> f - d = <sup>−</sup> 2 <sup>λ</sup> 3 sin φ1 sin φ2 sin φ3 − sin φ1 cos φ2) 3 sin φ1 sin φ2 cos φ3 + cos φ1) 3 sin φ1 sin φ2 sin φ3 + sin φ1 cos φ2) . Note that sin φ1 and sin φ2 are always non-negative. The V -to-Φ and Φ-to-V mappings are obtained from Equation (31) as follows: V -to-Φ: Given a − f, the angles φ1, φ2, and φ3 are computed as: φ1 = cos <sup>−1</sup> λ - a − b 0 if φ1 = 0 or φ1 = π φ2 = φ3 =      otherwise λ sin φ1 - d − e (32)   cos <sup>−1</sup> 0 if φ1 = 0 or φ1 = π or φ2 = 0 or φ2 = π otherwise √3λ sin φ1 sin φ2 - 2(e − f ) + λ sin φ1 cos φ2  sin <sup>−1</sup> Φ-to-V : Given α, β, δ, φ1, φ2, φ3, the values of a - f are computed from Equation (31). 19 Note that the cases of φ1 = 0 or φ1 = π or φ2 = 0 or φ2 = π are solved as follows: a = <sup>α</sup> 3 <sup>+</sup> <sup>λ</sup> 2 <sup>cos φ1</sup> <sup>α</sup> 2 <sup>cos φ1</sup> 3 <sup>−</sup> <sup>λ</sup> b = <sup>α</sup> 3 c = <sup>α</sup> 3 d = <sup>β</sup> 3 <sup>+</sup> <sup>λ</sup> 2 <sup>sin φ1 cos φ2</sup> <sup>β</sup> 3 <sup>+</sup> <sup>λ</sup> 2 <sup>sin φ1 cos φ2</sup> <sup>β</sup> 2 <sup>sin φ1 cos φ2</sup> 3 <sup>−</sup> <sup>λ</sup> (33) e = <sup>β</sup> 3 f = <sup>β</sup> 3 Hence, when dealing with Equation (30) in the remaining of the analysis, we only consider the case of 0 < φ1 < π and 0 < φ2 < π. Also, whenever φ1 = 0 or φ1 = π, we set φ2 = 0 and φ3 = 0. Similarly, whenever φ2 = 0 or φ2 = π, we set φ3 = 0. 4.5.1 Possible Geometries To make analysis easier, a notion of a “canonical configuration” is introduced for the three colliding particles in the 2-dimensional space. The canonical view is to align the x-axis with the line joining the centers of two particles in contact. The choice of the pair chosen for this line is designed to be recoverable in reverse execution, essentially making the choice of the pair only dependent on the geometry of collision, independent of the velocities of the particles undergoing the 3-particle collision. When the x-axis is aligned along such a pair of particles in contact, they can appear in one of four configurations shown in Figure 7. In all configurations, the horizontal line is chosen to be the line joining the two particles whose identifiers are smaller than that of the third one. The particle with the smallest identifier is always chosen as the particle on the left of the horizontal axis line. In configurations C1 and C2, all three particles are in contact with each other, giving three pairs of particles in contact. In each of the rest, C3 and C4, only two pairs of particles are in contact. In all configurations, P1 and P2 are the left and right particles forming the horizontal axis. In C1, the third particles P3 is above the two horizontally placed particles, while, in C2, the third particle is below them. The configurations C3 and C4 cover the rest of the possibilities in which only two pairs of the particles are in contact with each other at the same time. In C3, the third particle P3 is only in contact with particle P2, while, in C4, P3 is only in contact with particle P1. Once the canonical configuration is chosen, all the velocities are rotated to reorient to the new axes. Total momenta and energy undergo a resultant change that can be reversed to recover original momenta and energy values simply by rotating the axes back to original axes. Since the original velocities are in a one-to-one relation with the transformed velocities, it is the transformed velocities that will be considered as velocities a..f defined earlier for the 3-particle, 2-dimension collision model. After computing individual post-collision velocities, they are rotated back to the original frame of reference, thus restoring the original total momenta and energy. 20 #### P2 #### P1 #### P3 P1 P2 #### P3 # C1 # C2 #### P1 P2 P1 P2 # C3 P3 P3 C4 Figure 7: The canonical forms that we define for the four possible configurations in which three particles may undergo collision in 2 dimensions 4.5.2 Sampling the Ψ Phase Space To generate a random set of offsets, Ψ, a random sample point on the hyper-ellipsoid of Equation (29) is generated by invoking the numerical method given in Procedure 5 with s = 4, and {4λi | 1 ≤ i ≤ 4} obtained by converting Equation (29) into the canonical form expected by the algorithm. The sampling approach is a generalized version of the approach employed for 3-particle collisions in 1 dimension (Section 4.4) to sample the phase space of Ψ. As mentioned earlier, although rejection-based methods are available for generating the samples, rejection is incompatible with reversibility, making them inapplicable here. Note that, by using one extra random number (i.e., using dn + 1 random numbers instead of dn), Procedure 5 can be elegantly generalized, avoiding reliance on the separate algorithm of Section 4.4.3 for the special case of a 2-dimensional ellipsoid (ellipse). This can be achieved by iterating down to s = 1, introducing an extra parameter ψs, and using the additional random number to set ψs to either <sup>π</sup> 2 <sup>or</sup> <sup>3</sup> 2 <sup>π</sup> <sup>(i.e.,</sup> <sup>1x1</sup> <sup>= ±1λ1).</sup> <sup>Using such</sup> a generalized algorithm for sampling the surface of an s-dimensional ellipsoid, s ≥ 1, the algorithm in Section 4.4.3 can be replaced by a call to the generalized Procedure 5 with s = 2. However, to restrict the number of random numbers to dn, we customize the last iteration to use the optimized version given in Section 4.4.3. In the next sections, we derive the permissible ranges of the parameters, restricted from their full, nominal ranges due to conservation laws as well as geometrical constraints, and develop the forward and reverse collision procedures based on the derived parameter ranges. 4.5.3 Configuration C1 From the geometry of C1 (ref. Figure 8), it can be seen that r21x = D, r21y = 0, r32x = <sup>−</sup> 2 <sup>D</sup> <sup>,</sup> <sup>r32y</sup> <sup>=</sup> √23 <sup>D,</sup> <sup>r13x</sup> <sup>=</sup> <sup>−</sup> 2 <sup>D</sup> <sup>,</sup> <sup>and</sup> <sup>r13y</sup> <sup>=</sup> <sup>−</sup> √2 3 <sup>D.</sup> <sup>Using</sup> <sup>these</sup> <sup>in</sup> <sup>Equation</sup> <sup>(28)</sup> √ 2 <sup>D</sup> <sup>,</sup> <sup>r32y</sup> <sup>=</sup> 2 23 <sup>D,</sup> <sup>r13x</sup> <sup>=</sup> <sup>−</sup> 2 <sup>D</sup> <sup>,</sup> <sup>and</sup> <sup>r13y</sup> <sup>=</sup> <sup>−</sup> √2 r32x = <sup>−</sup> 2 <sup>D</sup> <sup>,</sup> <sup>r32y</sup> <sup>=</sup> √23 <sup>D,</sup> <sup>r13x</sup> <sup>=</sup> <sup>−</sup> 2 <sup>D</sup> <sup>,</sup> <sup>and</sup> <sup>r13y</sup> <sup>=</sup> <sup>−</sup> √2 3 <sup>D.</sup> <sup>Using</sup> <sup>these</sup> <sup>in</sup> <sup>Equation</sup> <sup>(28)</sup> and Equation (31) to account for the geometrical constraints, we obtain the ranges of 21 Procedure 5 (G −→ Ψ): Generate the Parameters Ψ of a Random Point on the Surface of an s-Dimensional Hyper-Ellipsoid, Hs, using Random Numbers G = {G1, . . ., Gs−1} i=1 sx <sup>λ</sup> ii = 1 is the Inputhyper-ellipsoid: s, {sλi | 1 ≤ i ≤ s}, where integer s - 1, and <sup>�s</sup> - �2 xi s <sup>λ</sup> i i=1 hyper-ellipsoid 1:2: InputOutput: :s, {sλi | 1 ≤ i1 ≤ s}, wherei < integer wheres - 1, ψandi are <sup>�s</sup> the {ψi | ≤ s}, s <sup>λ</sup> i 2: Output: {ψi | 1 ≤ i < s}, where ψi are the parameters of a random point (rx1, . . ., rxs) on the hyper-ellipsoid, such that r <sup>x</sup> i = s <sup>λ</sup> i <sup>cos ψ</sup> i j=1 <sup>sin ψj</sup> <sup>for</sup> <sup>all</sup> <sup>1 ≤</sup> <sup>i < s,</sup> <sup>and</sup> <sup>rxs</sup> <sup>=</sup> <sup>sλs</sup> j=1 <sup>sin ψj</sup> 3: for k = s down-to 2 do �i−1 �s s <sup>λ</sup> i <sup>cos ψ</sup> i j=1 <sup>sin ψj</sup> <sup>for</sup> <sup>all</sup> <sup>1 ≤</sup> <sup>i < s,</sup> <sup>and</sup> <sup>rxs</sup> <sup>=</sup> <sup>sλs</sup> down-to 2 do �i−1 4: Let k = s − k + 1 5: if k = 2 then 6: Invoke the algorithm in Section 4.4.3 using Gk to generate the parameter 0 ≤ ψ <sup>∗</sup> < 2π corresponding to a random point on the perimeter of the (2dimensional) ellipse H2 7:8: elseψk ← ψ <sup>∗</sup> 8: else 9: Compute the surface area Ak of Hk 10:11: ComputeUsing thethebisectionrandommethodfractionanalogousrAk of Aktoas:thatrAkin←SectionGk · Ak4.4.3, determine a 0 ≤ ψ <sup>∗</sup> ≤ π such that surface area of the calotte of Hk defined by the latitudinal angle ψ <sup>∗</sup> from the pole equals rAk 13:12: Determineψk ← ψ <sup>∗</sup> the parameters {s−1λi | 1 ≤ i ≤ s − 1} of the (s − 1)-dimensional ellipsoid Hs−1 formed by the opening of the calotte, obtained by substituting s <sup>x</sup> k <sup>=</sup> s <sup>λ</sup> k <sup>cos ψ</sup> k <sup>.</sup> 14: end if 15: end for φ1 and φ2 that are more constrained than in Equation (30). The inequality K1 directly gives the following: D · (λ cos φ1) + 0 · (· · · ) > 0 =⇒ cos φ1 ≥ 0 2 =⇒− <sup>π</sup> 2 <sup>≤</sup> <sup>φ1</sup> <sup>≤</sup> <sup>π</sup> =⇒ 0 ≤ φ1 < <sup>π</sup> 2 <sup>from</sup> <sup>Equation</sup> <sup>(30).</sup> =⇒− <sup>π</sup> 2 (34) <sup>π</sup> 2 <sup>from</sup> <sup>Equation</sup> <sup>(30).</sup> Inequality K2 gives: −D 3 sin φ1 sin φ2 cos φ3 − cos φ1) + 3 sin φ1 cos φ2 - 0. (35) √ 3D λ √ 2 - 2 <sup>(</sup> λ 2D <sup>·</sup> 2 <sup>(</sup> √ 3 sin φ1 sin φ2 sin φ3 − sin φ1 cos φ2) - 0. √ 3 sin φ1 cos φ2 - 0. or, √ √ 3 sin φ1 sin φ2 cos φ3 + cos φ1 + 3 sin φ1 sin φ2 sin φ3 − 22 P3 P1 P2 Figure 8: Measures of interest in configuration C1 Inequality K3 gives: 3 sin φ1 sin φ2 cos φ3 + cos φ1) + (36) −D 3 sin φ1 sin φ2 sin φ3 + sin φ1 cos φ2) - 0. √ φ1 sin φ2 sin φ3 + 3 sin φ1 cos φ2 - 0. 2λ <sup>(</sup> √ √ 2λ <sup>(</sup> √ −2D <sup>·</sup> −2λ √ 3 sin φ1 cos φ2 - 0. 23D - −2λ φ1 or, √ √ 3 sin φ1 sin φ2 cos φ3 + cos φ1 + 3 sin φ1 sin φ2 sin φ3 + From K2, we get: <sup>π</sup> 3 <sup>) <</sup> 2√ 1 3 tan L1: cos(φ3 + <sup>π</sup> 3 3 tan φ1 1 sin φ2 <sup>−</sup> 2 tan1 φ2 <sup>.</sup> (37) Similarly, from K3, we get: 1 <sup>π</sup> 3 <sup>) <</sup> 2√3 tan φ L2: - cos(φ3 − <sup>π</sup> 3 3 tan φ1 1 sin φ2 <sup>+</sup> 2 tan1 φ2 <sup>.</sup> (38) To ensure a valid range for the left hand side in L1, the right hand side (RHS) of the same must not be less than −1. Setting the RHS to −1 defines the boundary between the possible and impossible regions, in terms of the relation between φ1 and φ2. Similar restrictions arise from L2. These considerations give the limits on φ1 and φ2 as follows: √ √ 3 sin φ2) (from L1, RHS=−1) (39) 3 sin φ2) (from L2, RHS=−1). φ1 = cot <sup>−1</sup> ( φ1 = cot <sup>−1</sup> (− √ 3 cos φ2 − 2 √ 3 cos φ2 − 2 √ 3 cos φ2 − 2 3 sin φ2) (from L1, RHS=−1) When 0 ≤ φ1 ≤ φ1 <sup>∗</sup> <sup>=</sup> <sup>π</sup> 6 <sup>,</sup> <sup>φ2</sup> <sup>is</sup> <sup>unrestricted in</sup> <sup>its</sup> <sup>range of [0, π].</sup> <sup>When</sup> <sup>φ1</sup> <sup>> φ</sup> 1 <sup>∗</sup> <sup>=</sup> <sup>π</sup> 6 <sup>,</sup> <sup>the</sup> lower- and upper bounds of φ2 are restricted, as determined next. Let r = <sup>cot</sup> √ <sup>φ</sup> 3 <sup>1</sup> (giving When 0 ≤ φ1 ≤ φ1 <sup>∗</sup> lower- and upper lower- and upper bounds of φ2 are restricted, as determined next. Let r = <sup>cot</sup> √ <sup>φ</sup> 3 <sup>1</sup> (giving r < 1 when <sup>π</sup> 6 <sup><</sup> <sup>φ1</sup> <sup><</sup> <sup>π</sup> r < 1 when <sup>π</sup> 6 <sup><</sup> <sup>φ1</sup> <sup><</sup> <sup>π</sup> 2 <sup>).</sup> <sup>Then,</sup> <sup>the</sup> <sup>lower</sup> <sup>bound</sup> √ <sup>φ2l</sup> <sup>≤</sup> <sup>φ2</sup> <sup>is</sup> <sup>obtained</sup> <sup>by</sup> <sup>solving</sup> 1+5r−r <sup>2</sup> ). Similarly, the upper bound r = cos φ2 - 2 sin φ2, giving φ2l = 2 tan <sup>−1</sup> ( <sup>−2+</sup> √ 5−r <sup>2</sup> ). φ2 ≤ φ2u is obtained by solving r = − cos φ2 − 2 sin φ2, giving φ2u = 2 tan <sup>−1</sup> ( <sup>+2+</sup> 1−r Also, the values of φ1 and φ2 could restrict the range of φ3, whose limits are obtained by setting the RHS to unity. The restrictions on φ3 are obtained from: √ √ 1+5r−r <sup>2</sup> ). Similarly, the upper bound φ2 ≤ φ2u is obtained by solving r = − cos φ2 − 2 sin φ2, giving φ2u = 2 tan <sup>−1</sup> ( <sup>+2+</sup> 1 Also, the values of φ1 and φ2 could restrict the range of φ3 √ √ √ (40) 3 sin φ2) (from L2, RHS=1). φ1 = cot <sup>−1</sup> ( φ1 = cot <sup>−1</sup> (− √ 3 cos φ2 + 2 √ 3 cos φ2 + 2 3 sin φ2) (from L1, RHS=1) All the limiting curves on the angles are illustrated in Figure 9, which shows the space spanned by the nominal ranges of φ1 ∈ [0, <sup>π</sup> 2 <sup>]</sup> <sup>and φ2</sup> <sup>∈</sup> <sup>[0, π].</sup> <sup>The</sup> <sup>space is</sup> <sup>divided</sup> into six different regions that impose different constraints on the ranges of φ1, φ2 and 23 φ3. The first two regions, labeled R <sup>−</sup> 0 φ3. The first two regions, labeled R <sup>−</sup> 0 <sup>and</sup> <sup>R</sup> π <sup>−,</sup> <sup>demarcate the</sup> <sup>regions excluded</sup> <sup>to</sup> <sup>make</sup> RHSR <sup>+</sup> 0 <sup>,</sup> - <sup>the</sup> −1 (Equation (39)), one on each side of <sup>range</sup> <sup>of</sup> <sup>φ3</sup> <sup>is</sup> <sup>restricted</sup> <sup>from</sup> <sup>below</sup> φ <sup>to</sup> 2 = 0 and <sup>be</sup> <sup>greater</sup> φ2 = <sup>than</sup> π. In the region marked <sup>0,</sup> <sup>and</sup> <sup>in</sup> <sup>the</sup> <sup>region</sup> marked R <sup>+</sup> π <sup>, the range of φ3</sup> <sup>is restricted from the above to be less than 2π.</sup> <sup>In the region</sup> marked R <sup>−</sup> - <sup>,</sup> <sup>φ3</sup> <sup>is</sup> <sup>restricted</sup> <sup>from</sup> <sup>both</sup> <sup>below</sup> <sup>and</sup> <sup>above.</sup> <sup>The</sup> <sup>appropriate</sup> <sup>lower</sup> <sup>bound</sup> φ3l, and upper bound φ3u on φ3 can be computed accordingly. In the region marked R <sup>+</sup> + <sup>,</sup> <sup>φ3’s</sup> <sup>original</sup> <sup>range</sup> <sup>of</sup> <sup>[0, 2π)</sup> <sup>is</sup> <sup>unrestricted.</sup> <sup>+</sup> + <sup>,</sup> <sup>φ3’s</sup> <sup>original</sup> <sup>range</sup> <sup>of</sup> <sup>[0, 2π)</sup> <sup>is</sup> <sup>unrestricted.</sup> Thus, for C1, the ranges for post-collision parameters are: φ1 ∈ [0, <sup>π</sup> 2 [0, 0] if φ1 = 0 <sup>π</sup> 2 <sup>)</sup> <sup>π</sup> 6 <sup>< φ1</sup> <sup><</sup> <sup>π</sup> 2 <sup>)</sup> φ2 ∈ φ3 ∈     <u></u> <u></u> (41)   6 [0, π] if 0 < φ1 ≤ <sup>π</sup> [φ2l, φ2u ] otherwise (i.e., <sup>π</sup> 6 [φ3l, φ3u ] if (φ1,φ2) falls in R <sup>+</sup> 0 6 [0, π] if 0 < φ1 ≤ <sup>π</sup> <sup>+</sup> 0 <sup>,</sup> <sup>R</sup> π <sup>+</sup> <sup>or</sup> <sup>R−</sup> <sup>+</sup> + <sup>).</sup> [0, 0] if φ1 = 0 or φ2 = 0 or φ2 = π [0, 2π) otherwise (i.e., (φ1,φ2) falls in R <sup>+</sup> + R-L1, RHS=−1 R-L1, RHS=+1 F-L1, RHS=+1 F-L1, RHS=−1 R-L2, RHS=−1 R-L2, RHS=+1 F-L2, RHS=+1 F-L2, RHS=−1 ′2∗ φ φ F+ <sup>+</sup> ′2∗∗ + π F− <sup>−</sup> φ′1∗ π 2 φ <sup>∗</sup> 1 0 F0 <sup>+</sup> 0 <sup>+</sup> Fπ <sup>+</sup> φ <sup>∗</sup> 2 <sup>∗</sup> 2 φ <sup>∗∗</sup> 2 - <sup>−</sup> F0 <sup>−</sup> 0 <sup>−</sup> Fπ <sup>−</sup> π R <sup>−</sup> 0 <sup>−</sup> π <sup>−</sup> 0 R <sup>−</sup> π R <sup>+</sup> R <sup>−</sup> - R <sup>+</sup> π <sup>+</sup> - R <sup>+</sup> 0 π R <sup>+</sup> + 2 0 2 2 π φ2 and φ′2 Figure 9: Regions in the nominal phase spaces of φ1 and φ2 demarcating different bounds of φ1, φ2, and φ3 in Configuration 1 of 3-particle collisions in 2 dimensions 24 Figure 9,Using whicha similarshows theanalysis,range ofthe pre-collision φ′1 <sup>∈</sup> <sup>( π</sup> 2 <sup>, π],</sup> ranges <sup>and</sup> <sup>corresponding constraints of</sup> can be obtained, as illustrated <sup>φ</sup> ′2 <sup>and</sup> in Figure 9,′ which shows the range of φ′ 2 <sup>, π],</sup> <sup>and</sup> <sup>corresponding constraints of φ</sup> ′2 <sup>and</sup> 1 <sup>∈</sup> <sup>( π</sup> φ2 <sup>in</sup> <sup>terms</sup> <sup>of</sup> <sup>the</sup> <sup>forward</sup> <sup>regions</sup> <sup>F</sup> 0 <sup>−,</sup> <sup>F</sup> π <sup>−,</sup> <sup>and</sup> <sup>so</sup> <sup>on.</sup> φ′2 <sup>in</sup> <sup>terms</sup> <sup>of</sup> <sup>the</sup> <sup>forward</sup> <sup>regions</sup> <sup>F</sup> 0 <sup>−,</sup> <sup>F</sup> π <sup>−,</sup> <sup>and</sup> <sup>so</sup> <sup>on.</sup> The forward and reverse procedures for this configuration are given in Procedure 6 and Procedure 7 respectively. Procedure 6 ((φ′1 <sup>, φ</sup> ′2 <sup>, φ</sup> ′3 <sup>)</sup> <sup>−→</sup> <sup>(φ1, φ2, φ3)):</sup> <sup>Forward</sup> <sup>Procedure</sup> <sup>for</sup> <sup>Configuration</sup> <sup>1</sup> <sup>of</sup> a 3-Particle Collision in 2 dimensions Procedure 6 ((φ′1 <sup>, φ</sup> ′2 <sup>, φ</sup> ′3 <sup>)</sup> <sup>−→</sup> <sup>(φ1, φ2, φ3)):</sup> <sup>Forward</sup> <sup>Procedure</sup> <sup>for</sup> <sup>Configuration</sup> <sup>1</sup> <sup>of</sup> a 3-Particle Collision in 2 dimensions 1: Invoke Procedure 5 to generate the parameters (ψ1, ψ2, ψ3) of a random point on surface of the hyper-ellipsoid represented by Equation (29) ′ ′ 2 <sup>+ ψ1)</sup> <sup>mod</sup> <sup>π</sup> 2 2: φ1 ← (φ1 <sup>−</sup> <sup>π</sup> 3: φ2 ← (φ2 <sup>+ ψ2)</sup> <sup>mod</sup> <sup>π</sup> 4: Compute φ2l and φ2u {based on φ1} 5: if φ2 < φ2l or φ2u < φ2 then 6:7: endφ2 if← (φ2 + (φ2l + π − φ2u )) mod π ′ 8: Compute φ3l and φ3u {based on φ1 and φ2} 9: φ3 ← (φ3 <sup>+ ψ3)</sup> <sup>mod</sup> <sup>2π</sup> 10: if φ3 < φ3l then 11: φ3 ← (φ3 + φ3l ) mod 2π 12: else if φ3 - φ3u then 12: else if φ3 - φ3u then 14:13: endφ3 if← (φ3 + (2π − φ3u )) mod 2π 14: end if Procedure 7 ((φ1, φ2, φ3) −→ (φ′1 <sup>, φ</sup> ′2 <sup>, φ</sup> ′3 <sup>)):</sup> <sup>Reverse</sup> <sup>Procedure</sup> <sup>for</sup> <sup>Configuration</sup> <sup>1</sup> <sup>of</sup> a 3-Particle Collision in 2 dimensions 1: Invoke Procedure 5 to re-generate the parameters (ψ1, ψ2, ψ3) of the random point on surface of the hyper-ellipsoid represented by Equation (29), previously generated by Procedure 6 2: Recompute φ2l and φ2u {based on φ1} ′ 4:3: φRecompute φ3l and φ3u {based2 <sup>)</sup> on φ1 and φ2} 4: φ′′ 2 <sup>)</sup> 1 <sup>←</sup> <sup>π</sup> 2 <sup>+ ((φ1 −</sup> <sup>ψ1)</sup> <sup>mod</sup> <sup>π</sup> 5: φ ′ ′ 6: if2 φ <sup>←</sup> ′2 <sup>< φ(φ2</sup> <sup>2−</sup> l′ <sup>orψ2)φ2mod</sup> u <sup>< φπ</sup> 2 <sup>then</sup> ′2 if <sup>←</sup> <sup>(φ</sup> ′2 <sup>−</sup> <sup>(φ2</sup> l <sup>+ π −</sup> <sup>φ2</sup> u <sup>))</sup> <sup>mod</sup> <sup>π</sup> 7: φ 8: end if 9: φ′ ′ if3 φ <sup>←</sup> 3 <sup>< φ(φ3 −3</sup> l <sup>thenψ3)</sup> <sup>mod</sup> <sup>2π</sup> 10: if φ′′3 <sup>< φ3</sup> l′ <sup>then</sup> ′ ′ 11: φ ′ 12: else3′ if <sup>←</sup> φ <sup>(</sup> 3 <sup>φ</sup> 3′ <sup>> φ−</sup> <sup>3φ</sup> u <sup>3</sup> l <sup>then)</sup> <sup>mod</sup> <sup>2π</sup> 11: φ ′ ′ 14:13: endφ3 if <sup>←</sup> <sup>(φ</sup> 3 <sup>−</sup> <sup>(2π −</sup> <sup>φ3</sup> u <sup>))</sup> <sup>mod</sup> <sup>2π</sup> 13: φ 4.5.4 Configuration C2 Using algebra similar to that for C1, the ranges for configuration C2 are obtained, with swapped signs for r32y and r13y. 25 4.5.5 Configuration C3 Configuration C3 can be parameterized by an angle θ that P3 makes relative to P2, as shown in Figure 10. #### P1 #### P2 θ #### P3 Figure 10: Parametrization of configuration C3 by angle θ, <sup>π</sup> 3 <sup>< θ</sup> <sup><</sup> <sup>5</sup> 3 <sup>π</sup> In this configuration, r21x = D, r21y = 0 (as was the case for C1 and C2), but r32x = −D cos θ, r32y = −D sin θ, and we are not concerned about r13x and r13y. Using these in Equation (28), we get the geometrically constrained ranges of φ1, φ2, and φ3. Since the inquality K1 for this configuration is the same as for configurations C1 and C2, the range of φ1 remains (0, <sup>π</sup> 2 <sup>].</sup> <sup>However,</sup> <sup>only</sup> <sup>the</sup> <sup>inequality</sup> <sup>K2</sup> <sup>applies</sup> <sup>to</sup> <sup>this</sup> Figure 10: Parametrization of configuration C3 by angle θ, <sup>π</sup> 3 C2, the range of φ1 remains (0, <sup>π</sup> 2 <sup>].</sup> <sup>However,</sup> <sup>only</sup> <sup>the</sup> <sup>inequality</sup> <sup>K2</sup> <sup>applies</sup> <sup>to</sup> <sup>this</sup> configuration, and K3 need not apply. From K2, we get: 3 sin φ1 sin φ2 cos φ3 − cos φ1) √ <sup>λ</sup> 2 <sup>(</sup> 3 sin φ1 sin φ2 sin φ3 − sin φ1 cos φ2) > 0 . √ <sup>λ</sup> 2 <sup>(</sup> −D sin θ <sup>λ</sup> 2 −D cos θ <sup>λ</sup> 2 Since sin φ1̸ = 0 and sin φ2̸ = 0, ̸ ̸ √ cos(φ3 − θ) 3 sin φ1 sin φ2 < cos θ cos φ1 + sin θ sin φ1 cos φ2 =⇒ cos(φ3 − θ) < γ, where cos(φ3 − θ) γ = <sup>cos θ cos φ1 + sin θ sin φ1 cos φ2</sup> √3 sin φ1 sin φ2 (42) √3 sin φ1 sin φ2 =⇒ φ3 ∈ [φ3l + θ, φ3u + θ], where 0 ≤ (φ3l + θ) mod 2π ≤ (φ3u + θ) mod 2π ≤ 2π, and φ3l and φ3u are solutions to cos <sup>−1</sup> γ. Also,Let µ the= √range3 tancos θ φ1of <sup>and</sup> φ2 may <sup>ν</sup> <sup>=</sup> besin√3 θconstrained <sup>.</sup> <sup>Then,</sup> <sup>γ</sup> due <sup>=</sup> µto+sinν costhe φ2 φ2requirement. If µ − ν ≥that0 or−1µ +≤ νγ ≤≤ 1.0, θ µ+ν cos φ2 3 <sup>.</sup> <sup>Then,</sup> <sup>γ</sup> <sup>=</sup> sin φ2 cos θ sin θ 3 tan φ1 <sup>and</sup> <sup>ν</sup> <sup>=</sup> √3 Let µ = √3 tancos θ φ1 <sup>and</sup> <sup>ν</sup> <sup>=</sup> sin√3 θ <sup>.</sup> <sup>Then,</sup> <sup>γ</sup> <sup>=</sup> µ+sinν cos φ2 φ2 . If µ − ν ≥ 0 or µ + ν ≤ 0, then the range of φ2 is not constrained, giving the lowerbound φ2l ≤ φ2 equal to 0 and upperbound φ2 ≤ φ2u equal to π. Otherwise, the lower bound (greater than 0) and upper bound (less than π) of φ2 must be determined as follows. If µ - ν < 0, the lowerbound of φ2 is obtained by solving for φ2 in - sin φ2 = µ + ν cos φ2. Since sin φ2 and µ + ν cos φ2 intersect in at most two points within the range (0, π) (see Figure 11), a unique lowerbound φ2l, 0 < φ2l ≤ φ2 < π is obtainable. Similarly, if µ + ν - 0, then a unique upperbound φ2u, 0 < φ2 ≤ φ2u < π is obtained by solving for φ2 in sin φ2 = µ + ν cos φ2. 26 µ + ν 0 µ − ν sin φ2 - sin φ2 µ + ν cos φ2, ν - 0 µ + ν cos φ2, ν < 0 0 π φ2 Figure 11: Illustration of lower and upper bounds of φ2 in configuration 3 of 3-particle collisions in 2 dimensions Thus, for C3, the ranges are: φ1 ∈ [0, <sup>π</sup> 2 [0, 0] if φ1 = 0 <sup>π</sup> 2 <sup>)</sup> φ2 ∈ φ3 ∈    [0, 0] if φ1 = 0 or φ2 = 0 or φ2 = π - [φ3l + θ, φ3u + θ] otherwise.  [0, π] if µ − ν ≥ 0 or µ + ν ≤ 0 [φ2l, φ2u ] otherwise (43) the Thesameranges may beas in configuration 1derived similarly for pre-collision.at ( <sup>π</sup> 2 <sup>, π],</sup> <sup>but,</sup> <sup>Equation (42) changes to</sup> The range of φ <sup>cos (</sup> ′1 <sup>remains toφ</sup> ′3 <sup>−</sup> <sup>θ) > γbe.</sup> The ranges may be derived similarly for pre-collision. The range of φ <sup>π</sup> 2 <sup>, π],</sup> <sup>but,</sup> <sup>Equation (42) changes to</sup> <sup>cos (φ</sup> ′3 <sup>−</sup> <sup>θ) > γ.</sup> 4.5.6 Configuration C4 The treatment of configuration C4 proceeds similar to that for configuration C3, using K3 instead of K2. 4.6 Random Number Generation A subtle but important consideration in zero-memory reversal is the need to ensure that the exact number of random number invocations is also recovered during reverse execution without explicitly storing that information. In other words, the number of random numbers thrown, GC, for any collision C must be determinable by the collision operator such that the random number sequence is correctly reinstated to the proper position corresponding to the pre-collision state. All our algorithms possess this property, with GC = dn. In the case of 2-particle collisions in 1 dimension, no random numbers are needed, trivially satisfying the property. In the case of 2-particle collisions in 2 dimensions, 27 exactly one random number is generated per collision (Procedure 1), and hence the random number stream is stepped back by exactly one number during reversal of that collision (Procedure 2). The case of 2-particle collisions in 3 dimensions is slightly more complex, since it requires more than one random number to be generated. For forward collision, it appears possible to sometimes generate one random number and some other times two. Only one random number (let us denote it by G1) appears sufficient to be generated if that number happens to result in φ1 = 0 or φ1 = π. Similarly, two random numbers (let us denote them by G1 and G2) appear needed only to generate φ2 if the randomly generated φ1 (from G1) is such that φ1̸ = 0 and φ1̸ = π. However, this conditional generation of one or two random numbers per collision creates difficulties during reversal, because, when the random number stream is reversed and the previous random number G is recovered, we will remain unsure whether G corresponds to G1 or G2. It is impossible to disambiguate between the two possibilities because both φ1 and φ2 may assume the value of zero. Hence, we would remain unsure if, in the forward collision, G1 was zero and hence G2 was not used for that collision, or if G1 happened to be non-zero and G2 = G happened to be zero. Similar ambiguity can be argued for the case of G̸ = 0. Due to these considerations, we fix the number of random numbers generated per forward collision to be exactly two, unconditionally, so that the random number stream can be reversed exactly by two, restoring it to the correct pre-collision state. If G1 results in φ1 = 0, G2 is still generated from the stream, but simply discarded by the collision algorithm. Assuming that the stream is random, the discarding of G2 when φ1 = 0 does not affect the uniformity of the random samples. Note that the discarding is performed unconditionally, without any dependence or usage of the actual value of the discarded G2 in the forward model. This aspect of unconditional discarding is crucial for reversal, because the reversal also can determinstically reverse the random number stream. For 3-particle collisions in 1 dimension, exactly one random angle is required for every forward collision, and hence one reversal is necessary and sufficient in each reverse collision, ensuring correct reversal of the random stream. For 3-particle collisions in 2 dimensions (Appendix 4.5), one, two, or three random angles are needed (depending on the geometry and pre-collision velocities) per forward collision. However, due to considerations similar to those for the case of 2-particle collisions in 3 dimensions, we use exactly three random numbers for every forward collision (even if only one or two of them may be sufficient in special cases of dynamics and geometry) in order to reverse the random number stream correctly. In general, exactly dn random numbers must be generated for every collision involving n particles in d dimensions. With regard to the number of distinct streams to employ in the simulation, it is possible to use one of the following three approaches: (1) a single random number stream for the entire system, or (2) N independent streams, corresponding to each particle in the system, or (3) dn independent streams for use in each collision. The first approach clearly requires a very high quality random number generator with a very long period in order to support a large number of collisions when N is large. The second approach requires relatively smaller periods per stream but also requires minimal correlation between streams. In any given collision, the random stream of the particle with the smallest identifer among the colliding particles can be used for that collision. The third approach can be used to sample exactly one random number per stream per collision. All approaches seem appropriate for reversal, depending on the modeler’s specific needs regarding computational cost and the stream period. 28 Another context in which reversibility considerations of random number streams plays an important role is in generating random samples of Ψ. The G-to-Ψ function for sampling Ψ involves sampling the circumference of an ellipse (or, in general, sampling the points on the surface of higher dimensional ellipsoids). While rejection-based sampling procedures [PTVF07] are available for such problems, they cannot be used in reversible execution. This is because the number of (uniformly distributed) random numbers used by such rejection-based procedures varies with each sampled point, which makes it impossible to unambiguously reverse the random number stream without keeping track of how many random numbers were generated for each sample. In fact, rejection-based sampling can only be employed for certain special classes of probability distributions, whose parametric input does not vary across samples [PD09], whereas, in sampling Ψ, the parametric input varies with each collision. #### 5 Implementation Results In order to test the performance of the algorithms, we implemented the algorithms in software using the C++ programming language, and executed simulation experiments. The experiments are intended to test (1) the ability to restore the initial state after a sequence of many forward collisions followed by their reversals, and (2) the quality of phase space coverage discerned from the uniformity of generated velocity samples. For random number generation, we used a reversible version of a high quality linear congruential generator [LA97] with a period of 2 <sup>121</sup> . A single generator stream is used for all the particles. In each configuration, the experiments verify successful reversal across several thousands of collisions. 5.1 Collision Sequence Reversal Procedure 8 shows the pseudocode of the experiment program for 2-particle collisions in 2 dimensions. Procedure 9 shows the pseudocode of the experiment program for 3-particle collisions in 1 dimension. In both, the state of the particles is initialized to any desired intial configuration, followed by a sequence of Nc applications of the forward collision operator. RNG(S) represents the generation of the next sample in [0, 1) from the random number stream (which also updates S as side-effect), while RNG <sup>−1</sup> (S) represents the reversal of the most previous invocation to RNG and the recovery of the most recently generated value from RNG. After each forward collision, post-collision velocities are multiplied by −1 to give the new pre-collision velocities for the next collision. Since the post-collision velocities are guaranteed to be divergent, their opposites are guaranteed to give converging velocities that will result in the next collision. After all Nc forward collisions, the entire sequence is reversed by executing the reverse collision operator Nc times. Clearly, the reversal is successful if the final velocities after all Nc reversals recovers the initial velocities. This condition is verified at the end and the corresponding status message is printed. All executions terminated successfully with a “passed” status, verifying the restoration of initial state after reversal of Nc collisions. The unbiased and correct phase space coverage is tested with Nc up to 10 <sup>6</sup> by plotting the post-collision angles against random angle offsets and pre-collision velocities. In the case of 3-particle collisions in 1 dimension, numerical integration to compute the segment length of an ellipse was performed using the Simpson’s rule. Also, care was 29 Procedure 8 Reversal Illustration for 2-Particle Collisions in 2 Dimensions 1: (a, b, c, d) ← (a0, b0, c0, d0) {initial velocities} 2: α ← a + b, β ← c + d, δ ← a <sup>2</sup> + b <sup>2</sup> + c <sup>2</sup> + d <sup>2</sup> {momenta and energy} 3: S ← random number seed 4: r21x ← 1, r21y ← 1 {normalized collision geometry} ′ 5: for i = 1 to Nc do {−− Forward Execution −−} ′ 6:7: φ1 <sup>←</sup> <sup>V -to-Φ(a, b, c, d)</sup> <sup>of</sup> <sup>Section</sup> <sup>4.2</sup> ′ G ← RNG(S) {Generate next random number in [0, 1)} 6: φ ′ 9:8: (φa, b, c, d1 ← Apply) ← ΦProcedure-to-V (α, β, δ, φ1 on φ11) <sup>using</sup> of Section <sup>G,</sup> <sup>r21</sup> 4.2 <sup>x,</sup> <sup>and</sup> <sup>r21y</sup> 9:8: φ1 ← Apply Procedure 1 on φ 10: a ←−a, b ←−b, c ←−c, d ←−d {Reverse velocities to create next collision} 11: end for 12: for i = Nc to 1 do {−− Reverse Execution −−} 13: a ←−a, b ←−b, c ←−c, d ←−d 14:15: φ1 ← V -to-Φ(a, b, c, d) of Section 4.2 ′ G ← RNG <sup>−1</sup> (S) {Recover previous random number} 16: φ ′ 1 <sup>←</sup> <sup>Apply</sup> <sup>Procedure</sup> <sup>2</sup> <sup>on</sup> <sup>φ1</sup> <sup>using</sup> <sup>G,</sup> <sup>r21x,</sup> <sup>and</sup> <sup>r21y</sup> 17: (a, b, c, d) ← Φ-to-V (α, β, δ, φ1 <sup>)</sup> <sup>of</sup> <sup>Section</sup> <sup>4.2</sup> 16: φ ′1 <sup>)</sup> <sup>of</sup> <sup>Section</sup> <sup>4.2</sup> 18: end for 19: if a = a0 and b = b0 and c = c0 and d = d0 then {−− Verification −−} 20: print ’Passed’ 21: end if needed to account for numerical precision issues when using the numerically computed cosine function, which sometimes produces numerical noise for angles within very small neighborhoods of multiples of <sup>π</sup> 6 <sup>and</sup> <sup>π</sup> 2 <sup>.</sup> <sup>A tolerance of ±10−8</sup> <sup>around zero was employed</sup> when determining whether any given cosine value can be considered zero or positive. Figure 12 plots the post-collision angles against their corresponding pre-collision angles generated as part of an execution of 2-particle collisions in 2 dimensions, and plots the post-collision angles against their corresponding random angles in the same execution. Both plots show excellent uniformity and correctness of the sampled phase space. Similarly, Figure 13 shows the corresponding data for 3-particle collisions in 1 dimension; again, they display excellent coverage. Since the covered areas in the plots become too dense for visual clarity when Nc becomes large, only data for Nc = 10 <sup>4</sup> are shown in the figures <sup>2</sup> . 5.2 Randomness Tests The correctness of phase space coverage is experimentally verified by testing the randomness of the generated angles using statistical tests. The Diehard Battery of Tests [Mar95] for statistical verification of randomness is used for this purpose. The post-collision angles are mapped to double-precision numbers, each in [0, 1), and the uniformity of their distribution is verified. This method is applied to 2-particle collisions in 2 dimensions, and to 3-particle collisions in 1 dimension. 2Figures for much larger number of collisions (Nc = 105) were also generated confirming similar uniformity of coverage and correctness of sampled phase space, but they result in much larger file sizes and hence not included here. 30 Procedure 9 Reversal Illustration for 3-Particle Collisions in 1 Dimension 1: (a, b, c) ← (a0, b0, c0) {initial velocities} 2: α ← a + b + c, δ ← a <sup>2</sup> + b <sup>2</sup> + c <sup>2</sup> {momenta and energy} 3: S ← random number seed ′ 4: for i = 1 to Nc do {−− Forward Execution −−} ′1 <sup>←</sup> <sup>V -to-Φ(a, b, c)</sup> <sup>of</sup> <sup>Section</sup> <sup>4.4</sup> 5: φ 6: ′ G ← RNG(S) {Generate next random number in [0, 1)} 7:8: φ1 ← Apply Procedure 3 on φ1 <sup>using</sup> <sup>G</sup> ′1 <sup>using</sup> <sup>G</sup> 8: (a, b, c) ← Φ-to-V (α, δ, φ1) of Section 4.4 9: a ←−a, b ←−b, c ←−c {Reverse velocities to create next collision} 10: end for 11: for i = Nc to 1 do {−− Reverse Execution −−} 12: a ←−a, b ←−b, c ←−c 14:13: φ1 ← V -to-Φ(a, b, c) of Section 4.4 14: ′ G ← RNG <sup>−1</sup> (S) {Recover previous random number} 15: φ ′ ′ 1 <sup>←</sup> <sup>Apply</sup> <sup>Procedure</sup> <sup>4</sup> <sup>on</sup> <sup>φ1</sup> <sup>using</sup> <sup>G</sup> 1 <sup>)</sup> <sup>of</sup> <sup>Section</sup> ′ 16: (a, b, c) ← Φ-to-V (α, δ, φ1 <sup>)</sup> <sup>of</sup> <sup>Section</sup> <sup>4.4</sup> 17: end for 16: (a, b, c) ← Φ-to-V (α, δ, φ 17: end for 18: if a = a0 and b = b0 and c = c0 then {−− Verification −−} 19: print ’Passed’ 20: end if For 2-particle collisions in 2 dimensions, each post-collision angle φ1 is mapped to a double-precision number η ∈ [0, 1) as η = (φ1 − κ)/π, where κ = 0 if 0 ≤ φ1 ≤ <sup>π</sup> 2 <sup>,</sup> and κ = π otherwise ( <sup>3π</sup> a double-precision number η ∈ [0, 1) as η = (φ1 − κ)/π, where κ = 0 if 0 ≤ φ1 ≤ <sup>π</sup> 2 <sup>,</sup> and κ = π otherwise ( <sup>3</sup> 2 <sup>π</sup> ≤ φ1 ≤ 2π). Each η is converted into an integer equal to ⌊η × 4, 294, 967, 296⌋, and the resulting series of numbers (in hexadecimal format) is converted via the asc2bin program of Diehard to a binary-formatted file given as input to the diehard program. For 3-particle collisions in 1 dimension, each post-collision angle φ1 is mapped to a double-precision number η ∈ [0, 1) as η = (φ1 − <sup>7</sup> 6 <sup>π</sup> <sup>)/( 3</sup> 2 <sup>π</sup> <sup>−</sup> <sup>7</sup> 6 <sup>π</sup> <sup>).</sup> <sup>Each</sup> <sup>η</sup> <sup>is</sup> <sup>converted</sup> into an integer equal to ⌊η × 4, 294, 967, 296⌋, and the resulting series of numbers (in hexadecimal format) is converted via the asc2bin program of Diehard to a binaryformatted file given as input to the diehard program. For 3-particle collisions in 1 dimension, each post-collision angle φ1 is mapped to a double-precision number η ∈ [0, 1) as η = (φ1 − <sup>7</sup> 6 <sup>π</sup> <sup>)/( 3</sup> 2 <sup>π</sup> <sup>−</sup> <sup>7</sup> 6 <sup>π</sup> <sup>).</sup> <sup>Each</sup> <sup>η</sup> <sup>is</sup> <sup>converted</sup> Both Procedure 8 and Procedure 9 were successfully executed with Nc = 3, 000, 000 collisions, such that they terminate with a “Passed” result. The angles are logged to a file during their execution, and then used as input to the randomness tests. According to the Diehard tests, if the “p-values” computed and printed by diehard are observed to be strictly greater than 0 and less than unity, randomness is understood to be satisfied [Mar95]. The p-values observed from the randomness tests on the generated angles are given in Table 1. Good phase space coverage via randomization is indicated by the fact that the p-values from several tests are significantly away from zero and unity. For 2-particle collisions in 2 dimensions, all tests in the Diehard repository were used and verified to generate very good randomness (positive p-values less than unity) without exception. This is due to the fact that no numerical precision effects are present in the collision algorithm for 2-particle collisions in 2 dimensions. For 3-particle collisions in 1 dimension, all tests were used except those that operate on bit-level representations (such as the Birthday, Bitstream and Count-the-1s tests). This is because round off and 31 trunction effects in numerical integration, even at a relatively high precision of 10 <sup>−9</sup> in the computation of angles, introduces non-random patterns in the last few bits of the mantissa, appearing as non-randomness when selectively viewed in isolation or across multiple floating point numbers. However, when the angles are viewed as numbers themselves, uniform randomness is indeed observed, as expected. Table 1: Randomness indicator p-values from Diehard battery of tests Test Category p-value 2-Dimension 1-Dimension 2-Particle 3-Particle CRAPS Overall 0.979800 0.570270 Wins 0.790715 0.862293 Throws/game 0.979797 0.570273 RUNS Set 1 - Up 0.847070 0.298998 Set 1 - Down 0.128221 0.632054 Set 2 - Up 0.183069 0.871807 Set 2 - Down 0.244909 0.111657 SUMS 10 χ <sup>2</sup> -tests on 100 χ <sup>2</sup> -tests 0.370145 0.257959 SQUEEZE 42 degrees of freedom 0.890107 0.435410 3DSPHERES χ <sup>2</sup> -test on 20 p-values 0.813199 0.897844 MINDIST χ <sup>2</sup> -test on 100 min-distances 0.348209 0.751603 PARKLOT χ <sup>2</sup> -test on 10 p-values 0.947200 0.720233 #### 6 Performance Estimation To estimate the performance gain that can be expected by resorting to reversible collisions instead of state saving, we implemented a simulation of a sequence of 2-particle collisions in a closed system of N particles in d = 2 dimensions. Experiments were run with N = 1, 000, N = 10, 000, and N = 100, 000 particles. Starting with random initial configuration of positions and velocities, and randomly selected inter-collision times, particle motion is simulated between collisions, and, at every collision point, the collision operator is applied on a random pair of particles. With state saving, the system state is saved to memory before every collision, to be able to roll back to that state. With reverse computation, no state is saved, as the system can be rolled back perfectly to any point in the past by reverse computation alone, without reliance on memory. Two platforms with different computational and memory characteristics are tested: one with traditional central processing unit (CPU), and the other with newer graphical processing unit (GPU). Modern CPUs now have much higher computational speeds than memory speeds; the differential between computational and memory speeds is even more pronounced in modern GPU platforms [PFS05]. Implementation on the CPU is realized in the C++ programming language, and that on the GPU is in the CUDA programming language [SK10]. The CPU is an AMD Opteron 6174 processor with 64 GB of memory. The GPU is a high-end nVidia Geforce GTX 580 (Fermi) accelerator with 512 CUDA cores and 3 GB device memory. Compilation systems used were gcc 4.4.5 and CUDA 4.1. In each simulation run, Nc = 1000 collisions were simulated, and, after Nc collisions, the system was rolled back to the beginning. With reverse computation, the positions and velocities are verified to match the initial conditions exactly (to within at least 32 2π 3π 2 π π 2 0 2π 3π 2 π π 2 0 0 π2 π 32π 2π Pre-collision Angle φ′1 0 π2 π 32π 2π Random Angle Offset ψ1 Figure 12: Sampling for Nc = 10 <sup>4</sup> collisions in 2-particle collisions in 2 dimensions 33 2π 11π 6 3π 2 7π 6 π π 2 π 6 0 2π 11π 6 3π 2 7π 6 π π 2 π 6 0 0 π6 π2 π 32π 116π <sup>2π</sup> Pre-collision Angle φ′1 0 π6 π2 π 32π 116π <sup>2π</sup> Random Angle Offset ψ1 Figure 13: Sampling for Nc = 10 <sup>4</sup> collisions in 3-particle collisions in 1 dimension 34 ǫ = ±10 <sup>−9</sup> ), while, with state saving, the results are trivially exactly matched. The results are drawn as stacked histograms in Figure 14, with the total height of each bar representing the total time for forward execution of Nc collisions and their reversal, which is split into Forward Time and Rollback Time in milliseconds. Three variants are benchmarked: SS1 represents the state saving mechanism in which all state is saved (positions and velocities); SS2 represents an optimized state saving mechanism in which the positions are saved and only the four components of the pre-collision velocities of the colliding pair are saved; RC represents the reverse computation with no memory. For each variant, the suffix -CPU represents execution on the CPU, and -GPU represents execution on the GPU. CPU-based implementation GPU-based implementation (a) Number of particles = 1,000 (b) 80 70 60 50 40 30 20 10 0 450 400 350 300 250 200 150 100 50 0 4000 3500 3000 2500 2000 1500 1000 500 0 SS1-CPU SS2-CPU RC-CPU SS1-GPU SS2-GPU RC-GPU Rollback Time (ms) <u>Forward Time (ms)</u> Rollback Time (ms) <u>Forward Time (ms)</u> SS1-CPU SS2-CPU RC-CPU 80 70 60 50 40 30 20 10 0 (c) Number of particles = 10,000 (d) SS1-GPU SS2-GPU RC-GPU Rollback Time (ms) ~~For~~ ward Time (ms) Rollback Time (ms) ~~For~~ ward Time (ms) SS1-CPU SS2-CPU RC-CPU 450 400 350 300 250 200 150 100 50 0 (e) Number of particles = 100,000 (f) SS1-GPU SS2-GPU RC-GPU Rollback Time (ms) <u>Forward Time (ms)</u> Rollback Time (ms) <u>Forward Time (ms)</u> 4000 3500 3000 2500 2000 1500 1000 500 0 Figure 14: Performance of state saving and reverse computation with Nc = 1000 collisions 35 Total run time with reverse computation is lower across the board. As expected, the greatest differential is observed in Figure 14(f) for the GPU runs with the largest number of particles (N = 100, 000). Since the ratio of memory transfer cost to computational cost is much higher with the GPU, reverse computation runs much faster, while state saving incurs the high memory transfer cost for every collision. Also, the GPU platform is known to be extremely efficient with large vectorized codes such as this simulation (i.e., more particles can be simulated with little increase in total time, if memory bottle neck is relieved). Hence, the reverse computation runs are extremely fast on the GPU, compared to all CPU runs and also compared to state saving with GPU. On smaller number of particles (N = 1000 and N = 10, 000), CPU runs in (a) and (c) are faster than GPU runs in (b) and (d) because of larger CPU caches, yet, even in this case of relatively lower memory cost, reverse computation is observed to run faster. Even more importantly, when the number of particles is further increased (e.g., N ≥ 1 million), state saving becomes infeasible due to memory limitations, but reverse computation runs well even at such large scale. Similarly, the benefit of using reversible simulation only increases with increase in the number of collisions, due to corresponding increase in the memory needs of state saving. A more detailed analysis of the memory subsystem behavior (e.g., data cache misses at levels 1 and 2, and translation lookaside buffer metrics) for each of these runs is part of our planned future work. #### 7 Summary The classical problem of simulating elastic collisions of hard spheres has been revisited, with the important additional requirement of reversibility. Although classical simulation of elastic collisions has been well studied in the literature, little has been known on how to simulate them reversibly with minimal memory overhead. Here, we formalized the problem in terms of accurate phase space coverage specification and geometrical constraints. We solved the problem by developing a general framework that combines reversible pseudo random number generation with new mapping functions, geometrical constraints, and reversal semantics. While previous log-based approaches require memory proportional to the number of collisions, our algorithms incur essentially zero memory overheads and also ensure correct phase space coverage. We developed the detailed steps for 2-particle collisions (up to 3 dimensions) and 3-particle collisions (up to 2 dimensions). In these configurations, memory overhead is exactly zero for collisionsconfigurations,in which d{nφ′i+1= <sup>, . . ., φ</sup> 1, and′dnessentially <sup>}</sup> <sup>are</sup> <sup>logged</sup> zero <sup>if</sup> for <sup>and</sup> collisions <sup>only</sup> <sup>if</sup> <sup>φi</sup> with <sup>=</sup> <sup>0,</sup> dn <sup>for</sup> - <sup>any</sup> 1. In <sup>1</sup> <sup>≤</sup> the <sup>i</sup> <sup><</sup> latter <sup>dn.</sup> Generalizations to collisions among larger number of particles and at higher dimensions configurations, {φ′i+1 <sup>, . . ., φ</sup> ′dn <sup>}</sup> <sup>are</sup> <sup>logged</sup> <sup>if</sup> <sup>and</sup> <sup>only</sup> <sup>if</sup> <sup>φi</sup> <sup>=</sup> <sup>0,</sup> <sup>for</sup> <sup>any</sup> <sup>1</sup> <sup>≤</sup> <sup>i</sup> <sup><</sup> <sup>dn.</sup> Generalizations to collisions among larger number of particles and at higher dimensions are tedious, but can be carried out if needed. At higher dimensions and with larger number of particles, computationally expensive numerical integration becomes necessary in both classical (forward-only) approaches as well as in the forward procedures of our reversible method. To meet the goal of minimal memory overhead, our reverse procedures rely on numerical integration as well, whereas log-based reversal approaches would use memory to save information and avoid recomputation in the reverse path. In a normal, well-balanced parallel execution, reversals of collisions are far fewer than forward collisions (i.e., dependency violations are incurred infrequently). In such cases, our reversible models are more efficient, since forward cost for reversibility is eliminated, whereas log-based approaches would incur log-generation costs in forward execution. ′i+1 <sup>, . . ., φ</sup> Finally, although reversibility of elastic collisions is a seemingly simple problem to 36 formulate, it includes sufficient complexity to make it challenging. The new approach and results presented here offer insights in revisiting additional classical physical system models with the added requirement of reversibility and exploring their fundamental memory characteristics and limits. #### References [HBD <sup>+</sup> 89] P. Hontalas, B. Beckman, M. DiLorento, L. Blume, P. Reiher, K. Sturdevant, L. V. Warren, J. Wedel, F. Wieland, and D. R. Jefferson. Performance of the colliding pucks simulation on the time warp operating system. In Distributed Simulation, 1989. [Kra96] Alan T. Krantz. Analysis of an efficient algorithm for the hard-sphere problem. ACM Trans. Model. Comput. Simul., 6(3):185–209, July 1996. [LA97] Pierre L’Ecuyer and Terry H. Andres. A random number generator based on the combination of four lcgs. In Mathematics and Computers in Simulation, pages 99–107, 1997. [Lub91] Boris D. Lubachevsky. How to simulate billiards and similar systems. Journal of Computational Physics, 92(2):255–283, 1991. Updated version (2006) at arXiv.org as arXiv:cond-mat/0503627v2. [Mar72] George Marsaglia. Choosing a point from surface of a sphere. Annals of Math. Statistics, 43(2):645–646, 1972. [Mar95] George Marsaglia. Diehard battery of tests of randomness, 1995. stat.fsu.edu/pub/diehard. [Mar97a] Mauricio Marin. Billiards and related systems on the bulk-synchronous parallel model. In 11th Workshop on Parallel and Distributed Simulation, pages 164–171, Lockenhaus, Austria, 1997. IEEE Computer Society. [Mar97b] Mauricio Marin. Event-driven hard-particle molecular dynamics using bulksynchronous parallelism. Computer Physics Communications, 102(1-3):81– 96, 1997. [ML04] S. Miller and Stefan Luding. Event-driven molecular dynamics in parallel. Journal of Computational Physics, 193(1):306–316, 2004. [PD09] Kalyan S. Perumalla and Aleksandar Donev. Perfect reversal of rejection sampling methods for first-passage-time and similar probability distributions. Technical Report TM-2009/182, Oak Ridge National Laboratory, 2009. [PFS05] Matt Pharr, Randima Fernando, and Tim Sweeney. GPU Gems 2: Programming Techniques for High-Performance Graphics and General-Purpose Computation. Addison-Wesley Professional, 2005. [PTVF07] William H. Press, Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery. Numerical Recipes: The Art of Scientific Computing. Cambridge University Press, 2007. 37 [SK10] Jason Sanders and Edwards Kandrot. CUDA by Example: An Introduction to General-Purpose GPU Programming. Addison-Wesley Professional, 2010. [TM80] Clifford Truesdell and R. G. Muncaster. Fundamentals of Maxwell’s Kinetic Theory of a Simple Monatomic Gas. Academic Press, 1980. #### Acknowledgements This paper has been authored by UT-Battelle, LLC, under contract DE-AC05-00OR22725 with the U.S. Department of Energy. Accordingly, the United States Government retains and the publisher, by accepting the article for publication, acknowledges that the United States Government retains a non-exclusive, paid-up, irrevocable, world-wide license to publish or reproduce the published form of this manuscript, or allow others to do so, for United States Government purposes. Research was partly supported by the DOE Early Career Award in Advanced Scientific Computing Research under grant number 3ERKJR12. The authors thank Alfred J. Park, Sudip K. Seal, and James J. Nutaro for constructive comments on early versions of the manuscript, and Alfred J. Park for helping with the implementation for performance estimation. 38

섹션 본문

섹션 본문이 없습니다.

참고문헌

참고문헌 정보가 없습니다.