<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing with OASIS Tables v3.0 20080202//EN" "https://jats.nlm.nih.gov/nlm-dtd/publishing/3.0/journalpub-oasis3.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table" xml:lang="en" dtd-version="3.0" article-type="research-article">
  <front>
    <journal-meta><journal-id journal-id-type="publisher">GMD</journal-id><journal-title-group>
    <journal-title>Geoscientific Model Development</journal-title>
    <abbrev-journal-title abbrev-type="publisher">GMD</abbrev-journal-title><abbrev-journal-title abbrev-type="nlm-ta">Geosci. Model Dev.</abbrev-journal-title>
  </journal-title-group><issn pub-type="epub">1991-9603</issn><publisher>
    <publisher-name>Copernicus Publications</publisher-name>
    <publisher-loc>Göttingen, Germany</publisher-loc>
  </publisher></journal-meta>
    <article-meta>
      <article-id pub-id-type="doi">10.5194/gmd-19-9519-2026</article-id><title-group><article-title>Pysammos 1.0.0: a discrete-to-continuum transformation Python tool to analyse the rheology of granular materials</article-title><alt-title>Pysammos 1.0.0</alt-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author" corresp="yes" rid="aff1">
          <name><surname>Elijas-Parra</surname><given-names>Claudia</given-names></name>
          <email>c.elijas-parra@sms.ed.ac.uk</email>
        </contrib>
        <contrib contrib-type="author" corresp="no" rid="aff1 aff3">
          <name><surname>Breard</surname><given-names>Eric C. P.</given-names></name>
          
        </contrib>
        <contrib contrib-type="author" corresp="no" rid="aff2">
          <name><surname>Morrissey</surname><given-names>John P.</given-names></name>
          
        </contrib>
        <contrib contrib-type="author" corresp="no" rid="aff1 aff3">
          <name><surname>Zrelak</surname><given-names>P. J.</given-names></name>
          
        </contrib>
        <contrib contrib-type="author" corresp="no" rid="aff1">
          <name><surname>Naylor</surname><given-names>Mark</given-names></name>
          
        <ext-link>https://orcid.org/0000-0002-3761-5522</ext-link></contrib>
        <aff id="aff1"><label>1</label><institution>School of Geosciences, The University of Edinburgh, Edinburgh, UK</institution>
        </aff>
        <aff id="aff2"><label>2</label><institution>School of Engineering, The University of Edinburgh, Edinburgh, UK</institution>
        </aff>
        <aff id="aff3"><label>3</label><institution>Department of Earth Sciences, The University of Oregon, Eugene, OR, USA</institution>
        </aff>
      </contrib-group>
      <author-notes><corresp id="corr1">Claudia Elijas-Parra (c.elijas-parra@sms.ed.ac.uk)</corresp></author-notes><pub-date><day>8</day><month>October</month><year>2026</year></pub-date>
      
      <volume>19</volume>
      <issue>19</issue>
      <fpage>9519</fpage><lpage>9553</lpage>
      <history>
        <date date-type="received"><day>5</day><month>May</month><year>2026</year></date>
           <date date-type="rev-request"><day>5</day><month>June</month><year>2026</year></date>
           <date date-type="rev-recd"><day>11</day><month>September</month><year>2026</year></date>
           <date date-type="accepted"><day>15</day><month>September</month><year>2026</year></date>
      </history>
      <permissions>
        <copyright-statement>Copyright: © 2026 Claudia Elijas-Parra et al.</copyright-statement>
        <copyright-year>2026</copyright-year>
      <license license-type="open-access"><license-p>This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this licence, visit <ext-link ext-link-type="uri" xlink:href="https://creativecommons.org/licenses/by/4.0/">https://creativecommons.org/licenses/by/4.0/</ext-link></license-p></license></permissions><self-uri xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026.html">This article is available from https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026.html</self-uri><self-uri xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026.pdf">The full text article is available as a PDF file from https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026.pdf</self-uri>
      <abstract><title>Abstract</title>

      <p id="d2e131">Granular flow processes involving different interstitial fluids and coupling regimes are widespread in both natural systems (e.g., landslides, rock avalanches, river sediment transport) and industrial applications (e.g., aggregates in concrete manufacturing, powder technology, animal feed). Despite this, the behaviour of complex granular flows is not fully understood. Modelling of granular media through software packages that couple the Discrete Element Method with Computational Fluid Dynamics (DEM-CFD) enables a comprehensive description of granular small-scale mechanics through simulations of particle-particle and particle-fluid interactions at high temporal and spatial resolution. These approaches are pivotal in the development of constitutive models that represent the bulk rheology of granular media. While DEM-CFD simulations provide particle-scale information (e.g., particle velocities and forces), extracting continuum fields requires a discrete-to-continuum (D2C) transformation that applies a mathematical approach termed coarse-graining. Although some DEM software packages include built-in D2C capabilities, others, such as MFiX-DEM, do not. Consequently, users are often required to develop custom D2C workflows or adapt simulation outputs to the requirements of other D2C tools. Hence, we introduce Pysammos, a Python package that performs discrete-to-continuum transformations and is designed to be user-friendly, open-source, and computationally efficient. Pysammos is able to process polydisperse granular mixtures of any particle shape, while also offering the option to analyse different particle phases separately. It post-processes output files from MFiX-DEM software and produces vtkhdf outputs ready for visualisation in ParaView, as well as a more generic h5 format for further data analysis. Pysammos is able to operate on standard desktop computers as well as on HPC systems. Finally, we showcase a variety of exemplar applications such as sediment erosion, crystals and magma in a conduit, bedload transport and impact cratering.</p>
  </abstract>
    
<funding-group>
<award-group id="gs1">
<funding-source>Natural Environment Research Council</funding-source>
<award-id>NE/S007407/1</award-id>
<award-id>NE/V014242/1</award-id>
</award-group>
<award-group id="gs2">
<funding-source>Leverhulme Trust</funding-source>
<award-id>LT RPG award - RPG-2024-294</award-id>
</award-group>
<award-group id="gs3">
<funding-source>Royal Society</funding-source>
<award-id>IEC\NSFC\242381</award-id>
<award-id>ECnNSFCn42381</award-id>
</award-group>
</funding-group>
</article-meta>
  </front>
<body>
      

<sec id="Ch1.S1" sec-type="intro">
  <label>1</label><title>Introduction</title>
      <p id="d2e143">Granular media on Earth are two-phase systems comprising a discrete solid phase (i.e., particles) and an interstitial fluid phase (e.g., air, water), in which the solid particles are in contact or near contact <xref ref-type="bibr" rid="bib1.bibx5" id="paren.1"/>. Granular media are widespread in our everyday lives – from pharmaceutical pills, animal feed, cereals, snow, to blood cells suspended in plasma <xref ref-type="bibr" rid="bib1.bibx34" id="paren.2"/>. They are the second-most-handled material by weight in global industry only behind water <xref ref-type="bibr" rid="bib1.bibx18" id="paren.3"/> – e.g., aggregates in concrete manufacturing, mineral and powder processing, crushed oil shale and pebble bed nuclear reactors <xref ref-type="bibr" rid="bib1.bibx69" id="paren.4"/>. They also govern the behaviour of a variety of highly hazardous natural flows – e.g., snow avalanches, debris flows, rock avalanches, landslides and dense pyroclastic density currents – and natural processes that interact with human systems – e.g., bedload transport in rivers and soil creep <xref ref-type="bibr" rid="bib1.bibx8 bib1.bibx27 bib1.bibx53 bib1.bibx52" id="paren.5"/>. Hence, understanding granular media is essential for the resolution of numerous technological and scientific problems. However, the dynamic properties of granular media remain poorly constrained due to their wide-ranging nature <xref ref-type="bibr" rid="bib1.bibx44" id="paren.6"/>.</p>
<sec id="Ch1.S1.SS1">
  <label>1.1</label><title>The complexity of granular flows</title>
      <p id="d2e172">The ongoing search for constitutive relations that unify the multifaceted behaviour of granular media is hindered by the breadth of complex characteristics and phenomenology of these materials. For instance, they encompass a wide distribution of particle sizes, shapes, roughnesses and elasticities, which control their macroscopic dynamic properties. Additionally, the spatial distribution of the properties of the granular medium may change throughout the course of the flow, due to granular segregation – where particles segregate by size, density, shape, and cohesive properties <xref ref-type="bibr" rid="bib1.bibx17" id="paren.7"/> – or particle breakage <xref ref-type="bibr" rid="bib1.bibx75 bib1.bibx11" id="paren.8"/>.</p>
      <p id="d2e181">Furthermore, they also exhibit a strong dependence on the characteristic length scale (i.e., particle size)  <xref ref-type="bibr" rid="bib1.bibx47" id="paren.9"/>. This implies that the role of the microscopic length scale may not vanish at the macroscopic continuum scale, that is, the particle size is of the same order of magnitude as the scale of spatial variation of macroscopic fields <xref ref-type="bibr" rid="bib1.bibx35" id="paren.10"/>.</p>
      <p id="d2e190">Granular flows also show evidence of recording deformation history, implying that a previous deformation episode predisposes the initial conditions of the material <xref ref-type="bibr" rid="bib1.bibx70 bib1.bibx67" id="paren.11"/>. For instance, a high-shear episode to a granular packing with an initially isotropic contact network can induce dilation and preferentially align the force chains. This new fabric alters the initial state for any subsequent deformation, usually providing a higher shear strength relative to the initially isotropic packing.</p>
      <p id="d2e196">The role of the interstitial fluid introduces an additional level of complexity in multiphase granular flows. What is more, the interplay between the solid and fluid phases changes between dilute and dense suspensions <xref ref-type="bibr" rid="bib1.bibx52" id="paren.12"/>. The rheology is particularly challenging to capture in non-colloidal dense suspensions, as classical viscosity laws begin to break down due to the increase in energy dissipation through particle contacts <xref ref-type="bibr" rid="bib1.bibx25 bib1.bibx34" id="paren.13"/>.</p>
      <p id="d2e206">These aspects of granular flows render their continuum representation particularly difficult. Nonetheless, since the surge of computers, modelling of discrete particle systems has been made possible through the Discrete Element Method (DEM). Despite its computational limitation to small scale systems, it is an invaluable tool for simulating complex granular flows without involving any continuum assumptions.</p>
</sec>
<sec id="Ch1.S1.SS2">
  <label>1.2</label><title>Using DEM to study granular flows</title>
      <p id="d2e217">The DEM explicitly applies Newton’s second law of motion to the particle centres and the force displacement law at the contacts, to compute trajectories of individual granular particles from the forces exerted on particles, and vice versa, over time periods in which accelerations are assumed to be constant <xref ref-type="bibr" rid="bib1.bibx16" id="paren.14"/>. Collisions are assumed viscoelastic, conceptualised as a spring-dashpot system – whose components respectively represent the repulsive force and the dissipated kinetic energy –  although other contact models have also been implemented <xref ref-type="bibr" rid="bib1.bibx19" id="paren.15"/>.</p>
      <p id="d2e226">DEM was first developed by <xref ref-type="bibr" rid="bib1.bibx15" id="text.16"/> for a rock mechanics application and was later extended by <xref ref-type="bibr" rid="bib1.bibx16" id="text.17"/> for applications in granular media. Later it began to be applied to molecular dynamics <xref ref-type="bibr" rid="bib1.bibx81" id="paren.18"/>, and soil mechanics <xref ref-type="bibr" rid="bib1.bibx66" id="paren.19"/>. Coupling of DEM with Computational Fluid Dynamics (CFD) began in the early 1990s with <xref ref-type="bibr" rid="bib1.bibx77" id="text.20"/>, widening the range of applications of DEM to the study of multiphase granular flows.</p>
      <p id="d2e244">In recent decades, DEM has become a powerful tool to study numerous natural processes in the field of geosciences:  seismic wave propagation in unconsolidated sediments <xref ref-type="bibr" rid="bib1.bibx60" id="paren.21"/>; impact cratering on granular asteroids <xref ref-type="bibr" rid="bib1.bibx68" id="paren.22"/>; emplacement of igneous intrusions <xref ref-type="bibr" rid="bib1.bibx57" id="paren.23"/>; magma mush dynamics <xref ref-type="bibr" rid="bib1.bibx13" id="paren.24"/>; erosion processes <xref ref-type="bibr" rid="bib1.bibx10" id="paren.25"/>; bedload transport <xref ref-type="bibr" rid="bib1.bibx1" id="paren.26"/>; probing granular flow rheology from the basal force function <xref ref-type="bibr" rid="bib1.bibx91 bib1.bibx92" id="paren.27"/>, and thermal-geomechanical coupling effects in geothermal reservoirs <xref ref-type="bibr" rid="bib1.bibx6" id="paren.28"/>, amongst others.</p>
</sec>
<sec id="Ch1.S1.SS3">
  <label>1.3</label><title>The transition from discrete to continuum</title>
      <p id="d2e280">An essential service of DEM is that of providing the accurate particle dynamics from which we can obtain macroscopic quantities relevant for continuum-mechanical and/or statistical-mechanical formulations of those systems.  The gap between discrete particle data and macroscopic fields may be bridged through discrete-to-continuum (Discrete2Continuum, D2C) transformations, which apply coarse-graining (CG) methods to DEM data to derive bulk quantities  (e.g., stress tensor) projected onto continuum macroscopic fields. CG methods are grounded on the principle that macroscopic fields emerge as averages of microscopic quantities. It is worth noting this use of coarse-graining is distinct from <italic>coarse-grained</italic> DEM, a computational technique in which large populations of small particles are represented by fewer larger surrogate particles (e.g., <xref ref-type="bibr" rid="bib1.bibx45" id="altparen.29"/>). Hereafter, the term “coarse-graining”  will be used specifically to refer to the mathematical methods in D2C transformations.</p>
      <p id="d2e289">Several CG formulations have been developed over the years.  Early formulations were restricted to the quasi-static regime – whereby the inertial terms were neglected in the microscopic balance equations <xref ref-type="bibr" rid="bib1.bibx14" id="paren.30"/> – or to the rapid flow regime – assuming only binary particle collisions <xref ref-type="bibr" rid="bib1.bibx43" id="paren.31"/>. Some of these procedures are still used today to post-process DEM models that represent static systems (e.g., the host rock of a magma intrusion, <xref ref-type="bibr" rid="bib1.bibx57" id="altparen.32"/>). Later, formulations began to include inertial terms <xref ref-type="bibr" rid="bib1.bibx82 bib1.bibx90" id="paren.33"/>, although with incomplete derivations, as <xref ref-type="bibr" rid="bib1.bibx5" id="text.34"/> corroborates.</p>
      <p id="d2e307">However, the earlier averages were carried out within discrete or hard spatial boundaries – i.e., non-differentiable, hence inadequate for the derivation of macroscopic (differential) balance equations.  It is not until <xref ref-type="bibr" rid="bib1.bibx5" id="text.35"/>, that a general averaging approach across granular flow regimes, suitable to obtain average balance equations for multiphase granular media,  is introduced in the literature. The principles used by <xref ref-type="bibr" rid="bib1.bibx5" id="text.36"/> seem to be an adaptation of the almost coetaneous comprehensive derivation of continuum balance equations through spatio-temporal weighted averages in the field of molecular dynamics by <xref ref-type="bibr" rid="bib1.bibx59" id="text.37"/>.</p>
      <p id="d2e319">Ever since <xref ref-type="bibr" rid="bib1.bibx5" id="text.38"/>, CG theory has been honed to simplify the derivations therein <xref ref-type="bibr" rid="bib1.bibx30" id="paren.39"/>, to be valid near to hard boundaries <xref ref-type="bibr" rid="bib1.bibx83" id="paren.40"/>, to address averaging scale dependency <xref ref-type="bibr" rid="bib1.bibx4" id="paren.41"/>, to discuss appropriate spatial averaging resolution <xref ref-type="bibr" rid="bib1.bibx84" id="paren.42"/>, to study the contribution of individual particle phases in polydisperse systems <xref ref-type="bibr" rid="bib1.bibx78" id="paren.43"/>, and to account for contacts between particles of irregular shape <xref ref-type="bibr" rid="bib1.bibx85" id="paren.44"/>.</p>
      <p id="d2e345">Other CG methods exist in the literature, such as binning or the method of planes, however, they lack key advantages of the spatial weighted average. With the CG that performs a spatial weighted average: the macroscopic fields satisfy the average balance of continuum mechanics equations;  the fields can be evaluated at every point in space; and particles are not assumed to be spherical or rigid <xref ref-type="bibr" rid="bib1.bibx79" id="paren.45"/>.</p>
</sec>
<sec id="Ch1.S1.SS4">
  <label>1.4</label><title>Available discrete-to-continuum tools</title>
      <p id="d2e360">Nowadays, there are numerous DEM code packages, both open-source – e.g., LAMMPS <xref ref-type="bibr" rid="bib1.bibx62" id="paren.46"/>, LIGGGHTS <xref ref-type="bibr" rid="bib1.bibx46" id="paren.47"/>, YADE <xref ref-type="bibr" rid="bib1.bibx73" id="paren.48"/>, MercuryDPM <xref ref-type="bibr" rid="bib1.bibx86" id="paren.49"/>, MFiX <xref ref-type="bibr" rid="bib1.bibx74" id="paren.50"/>  –  and closed-source or commercial codes  – e.g., Altair EDEM (Siemens) <xref ref-type="bibr" rid="bib1.bibx2" id="paren.51"/>, PFC <xref ref-type="bibr" rid="bib1.bibx41" id="paren.52"/>, and Iota-Suite (although no longer operational) <xref ref-type="bibr" rid="bib1.bibx58" id="paren.53"/>. Regarding open-source software, some offer an inbuilt D2C transformation, that is the case of LAMMPS, with a standard volume averaging, and MercuryDPM, with a weighted average in their MercuryCG. Others, like MFiX do not provide that post-processing step, which leads users to build their own D2C code or adapt their DEM software outputs to the format other inbuilt D2C software require.  Some of the closed-source software, such as Altair EDEM, also provide their own continuum analysis tools. </p>
</sec>
<sec id="Ch1.S1.SS5">
  <label>1.5</label><title>An overview of Pysammos</title>
      <p id="d2e397">The purpose of this work was to build Pysammos, a Python package designed with the aim of providing a user-friendly D2C workflow to post-process data from the MFiX open-source DEM software, and provide a streamlined visualisation in widely used open-source visualisation software, ParaView (Fig. <xref ref-type="fig" rid="F1"/>). This code package provides flexibility in the output variable selection, mesh parametrisation, and data analysis of the obtained results. The efficient algorithmic complexity exhibited by Pysammos avoids the requirement of extensive computational resources, making it a program that can be run at the same time as other processes. Its modular design enhances DEM analysis across users with varying expertise, as it does not require access to inner-level source code. This is intended to encourage a broader use of DEM in geoscientific research, where many observed processes involving discrete elements are currently modelled as a continuum but could benefit from a discrete insight.</p>

      <fig id="F1" specific-use="star"><label>Figure 1</label><caption><p id="d2e404">Conceptual diagram of the code's main functionality <bold>(c)</bold>, types of input <bold>(a, b)</bold>, and output <bold>(d)</bold>. For further details on output structure and code architecture, see Fig. <xref ref-type="fig" rid="F3"/>. Appendix <xref ref-type="sec" rid="App1.Ch1.S1"/> contains additional information on the configuration file and the specific DEM data required.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f01.png"/>

        </fig>

      <p id="d2e426">The name of the package is a reference to a work by Archimedes called The Sand (Greek: <italic>psammos</italic>) Reckoner, in which he endeavoured to determine the number of grains of sand that could fit in the universe <xref ref-type="bibr" rid="bib1.bibx3" id="paren.54"/>. To do so, he created a new system of large number notation, given that the number system at that time could only express values up to a myriad (10 000). Similarly, Pysammos is concerned with the efficient handling and analysis of a large number of DEM particles. The name of the package thus reflects the shared focus on managing vast quantities of discrete elements, from grains of sand to simulated particles.</p>
      <p id="d2e436">Below we present the coarse-graining mathematical theory implemented in Pysammos; a description of the code workflow, methodologies and features; and a presentation of its performance, benchmarking against other CG codes, and a showcase of examples relevant to the geoscientific community.</p>
</sec>
</sec>
<sec id="Ch1.S2">
  <label>2</label><title>Theory of coarse-graining</title>
      <p id="d2e448">In this section we review the theory of coarse-graining as a spatial weighted average, and the caveats involved in the calculation of some continuum fields. We also discuss the implications of time-averaging and the importance of a suitable smoothing width. Finally, we introduce the framework to calculate the partial contribution of various species within a particulate mixture.</p>
<sec id="Ch1.S2.SS1">
  <label>2.1</label><title>A weighted spatial average</title>
      <p id="d2e458">In this work, we refer to coarse-graining as a generalised weighted averaging approach to compute macroscopic continuum fields from microscopic discrete quantities (e.g., DEM observables: particle velocity and forces), such that they satisfy the average balance of equations for granular media. The contribution of each particle to the macroscopic field evaluated at any given point is weighted according to the relative position of the particle's centre of mass to the point. CG is applicable to a range of flow regimes – from the solid-like quasi-static mode, to the fluid-like rapid flow mode, for granular media of arbitrary particle size, shape and rigidity <xref ref-type="bibr" rid="bib1.bibx5" id="paren.55"/>. The collisions are assumed not to be instantaneous.</p>
      <p id="d2e464">Coarse-graining conceptualises an assembly of discrete solid particles as a system of discrete mass points located at the particle centres, as per the principles of statistical mechanics <xref ref-type="bibr" rid="bib1.bibx5" id="paren.56"/>. Hence, the  microscopic <italic>discrete</italic> mass density field (<inline-formula><mml:math id="M1" display="inline"><mml:mrow><mml:msup><mml:mi mathvariant="italic">ρ</mml:mi><mml:mi mathvariant="normal">discrete</mml:mi></mml:msup></mml:mrow></mml:math></inline-formula>) at a point in space (<inline-formula><mml:math id="M2" display="inline"><mml:mi mathvariant="bold-italic">r</mml:mi></mml:math></inline-formula>) and time (<inline-formula><mml:math id="M3" display="inline"><mml:mi>t</mml:mi></mml:math></inline-formula>) is given by the convolution of the mass (<inline-formula><mml:math id="M4" display="inline"><mml:mrow><mml:msub><mml:mi>m</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>) of particle <inline-formula><mml:math id="M5" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula> (located at <inline-formula><mml:math id="M6" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>) and the Dirac delta function (<inline-formula><mml:math id="M7" display="inline"><mml:mi mathvariant="italic">δ</mml:mi></mml:math></inline-formula>), as shown in Eq. (<xref ref-type="disp-formula" rid="Ch1.E1"/>) <xref ref-type="bibr" rid="bib1.bibx30" id="paren.57"/>. Note that <inline-formula><mml:math id="M8" display="inline"><mml:mi mathvariant="italic">δ</mml:mi></mml:math></inline-formula> is zero everywhere except at the particle centres, where it is infinitely high, and has a total integral of one.

            <disp-formula id="Ch1.E1" content-type="numbered"><label>1</label><mml:math id="M9" display="block"><mml:mrow><mml:msup><mml:mi mathvariant="italic">ρ</mml:mi><mml:mi mathvariant="normal">discrete</mml:mi></mml:msup><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>i</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>N</mml:mi></mml:munderover><mml:msub><mml:mi>m</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mi mathvariant="italic">δ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo></mml:mrow></mml:math></disp-formula>

          Similarly, the macroscopic <italic>continuum</italic> mass density field is obtained by convolving the particle mass with a coarse-graining function, <inline-formula><mml:math id="M10" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula>, as described in Eq. (<xref ref-type="disp-formula" rid="Ch1.E2"/>) <xref ref-type="bibr" rid="bib1.bibx83" id="paren.58"/>.

            <disp-formula id="Ch1.E2" content-type="numbered"><label>2</label><mml:math id="M11" display="block"><mml:mrow><mml:mi mathvariant="italic">ρ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>i</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>N</mml:mi></mml:munderover><mml:msub><mml:mi>m</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo></mml:mrow></mml:math></disp-formula>

          The net effect of <inline-formula><mml:math id="M12" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula> is the smearing of the Dirac delta function of Eq. (<xref ref-type="disp-formula" rid="Ch1.E1"/>) across a volume of  radius <inline-formula><mml:math id="M13" display="inline"><mml:mi>c</mml:mi></mml:math></inline-formula> and effective smoothing width <inline-formula><mml:math id="M14" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula> (see Sect. <xref ref-type="sec" rid="Ch1.S3.SS5.SSS3"/>). Hence, <inline-formula><mml:math id="M15" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula> has dimensions of inverse volume, and the sum of the weights across that volume is <inline-formula><mml:math id="M16" display="inline"><mml:mn mathvariant="normal">1</mml:mn></mml:math></inline-formula> (Eq. <xref ref-type="disp-formula" rid="Ch1.E3"/>) <xref ref-type="bibr" rid="bib1.bibx5" id="paren.59"/>.

            <disp-formula id="Ch1.E3" content-type="numbered"><label>3</label><mml:math id="M17" display="block"><mml:mrow><mml:munder><mml:mo movablelimits="false">∫</mml:mo><mml:mrow><mml:msup><mml:mi mathvariant="double-struck">R</mml:mi><mml:mi mathvariant="normal">D</mml:mi></mml:msup></mml:mrow></mml:munder><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>)</mml:mo><mml:mi mathvariant="normal">d</mml:mi><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:math></disp-formula>

          Hence, by performing a spatial weighted average, the contribution of several particles is taken into account in the evaluation of a macroscopic continuum field at a given point in space. In order for the macroscopic fields to satisfy the continuum balance of equations, they must be smooth across space. This requires the coarse-graining function <inline-formula><mml:math id="M18" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula> to be differentiable everywhere. Several weighting functions are commonly seen in the literature: the Lucy polynomial function <xref ref-type="bibr" rid="bib1.bibx54" id="paren.60"/>, the Heaviside step function, and the cut-off Gaussian function (see Sect. <xref ref-type="sec" rid="Ch1.S3.SS5.SSS3"/>).</p>
</sec>
<sec id="Ch1.S2.SS2">
  <label>2.2</label><title>Averaging the interaction between particles</title>
      <p id="d2e782">Continuum fields that correspond to a quantity representing the interaction between two particles are evaluated differently: by distributing the field along the branch vector connecting the two particles <xref ref-type="bibr" rid="bib1.bibx5" id="paren.61"/>. The stress tensor is defined as the sum of the contact stress tensor (<inline-formula><mml:math id="M19" display="inline"><mml:mrow><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>c</mml:mi></mml:msup></mml:mrow></mml:math></inline-formula>) and the kinetic stress tensor (<inline-formula><mml:math id="M20" display="inline"><mml:mrow><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>k</mml:mi></mml:msup></mml:mrow></mml:math></inline-formula>), as shown in Eq. (<xref ref-type="disp-formula" rid="Ch1.E4"/>) <xref ref-type="bibr" rid="bib1.bibx5" id="paren.62"/>.

            <disp-formula id="Ch1.E4" content-type="numbered"><label>4</label><mml:math id="M21" display="block"><mml:mrow><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>c</mml:mi></mml:msup><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>+</mml:mo><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>k</mml:mi></mml:msup><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></disp-formula>

          The contact stress tensor is defined in Eq. (<xref ref-type="disp-formula" rid="Ch1.E5"/>).

            <disp-formula id="Ch1.E5" content-type="numbered"><label>5</label><mml:math id="M22" display="block"><mml:mrow><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>c</mml:mi></mml:msup><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>i</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>N</mml:mi></mml:munderover><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>j</mml:mi><mml:mo>=</mml:mo><mml:mi>i</mml:mi><mml:mo>+</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>N</mml:mi></mml:munderover><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>k</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mrow><mml:msub><mml:mi>C</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:munderover><mml:msubsup><mml:mi mathvariant="bold-italic">f</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow><mml:mi>k</mml:mi></mml:msubsup><mml:mo>⊗</mml:mo><mml:msubsup><mml:mi mathvariant="bold-italic">a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow><mml:mi>k</mml:mi></mml:msubsup><mml:munderover><mml:mo movablelimits="false">∫</mml:mo><mml:mn mathvariant="normal">0</mml:mn><mml:mn mathvariant="normal">1</mml:mn></mml:munderover><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>+</mml:mo><mml:mi>s</mml:mi><mml:msubsup><mml:mi mathvariant="bold-italic">a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow><mml:mi>k</mml:mi></mml:msubsup><mml:mo>)</mml:mo><mml:mi mathvariant="normal">d</mml:mi><mml:mi>s</mml:mi><mml:mo>,</mml:mo></mml:mrow></mml:math></disp-formula>

          where <inline-formula><mml:math id="M23" display="inline"><mml:mi>N</mml:mi></mml:math></inline-formula> is the number of particles in the system, and <inline-formula><mml:math id="M24" display="inline"><mml:mrow><mml:msub><mml:mi>C</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula> is the maximum number of contact points between two particles. The force between the particles <inline-formula><mml:math id="M25" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M26" display="inline"><mml:mi>j</mml:mi></mml:math></inline-formula> at the <inline-formula><mml:math id="M27" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>th contact point is represented as <inline-formula><mml:math id="M28" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">f</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow><mml:mi>k</mml:mi></mml:msubsup></mml:mrow></mml:math></inline-formula>. The branch vector <inline-formula><mml:math id="M29" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow><mml:mi>k</mml:mi></mml:msubsup></mml:mrow></mml:math></inline-formula> is defined as the distance between the <inline-formula><mml:math id="M30" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>th contact point and the centre of particle <inline-formula><mml:math id="M31" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula>. The dummy variable <inline-formula><mml:math id="M32" display="inline"><mml:mi>s</mml:mi></mml:math></inline-formula> parametrises the line segment from particle <inline-formula><mml:math id="M33" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula> to a contact point. The integral of the CG function <inline-formula><mml:math id="M34" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula> over the projection of <inline-formula><mml:math id="M35" display="inline"><mml:mi>s</mml:mi></mml:math></inline-formula> on <inline-formula><mml:math id="M36" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow><mml:mi>k</mml:mi></mml:msubsup></mml:mrow></mml:math></inline-formula>, enables the contact force to be spatially distributed along the branch vector, ensuring a smooth representation of the contact stress (Fig. <xref ref-type="fig" rid="F2"/>).  Note that  Eq. (<xref ref-type="disp-formula" rid="Ch1.E5"/>) does not account for wall-particle interactions; this extension is discussed in detail in <xref ref-type="bibr" rid="bib1.bibx83" id="text.63"/>.</p>

      <fig id="F2"><label>Figure 2</label><caption><p id="d2e1151">Vectors involved in the calculation of the contact stress tensor over one particle. In panel <bold>(a)</bold>,  <inline-formula><mml:math id="M37" display="inline"><mml:mi mathvariant="bold-italic">r</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M38" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> represent the positions of the grid point (yellow) at which the coarse-grained fields are evaluated, and the centre of mass of particle <inline-formula><mml:math id="M39" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula> (black), respectively. The branch vector <inline-formula><mml:math id="M40" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula>, connects <inline-formula><mml:math id="M41" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> and the contact point between the two particles. The displacement vector from particle <inline-formula><mml:math id="M42" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula> and the grid point is denoted by <inline-formula><mml:math id="M43" display="inline"><mml:mrow><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>. The force acting on particle <inline-formula><mml:math id="M44" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula> resulting from the collision with particle <inline-formula><mml:math id="M45" display="inline"><mml:mi>j</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M46" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">f</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula>, is represented by the brown vector. Panel <bold>(b)</bold> illustrates the integration of the weighting function <inline-formula><mml:math id="M47" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula> (evaluated at <inline-formula><mml:math id="M48" display="inline"><mml:mrow><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>) along a stepwise projection of <inline-formula><mml:math id="M49" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula> (Eq. <xref ref-type="disp-formula" rid="Ch1.E5"/>). The scalar <inline-formula><mml:math id="M50" display="inline"><mml:mi>s</mml:mi></mml:math></inline-formula> parametrises the line segment corresponding to <inline-formula><mml:math id="M51" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula>. Hence, the integral of <inline-formula><mml:math id="M52" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula> over its projection onto <inline-formula><mml:math id="M53" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula> spatially distributes the collisional force along the branch vector, providing a smooth representation of the contact stress.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f02.png"/>

        </fig>


</sec>
<sec id="Ch1.S2.SS3">
  <label>2.3</label><title>The influence of velocity gradients</title>
      <p id="d2e1359">The coarse-grained velocity field may be distinguished from individual particle velocities, which generally exhibit higher velocities than the macroscopic field. The difference between these two velocities is referred to as the fluctuation  velocity of the particle. To prevent it from vanishing to zero, it is represented by its magnitude <xref ref-type="bibr" rid="bib1.bibx32" id="paren.64"/>.</p>
      <p id="d2e1365">The kinetic stress tensor, calculated with the fluctuation velocity (Eq. <xref ref-type="disp-formula" rid="Ch1.E6"/>), has been shown to depend on averaging width <xref ref-type="bibr" rid="bib1.bibx30 bib1.bibx4 bib1.bibx85" id="paren.65"/>.

            <disp-formula id="Ch1.E6" content-type="numbered"><label>6</label><mml:math id="M54" display="block"><mml:mrow><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>k</mml:mi></mml:msup><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>i</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>N</mml:mi></mml:munderover><mml:msub><mml:mi>m</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>′</mml:mo></mml:msubsup><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>′</mml:mo></mml:msubsup><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo><mml:mo>,</mml:mo></mml:mrow></mml:math></disp-formula>

          The scale dependency arises from the fact that in Eq. (<xref ref-type="disp-formula" rid="Ch1.E6"/>) the fluctuation velocity,  <inline-formula><mml:math id="M55" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>′</mml:mo></mml:msubsup></mml:mrow></mml:math></inline-formula> (Eq. <xref ref-type="disp-formula" rid="Ch1.E7"/>), is defined with respect to the field velocity at <inline-formula><mml:math id="M56" display="inline"><mml:mi mathvariant="bold-italic">r</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M57" display="inline"><mml:mrow><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>, and not at the position of the particle's centre of mass, <inline-formula><mml:math id="M58" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>, i.e. <inline-formula><mml:math id="M59" display="inline"><mml:mrow><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>, in order to satisfy the continuum balance of equations at <inline-formula><mml:math id="M60" display="inline"><mml:mi mathvariant="bold-italic">r</mml:mi></mml:math></inline-formula> <xref ref-type="bibr" rid="bib1.bibx30" id="paren.66"/>. Nevertheless, <inline-formula><mml:math id="M61" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>′</mml:mo></mml:msubsup></mml:mrow></mml:math></inline-formula> can be decomposed into two terms in order to isolate the scale dependency of  <inline-formula><mml:math id="M62" display="inline"><mml:mrow><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>k</mml:mi></mml:msup></mml:mrow></mml:math></inline-formula>, as shown below.

            <disp-formula id="Ch1.E7" content-type="numbered"><label>7</label><mml:math id="M63" display="block"><mml:mtable class="aligned" rowspacing="0.2ex" columnspacing="1em" displaystyle="true" columnalign="right left"><mml:mtr><mml:mtd><mml:mrow><mml:mstyle class="stylechange" displaystyle="true"/><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>′</mml:mo></mml:msubsup></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mstyle displaystyle="true" class="stylechange"/><mml:mo>=</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">v</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>-</mml:mo><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mstyle displaystyle="true" class="stylechange"/></mml:mtd><mml:mtd><mml:mrow><mml:mstyle displaystyle="true" class="stylechange"/><mml:mo>=</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">v</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>-</mml:mo><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>+</mml:mo><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>-</mml:mo><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mstyle displaystyle="true" class="stylechange"/></mml:mtd><mml:mtd><mml:mrow><mml:mstyle class="stylechange" displaystyle="true"/><mml:mo>=</mml:mo><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>*</mml:mo></mml:msubsup><mml:mo>+</mml:mo><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>-</mml:mo><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>,</mml:mo></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>

          where   <inline-formula><mml:math id="M64" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">v</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> is the velocity of the <inline-formula><mml:math id="M65" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula>th particle at time <inline-formula><mml:math id="M66" display="inline"><mml:mi>t</mml:mi></mml:math></inline-formula>, and <inline-formula><mml:math id="M67" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>*</mml:mo></mml:msubsup></mml:mrow></mml:math></inline-formula> is the fluctuation velocity field evaluated at the particle's centre of mass, <inline-formula><mml:math id="M68" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>. The latter terms of <inline-formula><mml:math id="M69" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>′</mml:mo></mml:msubsup></mml:mrow></mml:math></inline-formula> capture the scale dependency due to velocity gradients. In the absence of these gradients, the scale dependency vanishes, and the fluctuation velocity simplifies to <inline-formula><mml:math id="M70" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>′</mml:mo></mml:msubsup><mml:mo>=</mml:mo><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>*</mml:mo></mml:msubsup></mml:mrow></mml:math></inline-formula>.  Alternatively, <xref ref-type="bibr" rid="bib1.bibx84" id="text.67"/> propose an a posteriori correction to obtain the scale-independent term of the kinetic tensor, thus bypassing the evaluation of the fluctuation velocity at <inline-formula><mml:math id="M71" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> by means of interpolation.</p>
      <p id="d2e1879">Nonetheless, the granular temperature is a measure that focuses solely on the local particle fluctuations, at <inline-formula><mml:math id="M72" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>. Hence, only the scale-independent part of  <inline-formula><mml:math id="M73" display="inline"><mml:mrow><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>k</mml:mi></mml:msup></mml:mrow></mml:math></inline-formula> is used to compute granular temperature (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E25"/> in Appendix <xref ref-type="sec" rid="App1.Ch1.S3.SS2"/>).</p>
</sec>
<sec id="Ch1.S2.SS4">
  <label>2.4</label><title>Time averaging</title>
      <p id="d2e1917">Traditional statistical mechanics considers multiple realisations, or probabilistic copies of a system, over which the corresponding macroscopic quantities are averaged <xref ref-type="bibr" rid="bib1.bibx42" id="paren.68"/>. This conceptual tool is equivalent to averaging over the total time range, an equivalence classically derived for ergodic systems in equilibrium <xref ref-type="bibr" rid="bib1.bibx39" id="paren.69"/>,  but which extends to systems at (non-equilibrium) steady state, where the relevant statistics are stationary in time <xref ref-type="bibr" rid="bib1.bibx5" id="paren.70"/>. This is advantageous for systems that are complex to simulate over large time scales. In the case of granular media we are able to simulate complex granular systems for longer time scales with DEM. Hence, in the field of computational granular physics, ensemble averaging is not required <xref ref-type="bibr" rid="bib1.bibx30" id="paren.71"/>, and in fact could be problematic due to the inherent lack of scale separation.  Instead, the analytical expressions for continuum fields tend to include a time-averaging, as well as a space-averaging, which acts as a low-pass filter on the inherent fluctuations of granular flows, to obtain steady-state solutions <xref ref-type="bibr" rid="bib1.bibx5 bib1.bibx30" id="paren.72"/>. Nevertheless, the time averaging is not strictly required, and in fact, even moving window Heaviside temporal averages could obscure time-dependent trends in highly transient flows, as pointed out by <xref ref-type="bibr" rid="bib1.bibx83" id="text.73"/>. Hence, in this study only spatial averaging is considered for the analytical equations of coarse-graining.</p>
</sec>
<sec id="Ch1.S2.SS5">
  <label>2.5</label><title>Smoothing width</title>
      <p id="d2e1947">The choice of averaging width <inline-formula><mml:math id="M74" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula>, i.e., the resolution of the continuum fields resulting from CG, has been shown to be non-trivial. <xref ref-type="bibr" rid="bib1.bibx5" id="text.74"/> proposes that the averaging should be computed over a representative volume, which is a region where no gradients occur, calling this the “continuum assumption”. In particular, the macroscopic kinetic tensor field has been shown to intrinsically depend on the square of the smoothing width <xref ref-type="bibr" rid="bib1.bibx30" id="paren.75"/>.  <xref ref-type="bibr" rid="bib1.bibx84" id="text.76"/> find two apparent CG length scales for which the coarse-grained macroscopic fields are almost independent of the averaging width: one at sub-particle scale, which is able to resolve flow layers close to the lower boundary of the modelled inclined flow, and one at particle scale, which yields smooth continuum fields.</p>
</sec>
<sec id="Ch1.S2.SS6">
  <label>2.6</label><title>Mixture theory</title>
      <p id="d2e1974">To evaluate the partial contribution of various species, or phases, within a particulate mixture, we make use of mixture theory. It conceptualises the granular mixture to be simultaneously populated by all phases, with associated partial macroscopic fields <xref ref-type="bibr" rid="bib1.bibx79" id="paren.77"/>. The macroscopic fields of the mixture are hence obtained by superposing (i.e., summing) the partial fields (Eq. <xref ref-type="disp-formula" rid="Ch1.E8"/>).

            <disp-formula id="Ch1.E8" content-type="numbered"><label>8</label><mml:math id="M75" display="block"><mml:mrow><mml:mi mathvariant="script">F</mml:mi><mml:mo>=</mml:mo><mml:munder><mml:mo movablelimits="false">∑</mml:mo><mml:mi mathvariant="italic">ν</mml:mi></mml:munder><mml:msup><mml:mi mathvariant="script">F</mml:mi><mml:mi mathvariant="italic">ν</mml:mi></mml:msup></mml:mrow></mml:math></disp-formula>

          A phase can be defined as any particle property, or combination of such, that contributes to particle segregation, that is, density, size, shape, elasticity, roughness  <xref ref-type="bibr" rid="bib1.bibx79" id="paren.78"/>.</p>
</sec>
</sec>
<sec id="Ch1.S3">
  <label>3</label><title>Methodology: code structure and algorithm steps</title>
      <p id="d2e2014">This section firstly describes how the architecture has been designed to facilitate maintenance, and to cater for the performance considerations inherent to DEM data processing. Subsequently, it provides a description of the input DEM data, and an overview of the algorithm steps of the CG workflow embedded and handled from the user-facing class.</p>
<sec id="Ch1.S3.SS1">
  <label>3.1</label><title>Software design</title>
      <p id="d2e2024">The architecture of Pysammos is designed to be modular, dividing cumbersome code into smaller manageable tasks, to enhance readability, and to allow reusability and easy maintenance. Code modularisation in Python takes on the form of packages, modules and functions, thus building a hierarchical structure of code (Fig. <xref ref-type="fig" rid="F3"/>). This is further aided by a hybrid implementation, combining object oriented programming (OOP) and functional programming (FP) approaches to optimise readability and maintainability. OOP provides a clear structural interface for encapsulating underlying computations, while FP is suitable for small reusable operations within or alongside OOP.  The core code makes use of widely used scientific Python packages, such as NumPy <xref ref-type="bibr" rid="bib1.bibx36" id="paren.79"/>, SciPy <xref ref-type="bibr" rid="bib1.bibx80" id="paren.80"/>, VTK <xref ref-type="bibr" rid="bib1.bibx71 bib1.bibx65" id="paren.81"/>, XArray <xref ref-type="bibr" rid="bib1.bibx38" id="paren.82"/> and Numba <xref ref-type="bibr" rid="bib1.bibx48" id="paren.83"/>.</p>

      <fig id="F3" specific-use="star"><label>Figure 3</label><caption><p id="d2e2047">Conceptual schematic of the code architecture of the user-interface class CoarseGraining, defined in the main Pysammos module coarse_graining <bold>(a)</bold>. The diagram illustrates the workflow structure of the class (green panels 1–3) and links each step to the corresponding source code in the relevant sub-packages <bold>(b)</bold> via red lines. Bold monospace text denotes class functions, while non-bold monospace text indicates the fully qualified module paths executed by each function. Function outputs and stored attributes are shown in normal and italic text, respectively. Panel 3 presents the computation of continuum fields across time steps as a flowchart, with each step corresponding to a hidden class method and further detailed in panels <bold>(e)</bold>–<bold>(g)</bold>. The format and purpose of inputs and outputs are shown in panels <bold>(c)</bold> and <bold>(d)</bold>.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f03.png"/>

        </fig>

<sec id="Ch1.S3.SS1.SSS1">
  <label>3.1.1</label><title>User-facing class</title>
      <p id="d2e2082">The <monospace>CoarseGraining</monospace> class acts as the user-facing interface. The steps of the coarse-graining workflow correspond to the different class methods, which in turn orchestrate lower-level functions. Methods of the user-facing class may be grouped into three categories according to the CG workflow: (1) inspection of model data, (2) generation of continuum mesh, (3) computation of continuum fields at each time step (Fig. <xref ref-type="fig" rid="F3"/>a). The class builds up its internal state sequentially, as task-oriented methods are called successively in the correct order, accumulating attributes in a pipeline style which subsequent methods rely on. While reducing boilerplate code, the sequential format suits the inherent progressive logic of the CG workflow, allowing a straightforward, readable and flexible interface flow for the user. Dependency fault tolerance, especially in the user interface class attributes, is implemented by checking that those attributes are stored as instance attributes before executing a method with dependencies <xref ref-type="bibr" rid="bib1.bibx40" id="paren.84"/>. The inputs to this class, provided in the configuration file (Appendix <xref ref-type="sec" rid="App1.Ch1.S1"/>), are stored as instance attributes and can be accessed throughout the lifetime of the object.</p>
</sec>
<sec id="Ch1.S3.SS1.SSS2">
  <label>3.1.2</label><title>Performance optimisation</title>
      <p id="d2e2104">In addition to ensuring readability and maintainability, the structural design described above was driven by performance considerations inherent to DEM data processing. Typical DEM simulations may consist of <inline-formula><mml:math id="M76" display="inline"><mml:mrow><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">4</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula>–<inline-formula><mml:math id="M77" display="inline"><mml:mrow><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">6</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula> particles and <inline-formula><mml:math id="M78" display="inline"><mml:mrow><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula>–<inline-formula><mml:math id="M79" display="inline"><mml:mrow><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">3</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula> time steps, but it is not uncommon to have <inline-formula><mml:math id="M80" display="inline"><mml:mrow><mml:mo>&gt;</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">4</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula> time steps in long duration high data save frequency simulations with a low number of particles. The computational cost of the code is dominated by data handling rather than individual numerical operations. The scalability of the execution gives rise to bottlenecks that limit efficiency due to memory bandwidth rather than raw CPU performance. Code performance was thus enhanced by tackling bottlenecks identified in the resource usage analysis, employing algorithmic optimisation or the Numba Python compiler. Each bottleneck was addressed with a unique strategy that suited that particular operation (Appendix <xref ref-type="sec" rid="App1.Ch1.S5"/>). </p>
</sec>
<sec id="Ch1.S3.SS1.SSS3">
  <label>3.1.3</label><title>User profiles</title>
      <p id="d2e2176">The modularity of the code's architecture suitably separates code levels linked to different user profiles. The standard user only employs the user-facing class, modifying the inputs in the configuration file, and analyses data as suggested in the documentation examples. The advanced user might make changes to variables of the user-facing class that have been set to a specific value by default, and analyse the data differently for a more specialised application. The developer user makes modifications to low-level functions in the sub-packages, and is provided with benchmarked examples to ensure consistency and robustness in future developments required to keep Pysammos relevant in the DEM community. The principal communication channel for the developer users is intended to be GitHub, as it facilitates tracking code issues and development of new implementations. It also provides a space where any type of user can open discussions about code development suggestions or experiences with code issues via GitHub's issue tracker.</p>
      <p id="d2e2179">Below, we introduce the principal steps of the coarse-graining workflow as implemented in the <monospace>CoarseGraining</monospace> class. Each subsection corresponds to a major stage of the algorithmic pipeline presented in Fig. <xref ref-type="fig" rid="F3"/>, highlighting both the functional role of each step, and the considerations associated with the design and performance of the code.</p>
</sec>
</sec>
<sec id="Ch1.S3.SS2">
  <label>3.2</label><title>Input DEM data</title>
      <p id="d2e2196">The paths to the DEM data files and the corresponding variable names are supplied by the user either through the configuration file (Appendix <xref ref-type="sec" rid="App1.Ch1.S1"/>), or directly to the user-facing <monospace>CoarseGraining</monospace> class.</p>
      <p id="d2e2204">The input DEM data required for Pysammos consist of particle data and contact data, which are stored in separate files. The particle data include particle position, particle ID, velocity, diameter (or radius), density, volume, mass, and optionally coordination number. The contact data include the particle IDs of the two particles involved in each recorded contact, the force acting on the first particle, and the contact point position. If contact point positions are unavailable (e.g., when using earlier MFiX releases), Pysammos can recalculate them for spherical particles.</p>
      <p id="d2e2207">MFiX records single-sided contacts, providing the force vector acting on the first particle, and the contact point position. Since the contact point position is explicitly available, reconstruction of the full bidirectional contact list is valid regardless of particle size distribution – the branch vectors (<inline-formula><mml:math id="M81" display="inline"><mml:mrow><mml:msub><mml:mi>a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula> in Eq. <xref ref-type="disp-formula" rid="Ch1.E5"/>) are computed directly from particle centre positions and the contact point, rather than being inferred from particle geometry. The reconstruction procedure is described in Sect. <xref ref-type="sec" rid="Ch1.S3.SS5.SSS1"/> and the Appendices referenced therein. </p>
</sec>
<sec id="Ch1.S3.SS3">
  <label>3.3</label><title>Data inspection stage</title>
      <p id="d2e2237">The data inspection consists of obtaining relevant information on the provided DEM data that will be used later on in the program to apply safety checks or perform calculations (Fig. <xref ref-type="fig" rid="F3"/>a, panel 1). Likewise, it also provides the user with a particle-size overview. It starts with the <monospace>.data_sampling()</monospace> method, which loads and inspects the particle data at the first time step that the user has chosen to process, thus obtaining arrays of particle diameter, mass, density and the bounds of particle positions – i.e., the extent of the model to be post-processed at the first chosen time step. These particle data are analysed in <monospace>.get_particle_size_statistics()</monospace> to get the median, root-mean-squared and maximum size, and area- and volume-weighted average particle size or diameter.</p>
<sec id="Ch1.S3.SS3.SSS1">
  <label>3.3.1</label><title>Phase detection algorithm</title>
      <p id="d2e2255">The DEM data are also analysed in  <monospace>.get_particle_phases()</monospace> with the purpose of classifying the particles into phases, should the user require macroscopic fields of each particle phase. Here, a phase is defined by particle diameter and density (Fig. <xref ref-type="fig" rid="F4"/>a, b), since they are two properties related to the two main competing mechanisms in segregation: kinetic sieving and buoyancy <xref ref-type="bibr" rid="bib1.bibx20 bib1.bibx76" id="paren.85"/>.  Phase detection is fully automated in the current version (1.0.0); the user does not specify phase definitions or characteristics.  In Pysammos the phase detection is carried out by clustering particle data using the <inline-formula><mml:math id="M82" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-means algorithm, explained in detail in Appendix <xref ref-type="sec" rid="App1.Ch1.S2.SS1"/>. The optimum number of clusters is chosen to be that with the absolute maximum in silhouette value, a measure for how well each point matches its assigned cluster relative to the nearest neighbouring cluster (Appendix <xref ref-type="sec" rid="App1.Ch1.S2.SS1"/>), as shown in Fig. <xref ref-type="fig" rid="F4"/>e. Afterwards, the <inline-formula><mml:math id="M83" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-means algorithm is applied to the dataset with the optimum number of clusters (Fig. <xref ref-type="fig" rid="F4"/>d) to obtain the phase-ascribed arrays, which are stored as attributes of the class instance.</p>

      <fig id="F4" specific-use="star"><label>Figure 4</label><caption><p id="d2e2291">Illustration of the approach to detect particle phases. Synthetic data set of a bimodal particle diameter distribution <bold>(a)</bold>. Synthetic data set of a bimodal particle density distribution <bold>(b)</bold>. Cross-plot corresponding to the diameter and density distributions in <bold>(a)</bold> and <bold>(b)</bold>, respectively <bold>(c)</bold>. Cross-plot containing the same particle samples as <bold>(c)</bold> coloured by the phase they are classified to according to the <inline-formula><mml:math id="M84" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-means algorithm using the optimum number of clusters <bold>(d)</bold>. Silhouette score for a given number of clusters employed in the <inline-formula><mml:math id="M85" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-means algorithm (grey), and the corresponding second derivative (black) <bold>(e)</bold>. The absolute maximum in <bold>(e)</bold> is chosen to be the optimum number of clusters (dashed red).</p></caption>
            <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f04.png"/>

          </fig>

</sec>
</sec>
<sec id="Ch1.S3.SS4">
  <label>3.4</label><title>Mesh generation stage</title>
      <p id="d2e2352">The mesh is created with a resolution <inline-formula><mml:math id="M86" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula> (Eq. <xref ref-type="disp-formula" rid="Ch1.E9"/>) specified in <monospace>.set_resolution()</monospace>. It is calculated as <inline-formula><mml:math id="M87" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>=</mml:mo><mml:msub><mml:mi>m</mml:mi><mml:mi>w</mml:mi></mml:msub><mml:mover accent="true"><mml:mi>d</mml:mi><mml:mo mathvariant="normal">¯</mml:mo></mml:mover></mml:mrow></mml:math></inline-formula>, where <inline-formula><mml:math id="M88" display="inline"><mml:mrow><mml:msub><mml:mi>m</mml:mi><mml:mi>w</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is a scaling and <inline-formula><mml:math id="M89" display="inline"><mml:mover accent="true"><mml:mi>d</mml:mi><mml:mo mathvariant="normal">¯</mml:mo></mml:mover></mml:math></inline-formula> is a representative particle size.  By default, <inline-formula><mml:math id="M90" display="inline"><mml:mrow><mml:msub><mml:mi>m</mml:mi><mml:mi>w</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>  is 0.75 <xref ref-type="bibr" rid="bib1.bibx85" id="paren.86"/>.  In polydisperse granular media the choice of <inline-formula><mml:math id="M91" display="inline"><mml:mover accent="true"><mml:mi>d</mml:mi><mml:mo mathvariant="normal">¯</mml:mo></mml:mover></mml:math></inline-formula> is not trivial <xref ref-type="bibr" rid="bib1.bibx63" id="paren.87"/>, hence, we provide different metrics for the user to choose from, such as the median diameter or <inline-formula><mml:math id="M92" display="inline"><mml:mrow><mml:msub><mml:mi>d</mml:mi><mml:mn mathvariant="normal">50</mml:mn></mml:msub></mml:mrow></mml:math></inline-formula>, the root mean squared diameter (<inline-formula><mml:math id="M93" display="inline"><mml:mrow><mml:msub><mml:mi>d</mml:mi><mml:mi mathvariant="normal">rms</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>), volume-weighted average (<inline-formula><mml:math id="M94" display="inline"><mml:mrow><mml:msub><mml:mi>d</mml:mi><mml:mn mathvariant="normal">43</mml:mn></mml:msub></mml:mrow></mml:math></inline-formula>) and area-weighted average or Sauter diameter (<inline-formula><mml:math id="M95" display="inline"><mml:mrow><mml:msub><mml:mi>d</mml:mi><mml:mn mathvariant="normal">32</mml:mn></mml:msub></mml:mrow></mml:math></inline-formula>).</p>
      <p id="d2e2481">The mesh domain can be user-defined or automatically determined from the model bounds. In the latter case, the mesh spans the extent of the model while leaving a safety margin to the boundaries proportional to the maximum grain size and averaging scale. In the case of 1D or 2D automatically generated meshes, the domain is reduced along one direction by taking a central transect perpendicular to that dimension.</p>
      <p id="d2e2484">The method <monospace>.generate_grid()</monospace> generates a structured grid with the specified spacing. Currently only a simple regular cuboid grid is available. Nevertheless, the code structure allows the additional implementation of new mesh types. Note that in this work, <italic>mesh</italic> refers to a general discretisation of space, while <italic>grid</italic> refers to the current structured Cartesian implementation.</p>
</sec>
<sec id="Ch1.S3.SS5">
  <label>3.5</label><title>Coarse-graining stage</title>
      <p id="d2e2504">The calculation of continuum fields across all time steps is encapsulated in <monospace>.fields_in_time()</monospace>. It makes use of hidden methods of the class, prefixed with an underscore, to organise internal logic and condense recurring functionality. For each time step processed, the data are loaded, the continuum fields are calculated, and output files are written (Fig. <xref ref-type="fig" rid="F3"/>e–g). The field evaluation is broken down into particle and grid point association, weight computation, and the computation of the different fields (Fig. <xref ref-type="fig" rid="F3"/>f).</p>
<sec id="Ch1.S3.SS5.SSS1">
  <label>3.5.1</label><title>Data reading and handling</title>
      <p id="d2e2521">The particle and contact data described in Sect. <xref ref-type="sec" rid="Ch1.S3.SS2"/> are retrieved from the MFiX <monospace>.vtp</monospace> file using the variable names specified in the configuration file (Appendix <xref ref-type="sec" rid="App1.Ch1.S1"/>).</p>
      <p id="d2e2531">Regarding contact data, Pysammos reconstructs the full bidirectional contact list by duplicating each particle pair, applying the opposite force to the second particle, and assigning the same contact point to both entries. For concave particles, multiple contact points between the same particle pair are explicitly reported and are handled as distinct contacts in our analysis. For convex particles, in contrast, the contact is represented by a single point at the centre of the overlapping volume.</p>
      <p id="d2e2534">Several data mapping structures and algorithms are used in the pre-processing stage prior to applying CG. Following the data ingestion, DEM data are sorted by particle ID, facilitating the mapping of contact data onto the global particle data (Appendix <xref ref-type="sec" rid="App1.Ch1.S4.SS1"/>), so that branch vectors between particle pairs can be computed. Subsequently, pre-processing steps are applied to ensure data quality, including the identification and removal of duplicated contacts written during parallel execution (Appendix <xref ref-type="sec" rid="App1.Ch1.S4.SS3"/>). During branch vector computation, periodic boundaries are accounted for by evaluating displacements to the nearest periodic equivalent (Appendix <xref ref-type="sec" rid="App1.Ch1.S4.SS2"/>).</p>
</sec>
<sec id="Ch1.S3.SS5.SSS2">
  <label>3.5.2</label><title>Particle search</title>
      <p id="d2e2551">Continuum macroscopic fields consist of the spatial weighted average of microscopic particle quantities within a finite volume around any point in space (Fig. <xref ref-type="fig" rid="F5"/>). The particles within this volume are identified based on the distances between particle centres and grid points, using a <inline-formula><mml:math id="M96" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-<inline-formula><mml:math id="M97" display="inline"><mml:mi>d</mml:mi></mml:math></inline-formula> tree–based nearest-neighbour search, which efficiently identifies, for all grid points in a single query, the particle centres within a cut-off distance of each point (Appendix <xref ref-type="sec" rid="App1.Ch1.S2.SS2"/>). The code subsequently organises this information into a compact array-based format optimised for performance and robustness (Appendix <xref ref-type="sec" rid="App1.Ch1.S4.SS4"/>). To improve computational efficiency, the search is performed only once every time step, and the resulting neighbour information is employed in all subsequent calculations of fields involving either individual particles or interparticle interactions.</p>

      <fig id="F5"><label>Figure 5</label><caption><p id="d2e2576">Visualisation of particle-to-node association. This plot displays an <inline-formula><mml:math id="M98" display="inline"><mml:mrow><mml:mi>x</mml:mi><mml:mi>y</mml:mi></mml:mrow></mml:math></inline-formula>-plane projection of a synthetic set of particle positions in 3D (blue dots) within the framework of a regular grid (crosses). The particles associated with the grey grid point (red dots) are those within the cut-off volume (grey circle). The size of the dots is not informative of the size of the particles. For the sake of simplicity, no units are provided.</p></caption>
            <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f05.png"/>

          </fig>

</sec>
<sec id="Ch1.S3.SS5.SSS3">
  <label>3.5.3</label><title>Weight calculation</title>
      <p id="d2e2603">The macroscopic continuum fields result from convolution of a microscopic discrete field with a CG (smoothing) function, <inline-formula><mml:math id="M99" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula>, over the model space, thus performing a spatial weighted average of particle quantities. The smoothing function is defined by two parameters: the spatial domain, <inline-formula><mml:math id="M100" display="inline"><mml:mi>c</mml:mi></mml:math></inline-formula>, over which <inline-formula><mml:math id="M101" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula> has non-zero values; and the effective smoothing width, <inline-formula><mml:math id="M102" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula>, which determines the spread or variance of <inline-formula><mml:math id="M103" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula>, thereby controlling how particle contributions are spatially distributed within the volume of radius <inline-formula><mml:math id="M104" display="inline"><mml:mi>c</mml:mi></mml:math></inline-formula>.</p>
      <p id="d2e2649">Various kernel functions that may be employed in coarse-graining are implemented in Pysammos: the Lucy (Eq. <xref ref-type="disp-formula" rid="Ch1.E9"/>), Gaussian (Eq. <xref ref-type="disp-formula" rid="Ch1.E10"/>), and Heaviside (Eq. <xref ref-type="disp-formula" rid="Ch1.E11"/>) functions. Different kernel forms relate <inline-formula><mml:math id="M105" display="inline"><mml:mi>c</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M106" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula> with different scaling factors. To provide a consistent comparison across kernels in Fig. <xref ref-type="fig" rid="F6"/>, all functions are rescaled so that they share the same variance. This ensures that the differences between kernels are due to the function shape and not the difference in effective smoothing width <inline-formula><mml:math id="M107" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula> or the kernel spatial domain <inline-formula><mml:math id="M108" display="inline"><mml:mi>c</mml:mi></mml:math></inline-formula>.

              <disp-formula id="Ch1.E9" content-type="numbered"><label>9</label><mml:math id="M109" display="block"><mml:mtable rowspacing="0.2ex" class="split" displaystyle="true" columnalign="right left"><mml:mtr><mml:mtd><mml:mrow><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi>r</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mo>=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mn mathvariant="normal">105</mml:mn><mml:mrow><mml:mn mathvariant="normal">16</mml:mn><mml:mi mathvariant="italic">π</mml:mi><mml:msup><mml:mi>c</mml:mi><mml:mn mathvariant="normal">3</mml:mn></mml:msup></mml:mrow></mml:mfrac></mml:mstyle><mml:mfenced open="(" close=")"><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">3</mml:mn><mml:msup><mml:mfenced open="(" close=")"><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mi>r</mml:mi><mml:mi>c</mml:mi></mml:mfrac></mml:mstyle></mml:mfenced><mml:mn mathvariant="normal">4</mml:mn></mml:msup><mml:mo>+</mml:mo><mml:mn mathvariant="normal">8</mml:mn><mml:msup><mml:mfenced open="(" close=")"><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mi>r</mml:mi><mml:mi>c</mml:mi></mml:mfrac></mml:mstyle></mml:mfenced><mml:mn mathvariant="normal">3</mml:mn></mml:msup><mml:mo>-</mml:mo><mml:mn mathvariant="normal">6</mml:mn><mml:msup><mml:mfenced open="(" close=")"><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mi>r</mml:mi><mml:mi>c</mml:mi></mml:mfrac></mml:mstyle></mml:mfenced><mml:mn mathvariant="normal">2</mml:mn></mml:msup><mml:mo>+</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:mfenced></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mtext>if</mml:mtext><mml:mspace width="0.25em" linebreak="nobreak"/><mml:mi>r</mml:mi><mml:mo>:=</mml:mo><mml:mo>|</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>|</mml:mo><mml:mo>&lt;</mml:mo><mml:mi>c</mml:mi></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>

            where <inline-formula><mml:math id="M110" display="inline"><mml:mi>c</mml:mi></mml:math></inline-formula> is the range of the weighting function and is usually set to <inline-formula><mml:math id="M111" display="inline"><mml:mrow><mml:mi>c</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">2</mml:mn><mml:mi>w</mml:mi></mml:mrow></mml:math></inline-formula> for Lucy polynomials <xref ref-type="bibr" rid="bib1.bibx84" id="paren.88"/>.

              <disp-formula id="Ch1.E10" content-type="numbered"><label>10</label><mml:math id="M112" display="block"><mml:mtable rowspacing="0.2ex" class="split" displaystyle="true" columnalign="right left"><mml:mtr><mml:mtd><mml:mrow><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi>r</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mo>=</mml:mo><mml:mi>exp⁡</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:mo>-</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:msup><mml:mi>r</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:mrow><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:msup><mml:mi>w</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:mrow></mml:mfrac></mml:mstyle></mml:mrow></mml:mfenced><mml:mfenced open="[" close=""><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:msqrt><mml:mn mathvariant="normal">2</mml:mn></mml:msqrt><mml:msup><mml:mi mathvariant="italic">π</mml:mi><mml:mrow><mml:mn mathvariant="normal">3</mml:mn><mml:mo>/</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:mrow></mml:msup><mml:msup><mml:mi>w</mml:mi><mml:mn mathvariant="normal">3</mml:mn></mml:msup><mml:mtext>erf</mml:mtext></mml:mrow></mml:mfenced></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:msup><mml:mfenced close="]" open=""><mml:mfenced open="(" close=")"><mml:mrow><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:msqrt><mml:mn mathvariant="normal">2</mml:mn></mml:msqrt><mml:mn mathvariant="normal">2</mml:mn></mml:mfrac></mml:mstyle><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mi>c</mml:mi><mml:mi>w</mml:mi></mml:mfrac></mml:mstyle><mml:mo>-</mml:mo><mml:mn mathvariant="normal">4</mml:mn><mml:mi mathvariant="italic">π</mml:mi><mml:mi>c</mml:mi><mml:msup><mml:mi>w</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msup><mml:mi>exp⁡</mml:mi><mml:mfenced close=")" open="("><mml:mrow><mml:mo>-</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:msup><mml:mi>c</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:mrow><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:msup><mml:mi>w</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:mrow></mml:mfrac></mml:mstyle></mml:mrow></mml:mfenced></mml:mrow></mml:mfenced></mml:mfenced><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msup></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>

            where the erf is the error function, and <inline-formula><mml:math id="M113" display="inline"><mml:mrow><mml:mi>c</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">3</mml:mn><mml:mi>w</mml:mi></mml:mrow></mml:math></inline-formula> for the Gaussian weighting function.

              <disp-formula id="Ch1.E11" content-type="numbered"><label>11</label><mml:math id="M114" display="block"><mml:mrow><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi>r</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:mfenced open="{" close=""><mml:mtable class="cases" rowspacing="6pt" columnspacing="1em" columnalign="left left" framespacing="0em"><mml:mtr><mml:mtd><mml:mrow><mml:mstyle displaystyle="false"><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mn mathvariant="normal">1</mml:mn><mml:mi mathvariant="italic">φ</mml:mi></mml:mfrac></mml:mstyle></mml:mstyle><mml:mo>,</mml:mo></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mi>r</mml:mi><mml:mo>≤</mml:mo><mml:mi>c</mml:mi><mml:mo>,</mml:mo></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mrow><mml:mn mathvariant="normal">0</mml:mn><mml:mo>,</mml:mo></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mi>r</mml:mi><mml:mo>&gt;</mml:mo><mml:mi>c</mml:mi><mml:mo>,</mml:mo></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:mfenced></mml:mrow></mml:math></disp-formula>

            where <inline-formula><mml:math id="M115" display="inline"><mml:mrow><mml:mi mathvariant="italic">φ</mml:mi><mml:mo>=</mml:mo><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mn mathvariant="normal">4</mml:mn><mml:mn mathvariant="normal">3</mml:mn></mml:mfrac></mml:mstyle><mml:mi mathvariant="italic">π</mml:mi><mml:msup><mml:mi>c</mml:mi><mml:mn mathvariant="normal">3</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula> is the volume of a sphere with radius <inline-formula><mml:math id="M116" display="inline"><mml:mi>c</mml:mi></mml:math></inline-formula>. It follows that <inline-formula><mml:math id="M117" display="inline"><mml:mrow><mml:mi>c</mml:mi><mml:mo>=</mml:mo><mml:mi>w</mml:mi></mml:mrow></mml:math></inline-formula> in the Heaviside function.</p>

      <fig id="F6"><label>Figure 6</label><caption><p id="d2e3073">Visualisation of the three implemented coarse-graining weighting functions, <inline-formula><mml:math id="M118" display="inline"><mml:mrow><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi>r</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>, in one dimension (<inline-formula><mml:math id="M119" display="inline"><mml:mi>r</mml:mi></mml:math></inline-formula>) normalised by the effective smoothing width (<inline-formula><mml:math id="M120" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula>). Note that the functions have been plotted with equal variance in order to ensure that any differences are due to kernel shape, not scale. </p></caption>
            <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f06.png"/>

          </fig>

      <p id="d2e3111">The weights are pre-calculated for a range of particle-grid point distances, extending from 0 to <inline-formula><mml:math id="M121" display="inline"><mml:mi>c</mml:mi></mml:math></inline-formula>, and corresponding to a discretisation of space at a high enough resolution to ensure accuracy. This approach provides a more efficient performance as it avoids the redundant calculation of weights. It is carried out with a lookup table algorithm, details of which can be found in Appendix <xref ref-type="sec" rid="App1.Ch1.S2.SS3"/>.</p>
      <p id="d2e3123">The calculation of contact-related fields (e.g., the contact stress tensor, Eq. (<xref ref-type="disp-formula" rid="Ch1.E5"/>)  requires the additional line integral of <inline-formula><mml:math id="M122" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula> along the branch vector connecting a particle centre to a contact point. This integral could, in principle, be solved analytically for each kernel individually <xref ref-type="bibr" rid="bib1.bibx83" id="paren.89"/>.  In Pysammos, we instead evaluate it numerically: the branch vector is discretised into <inline-formula><mml:math id="M123" display="inline"><mml:mrow><mml:mi>N</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">10</mml:mn></mml:mrow></mml:math></inline-formula> points, sampled through the same lookup table employed for particle weights, and integrating with the trapezoidal rule. This provides a single, kernel-independent implementation of the integral. Increasing <inline-formula><mml:math id="M124" display="inline"><mml:mi>N</mml:mi></mml:math></inline-formula> beyond 10, up to <inline-formula><mml:math id="M125" display="inline"><mml:mrow><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">5</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula>, produced no discernible change in the resulting contact stress fields (Fig. S7 of the Supplement), confirming that the trapezoidal integration is already converged at this resolution.</p>
</sec>
<sec id="Ch1.S3.SS5.SSS4">
  <label>3.5.4</label><title>Macroscopic fields</title>
      <p id="d2e3178">The structure of the field computing functions consists of several nested levels of iterations. The outermost iteration, which is parallelised using Numba, is performed over the grid points, as it is the largest dimension. The next level iterates through the particles within the cut-off volume of that grid point. Subsequently, an iteration through phase is performed, if specified by the user. Finally, if the resulting field has more than one dimension (i.e., is a vector or a tensor),  additional levels of iteration are implemented to carry out element-wise multiplication. Details about the utilisation of Numba in Pysammos can be found in Appendix <xref ref-type="sec" rid="App1.Ch1.S5.SS1"/>.</p>
      <p id="d2e3183">A range of continuum fields can be calculated with Pysammos (Appendix <xref ref-type="sec" rid="App1.Ch1.S3"/>). To allow the user to customise what fields to export for a more efficient use of the tool, yet accounting for dependencies of required fields, an inbuilt tool is used in the user-interface class to determine the full set of fields that have to be computed given a series of user-selected fields to be exported.</p>
</sec>
</sec>
<sec id="Ch1.S3.SS6">
  <label>3.6</label><title>Data writing stage</title>
      <p id="d2e3197">Pysammos provides two types of output files: a vtkhdf file per DEM time step processed, for ParaView visualisation; and a single h5 file containing data from all the time steps, for data analysis and storage. Vtkhdf files are built on hdf5 but are adapted for vtk-type workflows, thus combining the parallel I/O support and the optimisation for meshed structures with the standardisation of data storage for visualisation purposes.  On the other hand, h5 files offer high flexibility for structured data storage, are optimised for large datasets, and are compatible across programming languages.</p>
</sec>
</sec>
<sec id="Ch1.S4">
  <label>4</label><title>Results</title>
      <p id="d2e3209">In the following section we present the results concerning the benchmark of the code to other available CG software and the computational performance. We then provide an example of a user-friendly script to perform CG in Pysammos, and a series of examples to showcase the functionalities of the code for visualisation and analysis.</p>
<sec id="Ch1.S4.SS1">
  <label>4.1</label><title>Benchmarking</title>
      <p id="d2e3219">Pysammos is intended to be used by a diverse community working with computational particulate methods, spread across geosciences, engineering and physics. Hence, reassuring users that it yields reliable results is key. For that reason, we compared results from Pysammos to other CG software: Iota-Suite <xref ref-type="bibr" rid="bib1.bibx49" id="paren.90"/>, EDEM's continuum analysis <xref ref-type="bibr" rid="bib1.bibx2" id="paren.91"/>, Granulysed (using Iota-Suite and VELaSSCo <xref ref-type="bibr" rid="bib1.bibx58" id="paren.92"/>), and MercuryCG <xref ref-type="bibr" rid="bib1.bibx86" id="paren.93"/>. We used a benchmark DEM sample of a static monodisperse cubic lattice with vertical plate displacement and fixed side walls. The particles have diameter <inline-formula><mml:math id="M126" display="inline"><mml:mrow><mml:mi>d</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0.02</mml:mn></mml:mrow></mml:math></inline-formula> m and density <inline-formula><mml:math id="M127" display="inline"><mml:mrow><mml:mi mathvariant="italic">ρ</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">2500</mml:mn></mml:mrow></mml:math></inline-formula> kg m<sup>−3</sup>. The sample is analysed at the centre, <inline-formula><mml:math id="M129" display="inline"><mml:mrow><mml:mi>P</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0</mml:mn><mml:mo>,</mml:mo><mml:mn mathvariant="normal">0</mml:mn><mml:mo>,</mml:mo><mml:mn mathvariant="normal">0.42725</mml:mn></mml:mrow></mml:math></inline-formula> m (Fig. <xref ref-type="fig" rid="F7"/>g). The tests are carried out for different smoothing half-width lengths multiples of the characteristic particle size (i.e., <inline-formula><mml:math id="M130" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>) and smoothing functions. These established tests are straightforward to carry out, as they are easily accessible through the user interface class. Future versions of the code should be benchmarked using the same data in order to guarantee output consistency.  Figure <xref ref-type="fig" rid="F7"/> contains the continuum fields of the benchmarked simulation, computed with several different CG codes. All the fundamental continuum fields, including all the vector and tensor components are provided in the Supplement.</p>

      <fig id="F7" specific-use="star"><label>Figure 7</label><caption><p id="d2e3309">Benchmark of a monodisperse cubic lattice of grains with a diameter of 0.02 m and density of 2500 kg m<sup>−3</sup> <bold>(g)</bold>, at a point <inline-formula><mml:math id="M132" display="inline"><mml:mrow><mml:mi>P</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0</mml:mn><mml:mo>,</mml:mo><mml:mn mathvariant="normal">0</mml:mn><mml:mo>,</mml:mo><mml:mn mathvariant="normal">0.42725</mml:mn></mml:mrow></mml:math></inline-formula> m. It was coarse-grained with Pysammos (coloured triangles) and other coarse-graining software (void shapes): EDEM, Granulysed, Iota, and MercuryCG. Different smoothing functions  (Gaussian, Heaviside and Lucy), are compared when available, for a range of smoothing half-width lengths multiples of the characteristic particle size (i.e., <inline-formula><mml:math id="M133" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>). The volume fraction is shown in <bold>(a)</bold>. The horizontal component of the velocity and the momentum density are shown in <bold>(b)</bold> and <bold>(c)</bold>, respectively. The vertical component of the contact stress is provided in <bold>(d)</bold>, whereas <bold>(e)</bold> displays the ratio between the latter and the shear component in the <inline-formula><mml:math id="M134" display="inline"><mml:mrow><mml:mi>x</mml:mi><mml:mi>y</mml:mi></mml:mrow></mml:math></inline-formula>-plane. Finally, the vertical component of the kinetic tensor is shown in <bold>(f)</bold>.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f07.png"/>

        </fig>

      <p id="d2e3394">Volume fraction is overall constant across the entire <inline-formula><mml:math id="M135" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula> range (Fig. <xref ref-type="fig" rid="F7"/>a). It shows a larger spread of values across codes in the lower range of smoothing widths when using the Heaviside functions in Pysammos and MercuryCG. The mixture density field shows a very similar set of characteristics to the volume fraction (see Fig. S1). The velocity (Fig. <xref ref-type="fig" rid="F7"/>b) and momentum density (Fig. <xref ref-type="fig" rid="F7"/>c) fields at the tested point increase as the smoothing width is increased for all codes. The Lucy function yields slightly lower values than the rest of the codes for <inline-formula><mml:math id="M136" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi><mml:mo>&gt;</mml:mo><mml:mn mathvariant="normal">4</mml:mn></mml:mrow></mml:math></inline-formula>, whereas the Heaviside functions and EDEM’s Gaussian consistently estimate higher values. Pysammos’s results coincide with MercuryCG's corresponding results, as they use the same weighted spatial averaging scheme. The kinetic tensor field increases overall as the smoothing width is enlarged (Fig. <xref ref-type="fig" rid="F7"/>f). Granulysed calculations yield constant values of the kinetic tensor across the entire <inline-formula><mml:math id="M137" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula> range. The results rendered by Pysammos, coincide again with those from MercuryCG.</p>
      <p id="d2e3447">The contact tensor field (Fig. <xref ref-type="fig" rid="F7"/>d) shows a broadly constant mean value across the analysed <inline-formula><mml:math id="M138" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula> range (see Fig. S6e for enlarged view), with a greater scatter at the low end. Pysammos and MercuryCG show a degree of discrepancy at lower <inline-formula><mml:math id="M139" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>. This could be attributed to the difference in the particle-search criterion between the two codes: in Pysammos, a contact is included in the averaging volume based on the distance from the grid point to the centre of <italic>particle i</italic>, whereas MercuryCG's determines inclusion based on the minimum distance from the grid point to the branch vector itself <xref ref-type="bibr" rid="bib1.bibx87" id="paren.94"/>. This more general criterion allows MercuryCG to include contacts whose branch vector is positioned near the grid point even when the particle centre itself lies outside the cut-off radius, an effect expected to be more pronounced at low <inline-formula><mml:math id="M140" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>, where the search radius is comparable to the branch-vector length. We note that this discrepancy is unlikely to stem from the numerical evaluation of the branch-vector line integral in Pysammos (Sect. <xref ref-type="sec" rid="Ch1.S3.SS5.SSS3"/>), as the trapezoidal integration is already converged at <inline-formula><mml:math id="M141" display="inline"><mml:mrow><mml:mi>N</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">10</mml:mn></mml:mrow></mml:math></inline-formula> sampling points (Fig. S7 of the Supplement) and is not expected to be a significant source of error even at low <inline-formula><mml:math id="M142" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>. Further, the Heaviside function in Pysammos shows larger disagreement with that of MercuryCG across the whole <inline-formula><mml:math id="M143" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula> range and especially in the diagonal components of <inline-formula><mml:math id="M144" display="inline"><mml:mrow><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>c</mml:mi></mml:msup></mml:mrow></mml:math></inline-formula>, compared to the off-diagonal ones (see Fig. S5). This could be due to the Heaviside's uniform weighting of all the particles within the search volume, which exacerbates edge effects of the search shift discussed above. Conversely, the Gaussian and Lucy functions heavily damp the contribution from particles further from the evaluation point, making them less susceptible to this issue. Despite these discrepancies,  the ratio of the vertical to the shear component in the <inline-formula><mml:math id="M145" display="inline"><mml:mrow><mml:mi>x</mml:mi><mml:mi>y</mml:mi></mml:mrow></mml:math></inline-formula>-plane of the contact stress tensor converges towards a constant value close to 0 after <inline-formula><mml:math id="M146" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi><mml:mo>∼</mml:mo><mml:mn mathvariant="normal">3</mml:mn></mml:mrow></mml:math></inline-formula>, whereas it shows a larger scatter on the order of <inline-formula><mml:math id="M147" display="inline"><mml:mrow><mml:mo>±</mml:mo><mml:mn mathvariant="normal">4</mml:mn><mml:mo>×</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:mrow></mml:msup></mml:mrow></mml:math></inline-formula> for <inline-formula><mml:math id="M148" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi><mml:mo>&lt;</mml:mo><mml:mn mathvariant="normal">3</mml:mn></mml:mrow></mml:math></inline-formula> (Fig. <xref ref-type="fig" rid="F7"/>e).</p>

      <fig id="F8" specific-use="star"><label>Figure 8</label><caption><p id="d2e3611">Computational cost per particle, and per time step, as the dataset size increases using a different number of CPUs for parallelisation. The cost per particle is measured as the runtime duration (in seconds) normalised by the number of particles within the region of the model being processed. The performance was compared across different search radii, <inline-formula><mml:math id="M149" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>: the default 0.75 <bold>(a)</bold>, 2 <bold>(b)</bold>, 4 <bold>(c)</bold> and 6 <bold>(d)</bold>. </p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f08.png"/>

        </fig>

</sec>
<sec id="Ch1.S4.SS2">
  <label>4.2</label><title>Performance</title>
      <p id="d2e3652">The computational performance of Pysammos's CG workflow was evaluated by means of the computational cost per particle as the post-processed model increased in size. The computational cost per particle corresponds to the ratio between runtime and number of accounted particles, and it is a measure of how well the code scales resources needed as complexity increases. The model size is quantified by the number of grid points and/or particles in the analysed space. The performance was tested at different spatial averaging resolutions (<inline-formula><mml:math id="M150" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>), and using different number of core processors. Thus, we provide a map of optimal performance across different analysis scenarios, revealing that the ideal configuration depends on the nature of the data being processed and the resolution at which it is being processed.</p>
      <p id="d2e3667">The DEM sample was that of a static random packing cube of side length <inline-formula><mml:math id="M151" display="inline"><mml:mrow><mml:mo>∼</mml:mo><mml:mn mathvariant="normal">95</mml:mn><mml:msub><mml:mi>d</mml:mi><mml:mn mathvariant="normal">43</mml:mn></mml:msub></mml:mrow></mml:math></inline-formula>, with a high coordination number of <inline-formula><mml:math id="M152" display="inline"><mml:mrow><mml:mo>∼</mml:mo><mml:mn mathvariant="normal">5</mml:mn></mml:mrow></mml:math></inline-formula>–6 (Fig. <xref ref-type="fig" rid="F10"/> prior to the impact). All available outputs, involving both particle and contact related fields, were exported in order to have a complete representation of the computational requirements when running the program at full capacity. The quoted runtime values are an average of three different computed time steps. The computation for this exercise was carried out on the ARCHER2 HPC cluster.</p>
      <p id="d2e3697">The cost per particle decreases sub-linearly with number of particles across all averaging resolutions and number of cores, meaning the code cost scales favourably with problem size (Fig. <xref ref-type="fig" rid="F8"/>). This entails that overheads are being amortised and caches are being used efficiently. Inherently, for a given tested model size (i.e., <inline-formula><mml:math id="M153" display="inline"><mml:mrow><mml:msub><mml:mi>N</mml:mi><mml:mi mathvariant="normal">particles</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>), the higher the CG resolution is (i.e., lower <inline-formula><mml:math id="M154" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>), the larger the number of grid points, but the fewer particles per grid point. Consequently, we observe that across all number of cores, the cost per particle at Pysammos's default <inline-formula><mml:math id="M155" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0.75</mml:mn></mml:mrow></mml:math></inline-formula> begins to plateau at <inline-formula><mml:math id="M156" display="inline"><mml:mrow><mml:mo>∼</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">4</mml:mn></mml:mrow></mml:msup></mml:mrow></mml:math></inline-formula> for <inline-formula><mml:math id="M157" display="inline"><mml:mrow><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">6</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula> particles  (Fig. <xref ref-type="fig" rid="F8"/>a), but for larger <inline-formula><mml:math id="M158" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>  it continues to decrease (Fig. <xref ref-type="fig" rid="F8"/>b–d). Thus, we can say that the number of particles per grid point controls the point at which the performance plateaus. At higher resolutions, the iteration at each grid point carries out operations across a smaller range of particles, which is harder to amortise for large models (<inline-formula><mml:math id="M159" display="inline"><mml:mrow><mml:mo>∼</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">6</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula> particles), regardless of the total number of grid points.</p>
      <p id="d2e3798">The use of parallel computing reduces the cost per particle for model sizes of <inline-formula><mml:math id="M160" display="inline"><mml:mrow><mml:msub><mml:mi>N</mml:mi><mml:mi mathvariant="normal">particles</mml:mi></mml:msub><mml:mo>&gt;</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">5</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula>  at resolutions of <inline-formula><mml:math id="M161" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi><mml:mo>&gt;</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:mrow></mml:math></inline-formula>  (Fig. <xref ref-type="fig" rid="F8"/>). The efficiency gained from additional cores increases with <inline-formula><mml:math id="M162" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>, up to <inline-formula><mml:math id="M163" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">6</mml:mn></mml:mrow></mml:math></inline-formula>, beyond which it begins to plateau relative to <inline-formula><mml:math id="M164" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">4</mml:mn></mml:mrow></mml:math></inline-formula> (Fig. <xref ref-type="fig" rid="F8"/>c, d). For larger systems (<inline-formula><mml:math id="M165" display="inline"><mml:mrow><mml:msub><mml:mi>N</mml:mi><mml:mi mathvariant="normal">particles</mml:mi></mml:msub><mml:mo>&gt;</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">5</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula>) the speed-up by parallelisation saturates at a low number of cores under sub-particle resolution, but at 16 cores for  <inline-formula><mml:math id="M166" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>&gt;</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>. For smaller systems (<inline-formula><mml:math id="M167" display="inline"><mml:mrow><mml:msub><mml:mi>N</mml:mi><mml:mi mathvariant="normal">particles</mml:mi></mml:msub><mml:mo>&lt;</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">5</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula>), parallelisation provides no noticeable speed-up at resolutions <inline-formula><mml:math id="M168" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>&gt;</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>, and saturates at a low number of cores (<inline-formula><mml:math id="M169" display="inline"><mml:mrow><mml:mo>∼</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:mrow></mml:math></inline-formula>) at resolutions <inline-formula><mml:math id="M170" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>&lt;</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>.  Although Numba reduces Python-level overhead, the gains from additional parallelism at <inline-formula><mml:math id="M171" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>&lt;</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula> are of limited improvement (Fig. <xref ref-type="fig" rid="F8"/>a), most likely because the algorithms where Numba parallelisation is employed are memory-bound, and this cost is not sufficiently amortised when the number of particles per grid point is small.</p>
      <p id="d2e3982">Therefore, when coarse-graining at a high resolution below the particle scale, it is recommended to use a low number of cores to attain optimal computational efficiency. Nevertheless, this means that efficient execution of Pysammos does not require extensive parallel resources, thereby making this post-processing software well suited for shared computational systems. On the other hand, when coarse-graining at a lower resolution, namely above particle scale, in a large dense packing it is recommended to use between 4 and 16 cores. In general, further improved parallel performance can be attained by, alternatively or additionally, distributing independent time slices across different shared-memory processes.</p>
</sec>
<sec id="Ch1.S4.SS3">
  <label>4.3</label><title>User-friendly workflow</title>
      <p id="d2e3993">Here we provide a usage example of the user-facing <monospace>CoarseGraining</monospace> class. Listing <xref ref-type="fig" rid="Li1"/> shows how to initialise the class with the entries of the configuration file. See Appendix <xref ref-type="sec" rid="App1.Ch1.S1"/> for an example of a configuration file. </p>

      <fig id="Li1" specific-use="star"><label>Listing 1</label><caption><p id="d2e4007">Initialisation of the CoarseGraining class. </p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-l01.png"/>

        </fig>

      <p id="d2e4016">Listing <xref ref-type="fig" rid="Li2"/> presents the algorithm steps of the CG workflow applied through the methods of the <monospace>CoarseGraining</monospace> class, previously described in Sect. <xref ref-type="sec" rid="Ch1.S3"/>. Alternatively, the method <monospace>CG.run()</monospace> performs all the steps sequentially with default parameters.</p>

      <fig id="Li2" specific-use="star"><label>Listing 2</label><caption><p id="d2e4032">Coarse-graining workflow with Pysammos. </p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-l02.png"/>

        </fig>

</sec>
<sec id="Ch1.S4.SS4">
  <label>4.4</label><title>Example cases</title>
      <p id="d2e4050">Below we present a set of example MFiX DEM simulations of processes relevant to the geoscientific community, alongside coarse-graining results to showcase the functionalities offered by Pysammos  – some of the various continuum fields that can be computed, relevant further data analysis, and result visualisation modalities.</p>
<sec id="Ch1.S4.SS4.SSS1">
  <label>4.4.1</label><title>Bedload transport</title>
      <p id="d2e4060">The following example demonstrates how Pysammos can process a polydisperse mixture of non-spherical particles in a 2D model, and provide ParaView-ready outputs.  It also provides an insight into the breadth of information that can be obtained using DEM and Pysammos's coarse-graining for the study of  river bedload transport.</p>
      <p id="d2e4063">Figure <xref ref-type="fig" rid="F9"/> displays a DEM-CFD 2D numerical simulation representing bedload sediment, of polydisperse non-spherical grains, submerged in water over a rough static base of spherical grains. The boundaries of the <inline-formula><mml:math id="M172" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula> axis are made periodic. The water is subjected to periodic horizontal planar waves travelling in the positive <inline-formula><mml:math id="M173" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula> direction. The time step in Fig. <xref ref-type="fig" rid="F9"/> captures wave fronts at <inline-formula><mml:math id="M174" display="inline"><mml:mrow><mml:mi>x</mml:mi><mml:mo>∼</mml:mo><mml:mn mathvariant="normal">0</mml:mn></mml:mrow></mml:math></inline-formula>.05 m and <inline-formula><mml:math id="M175" display="inline"><mml:mrow><mml:mi>x</mml:mi><mml:mo>∼</mml:mo><mml:mn mathvariant="normal">0</mml:mn></mml:mrow></mml:math></inline-formula>.45 m. These are manifested as bands of higher shear rate (Fig. <xref ref-type="fig" rid="F9"/>d) and inertial number <inline-formula><mml:math id="M176" display="inline"><mml:mi>I</mml:mi></mml:math></inline-formula> (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E31"/>), a measure of the dynamic state of a granular medium further described in Appendix <xref ref-type="sec" rid="App1.Ch1.S3.SS2"/> (Fig. <xref ref-type="fig" rid="F9"/>c). However, the wave fronts do not appear obvious in the contact network (Fig. <xref ref-type="fig" rid="F9"/>b). It can also be seen that shear rate decreases with depth, as expected in bedload transport <xref ref-type="bibr" rid="bib1.bibx37" id="paren.95"/>.</p><fig id="F9" specific-use="star"><label>Figure 9</label><caption><p id="d2e4132">DEM-CFD 2D numerical simulation representing bedload sediment, of polydisperse non-spherical grains, submerged in flowing water over a rough static base of spherical grains <bold>(a)</bold>. The water is subjected to periodic horizontal planar waves in the positive <inline-formula><mml:math id="M177" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula> direction. The contact network is shown in <bold>(b)</bold> and is coloured by the normalised force magnitude (<inline-formula><mml:math id="M178" display="inline"><mml:mrow><mml:mo fence="true">|</mml:mo><mml:mover accent="true"><mml:mi>F</mml:mi><mml:mo mathvariant="normal">¯</mml:mo></mml:mover><mml:mo fence="true">|</mml:mo></mml:mrow></mml:math></inline-formula>). Plots <bold>(c)</bold> and <bold>(d)</bold> display the inertial number (<inline-formula><mml:math id="M179" display="inline"><mml:mi>I</mml:mi></mml:math></inline-formula>) and shear rate tensor magnitude (<inline-formula><mml:math id="M180" display="inline"><mml:mover accent="true"><mml:mi mathvariant="italic">γ</mml:mi><mml:mo mathvariant="normal">˙</mml:mo></mml:mover></mml:math></inline-formula>)  coarse-grained fields evaluated with Pysammos, respectively.</p></caption>
            <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f09.jpg"/>

          </fig>

</sec>
<sec id="Ch1.S4.SS4.SSS2">
  <label>4.4.2</label><title>Impactor on polydisperse granular bed</title>
      <p id="d2e4201">This example illustrates the ability of Pysammos to recover high spatial resolution fields from a large DEM model (<inline-formula><mml:math id="M181" display="inline"><mml:mrow><mml:mo>∼</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">6</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula> particles). We present a DEM simulation of a high-speed impact on a granular bed, as a case study relevant in the field of both extraterrestrial cratering and seismology. It consists of a cuboid polydisperse bed (<inline-formula><mml:math id="M182" display="inline"><mml:mrow><mml:mn mathvariant="normal">0.08</mml:mn><mml:mo>×</mml:mo><mml:mn mathvariant="normal">0.08</mml:mn><mml:mo>×</mml:mo><mml:mn mathvariant="normal">0.08</mml:mn></mml:mrow></mml:math></inline-formula> m), struck at high speed by a large impactor (<inline-formula><mml:math id="M183" display="inline"><mml:mrow><mml:msub><mml:mi>d</mml:mi><mml:mi mathvariant="normal">L</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0.001</mml:mn></mml:mrow></mml:math></inline-formula> m) (Fig. <xref ref-type="fig" rid="F10"/>). The particle diameters were drawn from a normal distribution with a  mean of 0.0008 m and a coefficient of variation of 10 %.</p>
      <p id="d2e4250">Vertical slices in the <inline-formula><mml:math id="M184" display="inline"><mml:mrow><mml:mi>x</mml:mi><mml:mi>y</mml:mi></mml:mrow></mml:math></inline-formula>-plane (at <inline-formula><mml:math id="M185" display="inline"><mml:mrow><mml:mi>z</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0.04</mml:mn></mml:mrow></mml:math></inline-formula> m) of the contact network and several coarse-grained fields at a spatial resolution similar to the particle size are shown in Fig. <xref ref-type="fig" rid="F11"/>.  The contact network is less dense in the vicinity of the impact due to particle ejection, with higher magnitude forces (<inline-formula><mml:math id="M186" display="inline"><mml:mo lspace="0mm">∼</mml:mo></mml:math></inline-formula> 10<sup>6</sup> N) within a sphere around the impact (Fig. <xref ref-type="fig" rid="F11"/>a).  The vertical component of the velocity shows the shock wave propagating downwards (Fig. <xref ref-type="fig" rid="F11"/>b). In addition, we see two paths of lower particle velocity radiating outwards from the impact towards the side walls. This, however, is not observed in other fields, such as pressure (Fig. <xref ref-type="fig" rid="F11"/>c) or inertial number (Fig. <xref ref-type="fig" rid="F11"/>d), where the shock wave is seemingly mostly isotropic and has the same radial extent as that seen in velocity.  Figure <xref ref-type="fig" rid="F11"/>e displays the <inline-formula><mml:math id="M188" display="inline"><mml:mi mathvariant="italic">μ</mml:mi></mml:math></inline-formula>(I) according to <xref ref-type="bibr" rid="bib1.bibx28" id="text.96"/>, to assess the extent to which the rheology of the mixture can be approximated to a local rheology, if the background blue is the static coefficient of friction of this mixture (<inline-formula><mml:math id="M189" display="inline"><mml:mo lspace="0mm">∼</mml:mo></mml:math></inline-formula> 0.4). In fact, we see that <inline-formula><mml:math id="M190" display="inline"><mml:mi mathvariant="italic">μ</mml:mi></mml:math></inline-formula>(I) is greater than the coefficient of static friction around the region of impact, which is what has been observed in the literature at high values of inertial number – in this case corresponding to high pressure – <xref ref-type="bibr" rid="bib1.bibx7" id="paren.97"/>.  Finally, the coordination number (i.e., the number of contacts of a given particle) is plotted in Fig. <xref ref-type="fig" rid="F11"/>f, from which we can see a decrease towards the region of impact, and a faint ring of  lower coordination number at the wave front.</p>

      <fig id="F10" specific-use="star"><label>Figure 10</label><caption><p id="d2e4338">DEM numerical simulation of a polydisperse cuboid bed, of spherical particles initially at rest, hit at high velocity by an impactor larger in size. </p></caption>
            <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f10.jpg"/>

          </fig>

      <fig id="F11" specific-use="star"><label>Figure 11</label><caption><p id="d2e4350">Vertical slices in the <inline-formula><mml:math id="M191" display="inline"><mml:mrow><mml:mi>x</mml:mi><mml:mi>y</mml:mi></mml:mrow></mml:math></inline-formula>-plane (<inline-formula><mml:math id="M192" display="inline"><mml:mrow><mml:mi>z</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0.04</mml:mn><mml:mspace width="0.125em" linebreak="nobreak"/></mml:mrow></mml:math></inline-formula>m) of the coarse-grained fields corresponding to the DEM numerical simulation of a polydisperse bed hit by an impactor presented in Fig. <xref ref-type="fig" rid="F10"/>.  The contact network is shown in <bold>(a)</bold>, coloured by the normalised force magnitude (<inline-formula><mml:math id="M193" display="inline"><mml:mrow><mml:mo fence="true">|</mml:mo><mml:mover accent="true"><mml:mi>F</mml:mi><mml:mo mathvariant="normal">¯</mml:mo></mml:mover><mml:mo fence="true">|</mml:mo></mml:mrow></mml:math></inline-formula>). The vertical component of the velocity (<inline-formula><mml:math id="M194" display="inline"><mml:mrow><mml:msub><mml:mi>V</mml:mi><mml:mi>y</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>), pressure (<inline-formula><mml:math id="M195" display="inline"><mml:mi>P</mml:mi></mml:math></inline-formula>), inertial number (<inline-formula><mml:math id="M196" display="inline"><mml:mi>I</mml:mi></mml:math></inline-formula>) and coordination number (<inline-formula><mml:math id="M197" display="inline"><mml:mi>Z</mml:mi></mml:math></inline-formula>) are displayed in <bold>(b)</bold>, <bold>(c)</bold>, <bold>(d)</bold> and <bold>(f)</bold>, respectively. The coefficient of friction as a function  of inertial number (i.e., <inline-formula><mml:math id="M198" display="inline"><mml:mi mathvariant="italic">μ</mml:mi></mml:math></inline-formula>(I)-rheology) is shown in <bold>(e)</bold>, where the static coefficient of friction of the mixture (<inline-formula><mml:math id="M199" display="inline"><mml:mo lspace="0mm">∼</mml:mo></mml:math></inline-formula> 0.4) is coloured light-blue.</p></caption>
            <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f11.jpg"/>

          </fig>

</sec>
<sec id="Ch1.S4.SS4.SSS3">
  <label>4.4.3</label><title>Crystal suspension in magmas</title>
      <p id="d2e4473">This example showcases the application of Pysammos to granular suspensions, that is, particles flowing and interacting with each other and the fluid they are immersed in. The rheology of granular suspensions controls the dynamics of lava flows and magma reservoirs <xref ref-type="bibr" rid="bib1.bibx56" id="paren.98"/>, and has begun to be studied with DEM <xref ref-type="bibr" rid="bib1.bibx64" id="paren.99"/>.</p>
      <p id="d2e4482">Hence, we present a DEM-CFD pseudo-2D (i.e., with a thickness of one cell) numerical simulation representing non-spherical crystals suspended in magma flowing cyclically in the positive vertical direction through a narrow conduit with frictional walls  (Fig. <xref ref-type="fig" rid="F12"/>a). The particles are fully three-dimensional and interact with the fluid through a two-way coupling via drag and pressure forces. The flow is driven by a constant flux, causing the particles to accelerate until they eventually reach steady state. Given the sparsity of the solid particles, we chose a smoothing function half-width four times larger than the default option, 0.75 <inline-formula><mml:math id="M200" display="inline"><mml:mrow><mml:mo>×</mml:mo><mml:msub><mml:mi>d</mml:mi><mml:mn mathvariant="normal">43</mml:mn></mml:msub></mml:mrow></mml:math></inline-formula>.</p>
      <p id="d2e4500">The interstitial fluid was made viscous to resemble magma. However, the viscosity (10 Pa s) was  chosen to be significantly lower than that of magmas (10<sup>−1</sup>–10<sup>14</sup> Pa s, <xref ref-type="bibr" rid="bib1.bibx29" id="altparen.100"/>)  to decrease the computational cost of the simulation, as the purpose is to demonstrate the application to this field. The viscous number, <inline-formula><mml:math id="M203" display="inline"><mml:mrow><mml:mi>J</mml:mi><mml:mo>=</mml:mo><mml:mover accent="true"><mml:mi mathvariant="italic">γ</mml:mi><mml:mo mathvariant="normal">˙</mml:mo></mml:mover><mml:msub><mml:mi mathvariant="italic">η</mml:mi><mml:mi mathvariant="normal">f</mml:mi></mml:msub><mml:mo>/</mml:mo><mml:mi>P</mml:mi></mml:mrow></mml:math></inline-formula>, where <inline-formula><mml:math id="M204" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">η</mml:mi><mml:mi mathvariant="normal">f</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is the viscosity of the interstitial fluid, is commonly used in the study of granular suspensions <xref ref-type="bibr" rid="bib1.bibx9" id="paren.101"/>  and it is plotted in Fig. <xref ref-type="fig" rid="F12"/>b. The viscosity is higher on the sides due to frictional forces at the conduit walls, also shown to slow down the particles (Fig. <xref ref-type="fig" rid="F12"/>a).</p>
      <p id="d2e4570">The dimensionless effective shear viscosity, <inline-formula><mml:math id="M205" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">η</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mi mathvariant="italic">μ</mml:mi><mml:mo>/</mml:mo><mml:mi>J</mml:mi></mml:mrow></mml:math></inline-formula>, measures the competing shear viscosity from the particles and the fluid itself  <xref ref-type="bibr" rid="bib1.bibx9" id="paren.102"/>.  In Fig. <xref ref-type="fig" rid="F12"/>c <inline-formula><mml:math id="M206" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">η</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>&lt;</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:math></inline-formula>, implying that the presence of particles lowers the viscosity of the fluid. However, in Fig. 3 of <xref ref-type="bibr" rid="bib1.bibx9" id="text.103"/>, <inline-formula><mml:math id="M207" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">η</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>&lt;</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:math></inline-formula> for <inline-formula><mml:math id="M208" display="inline"><mml:mrow><mml:mi mathvariant="italic">ϕ</mml:mi><mml:mo>&lt;</mml:mo><mml:mn mathvariant="normal">0.3</mml:mn></mml:mrow></mml:math></inline-formula>. Therefore, for the low concentration of suspended particles (<inline-formula><mml:math id="M209" display="inline"><mml:mrow><mml:mi mathvariant="italic">ϕ</mml:mi><mml:mo>≪</mml:mo></mml:mrow></mml:math></inline-formula> 0.1) used in this example (see Fig. S9 of the Supplement), very low effective shear viscosity is to be expected.</p>

      <fig id="F12" specific-use="star"><label>Figure 12</label><caption><p id="d2e4656">DEM-CFD 2D numerical simulation representing non-spherical crystals suspended in magma <bold>(a)</bold>. The interstitial fluid was made viscous to resemble a magma mush. However, the viscosity was  chosen to be significantly lower than that of magma to decrease the computational cost of the simulation, as the purpose is to demonstrate an application. The coarse-grained fields of the viscous number (<inline-formula><mml:math id="M210" display="inline"><mml:mrow><mml:mi>J</mml:mi><mml:mo>=</mml:mo><mml:mover accent="true"><mml:mi mathvariant="italic">γ</mml:mi><mml:mo mathvariant="normal">˙</mml:mo></mml:mover><mml:msub><mml:mi mathvariant="italic">η</mml:mi><mml:mi mathvariant="normal">f</mml:mi></mml:msub><mml:mo>/</mml:mo><mml:mi>P</mml:mi></mml:mrow></mml:math></inline-formula>, where <inline-formula><mml:math id="M211" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">η</mml:mi><mml:mi mathvariant="normal">f</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is the viscosity of the interstitial fluid), and dimensionless effective shear viscosity (<inline-formula><mml:math id="M212" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">η</mml:mi><mml:mi mathvariant="normal">s</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mi mathvariant="italic">μ</mml:mi><mml:mo>/</mml:mo><mml:mi>J</mml:mi></mml:mrow></mml:math></inline-formula>) are presented in <bold>(b)</bold> and <bold>(c)</bold>, respectively.</p></caption>
            <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f12.png"/>

          </fig>

</sec>
<sec id="Ch1.S4.SS4.SSS4">
  <label>4.4.4</label><title>Pile-stabilised slopes</title>
      <p id="d2e4738">This example highlights the package's ability to (1) analyse and visualise Pysammos results entirely in Python, (2) resolve individual phases within a polydisperse mixture, and (3) straightforwardly assess each phase's contribution to the bulk properties of the mixture. DEM can also be used to study vertical load redistribution in loose sediment – for instance, in debris-flow deposits posing a risk to nearby communities and infrastructure. Here, we present a 2D DEM simulation of a growing granular pile, in which grains of different sizes are poured from above into a confined space between two walls 50 cm apart (Fig. <xref ref-type="fig" rid="F13"/>a). This model captures two combined effects: force-chain arching in a free-surface granular pile  <xref ref-type="bibr" rid="bib1.bibx12" id="paren.104"/>, and the Janssen effect, whereby vertical stress saturates with depth as it is redistributed laterally through friction at the side walls <xref ref-type="bibr" rid="bib1.bibx88" id="paren.105"/>.</p>
      <p id="d2e4749">Through this example we see that, near the peak of the pile, basal pressure exhibits a local minimum, rather than the maximum that a hydrostatic gradient of a fluid would predict directly beneath the peak (Fig. <xref ref-type="fig" rid="F13"/>d) – a phenomenon that has been documented experimentally <xref ref-type="bibr" rid="bib1.bibx12" id="paren.106"/>. This occurs because granular assemblies transmit stress anisotropically along chains of contacting grains, rather than isotropically as in fluids, redirecting stress sideways by “arching” it toward the flanks of the pile rather than accumulating it directly underneath. These arching structures are visible as high-magnitude bands in the total stress tensor magnitude field (Fig. <xref ref-type="fig" rid="F13"/>b). This effect is even more pronounced in this 2D configuration, compared to a 3D pile.</p>
      <p id="d2e4759">The mechanism behind this stress redistribution is more explicitly shown by the shear stress field (Fig. <xref ref-type="fig" rid="F13"/>c). Unlike the stress magnitude, which illustrates where stress locally intensifies, the sign of the shear stress specifies the direction in which load is being carried: shear stress is close to zero along the vertical centreline and grows with opposite sign toward each flank. This indeed confirms that weight is transported away from the pile’s apex in both lateral directions, rather than straight downward. The largest shear stress magnitudes do not occur at the side walls, but midway between the peak and the walls. This is consistent with force chain curving outward and downward through the pile before reaching the walls. This suggests force chain arching is probably the dominant redistribution mechanism here, with the walls providing at least a partial frictional contribution to support, consistent with a weakly-developed Janssen effect. This is visible in Fig. <xref ref-type="fig" rid="F13"/>e, where in the wall-confined region (heights of 0.005–0.03 m), horizontal stress increases with depth while vertical stress remains constant – indicating that the walls are supporting part of the pile's weight. We note that this apparent depth-independence of vertical stress is not expected to persist as the pile height grows, given that the wall-supported fraction of the total weight would saturate, while the unsupported fraction below saturation depth would grow with height approximately following a hydrostatic profile. Finally, we find that the different phases identified by grain diameter contribute differently to the bulk stress at different heights, although the relatively low polydispersity of this mixture means all phases contribute roughly equally to the bulk field along the profile.</p>

      <fig id="F13" specific-use="star"><label>Figure 13</label><caption><p id="d2e4769">Analysis of a 2D DEM simulation of a growing granular pile carried out with Pysammos's Python-supported visualisation. Simulation particles coloured by size <bold>(a)</bold>, coarse-grained magnitude of the total stress tensor <bold>(b)</bold> and shear stress <bold>(c)</bold> across the granular mixture. Coarse-grained basal vertical stresses, taken from the lowest row of CG cells, as a function of horizontal distance, testing for stress arching beneath the pile crest (dotted black line, <inline-formula><mml:math id="M213" display="inline"><mml:mrow><mml:mi>x</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0</mml:mn></mml:mrow></mml:math></inline-formula>) <bold>(d)</bold>. Vertical profiles, taken along the pile centre (<inline-formula><mml:math id="M214" display="inline"><mml:mrow><mml:mi>x</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0</mml:mn></mml:mrow></mml:math></inline-formula>) dotted line in <bold>(d)</bold>, of the horizontal stress of the mixture (grey solid line), vertical stress of the mixture (dashed blue line), and vertical stress of each of the phases with diameters 5.7, 4.7, 5.1, and 4.2 mm, in yellow, red, orange and blue, respectively <bold>(e)</bold>. </p></caption>
            <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f13.png"/>

          </fig>

</sec>
<sec id="Ch1.S4.SS4.SSS5">
  <label>4.4.5</label><title>Erodible granular beds</title>
      <p id="d2e4829">The following example showcases a feature of Pysammos that provides profiles of the coarse-grained fields along a given axis, averaging over the other two axes. This is suitable for post-processing DEM simulations that are close to constant in the directions in which the data are averaged, and show transient or gradual characteristics in the direction in which the profile is produced.  To illustrate this functionality, we present a DEM simulation of a monodisperse granular column, over an inclined (24<inline-formula><mml:math id="M215" display="inline"><mml:mi mathvariant="italic">°</mml:mi></mml:math></inline-formula>) rough base, sheared at the top by a rough plate, approximating the effect of an overriding flow (Fig. <xref ref-type="fig" rid="F14"/>a). The simulation was initially run with a fixed erodible bed until the overriding flow reached steady state, after which the bed was allowed to be mobilised by the flow.</p>
      <p id="d2e4841">Vertical profiles of the horizontal granular temperature (<inline-formula><mml:math id="M216" display="inline"><mml:mrow><mml:msub><mml:mi>T</mml:mi><mml:mi>x</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>), calculated according to Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S3.E25"/>) and alternative slice-averaging approaches <xref ref-type="bibr" rid="bib1.bibx89 bib1.bibx62" id="paren.107"/>, are averaged over the last second of erosion and shown in Fig. <xref ref-type="fig" rid="F14"/>c. The three methods are in agreement along the profile up to the height at which the flow becomes more dilute (Fig. <xref ref-type="fig" rid="F14"/>b), where the results yielded by the slice methods depart from Pysammos's.</p>
      <p id="d2e4864">The overall trend shows an increase of <inline-formula><mml:math id="M217" display="inline"><mml:mrow><mml:msub><mml:mi>T</mml:mi><mml:mi>x</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> with depth. In other words, towards the top of the column the particle velocity is more correlated to the velocity mean field. This implies that the erodible bed has been mobilised and entrained into the flow, and the bottom part is rattling as the rough base is hindering movement. This is manifested in the flow velocity as a typical Bagnold profile (Fig. <xref ref-type="fig" rid="F14"/>e), where most of the column is flowing at a constant velocity, affine to that of the overriding flow, below which there is a shear zone driven by  geometric friction induced by the rough-frictional base.</p>
      <p id="d2e4880">The instantaneous profiles, taken at a frequency of 10 Hz, are shown to oscillate by several orders of magnitude about the time averages of the first and last seconds of erosion (Fig. <xref ref-type="fig" rid="F14"/>d). Nevertheless, it is clear that it is a transient process, migrating from a shallow gradient to a steeper gradient with height, implying a dissipation of granular temperature through the column due to friction at the base. This is also seen in the velocity profiles, as the steady state is attained in the form of a Bagnold profile.</p>

      <fig id="F14" specific-use="star"><label>Figure 14</label><caption><p id="d2e4888">DEM simulation describing a tilted erodible granular column (24<inline-formula><mml:math id="M218" display="inline"><mml:mi mathvariant="italic">°</mml:mi></mml:math></inline-formula>) sheared by a rough plate at the top, approximating the effect of an overriding flow <bold>(a)</bold>. Instantaneous vertical profiles of the coarse-grained volume fraction, <inline-formula><mml:math id="M219" display="inline"><mml:mi mathvariant="italic">φ</mml:mi></mml:math></inline-formula> <bold>(b)</bold>. Time averages of alternative calculations of the horizontal component of the continuum granular temperature field, <inline-formula><mml:math id="M220" display="inline"><mml:mrow><mml:msub><mml:mi>T</mml:mi><mml:mi>x</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>, such as that presented in <xref ref-type="bibr" rid="bib1.bibx89" id="text.108"/>, and that implemented in LAMMPS <xref ref-type="bibr" rid="bib1.bibx62" id="paren.109"/> <bold>(c)</bold>. Instantaneous vertical profiles of the horizontal granular temperature (purple-yellow) shown alongside the time averaged profiles corresponding to the first (solid red) and last (dashed red) seconds of simulation <bold>(d)</bold>. Instantaneous vertical profiles of velocity magnitude, <inline-formula><mml:math id="M221" display="inline"><mml:mrow><mml:mo>|</mml:mo><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>|</mml:mo></mml:mrow></mml:math></inline-formula>, shown alongside the average over the first (solid red) and last (dashed red) seconds of simulation <bold>(e)</bold>.</p></caption>
            <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f14.png"/>

          </fig>

</sec>
</sec>
</sec>
<sec id="Ch1.S5">
  <label>5</label><title>Discussion</title>
      <p id="d2e4967">In this section we discuss the strengths and limitations of Pysammos and hence recommend practices when employing it, as well as reflecting on the contributions to the DEM community, and outline the ongoing work and paths for future work. </p>
<sec id="Ch1.S5.SS1">
  <label>5.1</label><title>Recommended practice: strengths and caveats</title>
<sec id="Ch1.S5.SS1.SSS1">
  <label>5.1.1</label><title>Choice of smoothing function</title>
      <p id="d2e4985">The benchmark of Pysammos against other codes shows that the CG fields are congruent with those obtained from other software. The results from the Gaussian and Lucy smoothing functions show similar results, whereas the fields calculated with the Heaviside function have a larger spread and offset on some occasions. This could be due to the fact that the Heaviside function weights all the particles within the search diameter equally hence exacerbating edge effects, whereas the Gaussian and Lucy functions heavily damp the contribution from particles further from the evaluation point.  Nevertheless, the Gaussian function in Pysammos has an imposed cut-off, making it not perfectly smooth and thus non-differentiable, violating the condition that must be satisfied by the differential conservation equations <xref ref-type="bibr" rid="bib1.bibx5" id="paren.110"/>. Therefore, we recommend the Lucy weighting function over the Gaussian and Heaviside functions. </p>
</sec>
<sec id="Ch1.S5.SS1.SSS2">
  <label>5.1.2</label><title>Choice of smoothing width</title>
      <p id="d2e5000">The choice of smoothing width, <inline-formula><mml:math id="M222" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula>, is not trivial. <xref ref-type="bibr" rid="bib1.bibx84" id="text.111"/> show that the CG fields are independent of the smoothing width for a finite range of <inline-formula><mml:math id="M223" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula> values, which in turn vary with flow regimes and time averaging windows. For case studies exhibiting flow regimes ranging from quasi-static to inertial, as observed in natural flows, studies find that a <inline-formula><mml:math id="M224" display="inline"><mml:mrow><mml:mn mathvariant="normal">0.5</mml:mn><mml:mo>&lt;</mml:mo><mml:mi>w</mml:mi><mml:mo>/</mml:mo><mml:mi>d</mml:mi><mml:mo>&lt;</mml:mo><mml:mn mathvariant="normal">1.5</mml:mn></mml:mrow></mml:math></inline-formula> is suitable to capture stable results in all the zones corresponding to the different flow regimes <xref ref-type="bibr" rid="bib1.bibx31 bib1.bibx84" id="paren.112"/>. Hence, in Pysammos we have implemented a default value of <inline-formula><mml:math id="M225" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula> to be <inline-formula><mml:math id="M226" display="inline"><mml:mrow><mml:msub><mml:mi>w</mml:mi><mml:mi mathvariant="normal">default</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0.75</mml:mn><mml:msub><mml:mi>d</mml:mi><mml:mn mathvariant="normal">43</mml:mn></mml:msub></mml:mrow></mml:math></inline-formula>, used in most of our examples. Anyhow, we highlight the importance of investigating the stability of the obtained results given the employed <inline-formula><mml:math id="M227" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula> on the user's specific case study.</p>
      <p id="d2e5078"><xref ref-type="bibr" rid="bib1.bibx30" id="text.113"/> showed that the kinetic tensor is intrinsically dependent on the smoothing width (<inline-formula><mml:math id="M228" display="inline"><mml:mrow><mml:mo>∼</mml:mo><mml:msup><mml:mi>w</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula>),  due to the captured velocity gradients between the particle position and the point at which the CG fields are evaluated. The kinetic tensor can be decomposed into a scale-independent and scale-dependent components. The scale-independent contribution involves the local fluctuation velocity <inline-formula><mml:math id="M229" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>*</mml:mo></mml:msubsup></mml:mrow></mml:math></inline-formula>  (Eq. <xref ref-type="disp-formula" rid="Ch1.E7"/>), and is used to evaluate granular temperature, as this is a quantity that captures the particle's perspective. The scale-dependent contribution arises from velocity gradients in the coarse-grained velocity field. Although a scale-independent kinetic tensor would be desirable <xref ref-type="bibr" rid="bib1.bibx84" id="paren.114"/>, the velocity gradients causing the scale dependence contain valuable information about the stress state and are therefore necessary for evaluating the total stress tensor.</p>
      <p id="d2e5114">In the example of granular suspensions (Sect. <xref ref-type="sec" rid="Ch1.S4.SS4.SSS3"/>), we chose <inline-formula><mml:math id="M230" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">4</mml:mn><mml:msub><mml:mi>w</mml:mi><mml:mi mathvariant="normal">default</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> given the low volume fraction of the mixture. In doing so, when computing contact-related fields, such as pressure, the code averages nearby contacts where there are no particles, and vice versa. This might result in some artefacts and it should be accounted for in the result interpretation. For this reason, while we are confident in the robustness of Pysammos when applied to dense granular mixtures, we do recommend the user be rigorous when assessing the implications of the CG results of a dilute granular flow according to the mathematical formulations behind the software.</p>
</sec>
<sec id="Ch1.S5.SS1.SSS3">
  <label>5.1.3</label><title>Phase detection algorithm</title>
      <p id="d2e5144">Mixture theory conceives granular mixtures to be populated by all phases with associated partial macroscopic fields contributing to a bulk field, where a phase can be defined as any particle property, or combination of properties, such as density, size, shape, elasticity, roughness <xref ref-type="bibr" rid="bib1.bibx79" id="paren.115"/>.</p>
      <p id="d2e5150">In Pysammos we consider a phase to be defined by particle diameter and density, since they are two properties directly related to the two main competing mechanisms in segregation – kinetic sieving and buoyancy <xref ref-type="bibr" rid="bib1.bibx20 bib1.bibx76" id="paren.116"/> –, ubiquitous processes in natural flows. Nevertheless, we would like to stress that this is a developer's choice of phase definition, and that the users should consider if this feature is relevant for their research.</p>
      <p id="d2e5156">The phase detection algorithm is based on clustering separation, which has been reported to perform better in clearly separated, round clusters  <xref ref-type="bibr" rid="bib1.bibx55" id="paren.117"/>. Hence, in granular mixtures with low polydispersity the phase detection algorithm would struggle to separate the mixture into phases, yielding arbitrary phases that depend on the choice of minimum number of clusters.</p>
      <p id="d2e5162">On the other hand, highly polydisperse mixtures would have to be handled carefully, as the smoothing widths depend on the characteristic particle size of the mixture. For instance, a large proportion of large particles might shift that average upwards, resulting in a smoothing width that could potentially obscure small particle behaviour. Therefore, we recommend the user to be cautious when coarse-graining polydisperse mixtures and perform stability and verification tests to ensure relevant and reliable information is being recovered.</p>
      <p id="d2e5166">From an implementation standpoint, phase detection is only performed on the first time step, producing a phase-ascribed array that is used to classify particles into phases in the subsequent time steps. If the polydisperse calculation of CG is applied to open systems (e.g., new particles are incorporated throughout the simulation), the phase array can no longer be matched to the particle data, as they will have different lengths.</p>
</sec>
<sec id="Ch1.S5.SS1.SSS4">
  <label>5.1.4</label><title>Coarse-graining non-spherical grains</title>
      <p id="d2e5177">The mathematical foundation of the weighted spatial average implemented in Pysammos makes no assumptions about the shape of the particles <xref ref-type="bibr" rid="bib1.bibx5" id="paren.118"/>. Hence, we are able to coarse-grain particles of any shape, as we have shown in the Results section. DEM software like MFiX – for which Pysammos is principally conceived – exports particle properties and information, including the total force and the geometric centre of the overlapping volume <xref ref-type="bibr" rid="bib1.bibx26" id="paren.119"/>.  Notably, Pysammos requires the total force between particle pairs, an export that is available only from MFiX-25 onwards.</p>
      <p id="d2e5186">The current MFiX release also supports the representation of irregular shapes via glued-sphere particles (GSP) <xref ref-type="bibr" rid="bib1.bibx51" id="paren.120"/>. However, rather than exporting data for the individual bounding GSP – as required for CG in Pysammos – the current release exports data for the component spheres only. This limitation is being actively addressed in collaboration with the MFiX team, and in the interim, component-sphere data can be coarse-grained at the GSP scale to yield reasonable results. Section <xref ref-type="sec" rid="Ch1.S5.SS3"/> illustrates what is currently achievable and outlines forthcoming capabilities.</p>
</sec>
<sec id="Ch1.S5.SS1.SSS5">
  <label>5.1.5</label><title>Coarse-graining near the boundaries</title>
      <p id="d2e5203">Pysammos accounts for particles being positioned near cyclic boundaries, hence being in contact with particles at the opposite edge of the model, by calculating displacements to the nearest periodic equivalent. For that reason, we can say it is safe to generate a mesh as wide as the extent of the model between periodic boundaries, as long as the cyclic axes are provided in the configuration file. On the other hand, Pysammos does not take into account the effect of hard boundaries in the contact stress tensor, as described in <xref ref-type="bibr" rid="bib1.bibx83" id="text.121"/>. Therefore, we advise users to avoid including particles in contact with walls in the extent of the generated mesh by entering suitable axes mesh ranges in the configuration file.</p>
</sec>
<sec id="Ch1.S5.SS1.SSS6">
  <label>5.1.6</label><title>Optimal resource request</title>
      <p id="d2e5217">Concerning the efficiency of the program as it uses more cores, we see that the benefit of additional parallelism depends strongly on the coarse-graining resolution and system size. Although Numba reduces overhead, gains from additional cores at sub-particle resolution (<inline-formula><mml:math id="M231" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>&lt;</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>) are limited, most likely due to the memory-bound nature of the algorithms to which Numba is applied, where the number of particles per grid point is too small to sufficiently amortise this cost.</p>
      <p id="d2e5232">The optimal resource request therefore depends on the coarse-graining resolution. At high resolution (<inline-formula><mml:math id="M232" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>&lt;</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>), a low number of cores (e.g., 2) is sufficient to attain optimal computational efficiency. At lower resolutions (<inline-formula><mml:math id="M233" display="inline"><mml:mrow><mml:mi>w</mml:mi><mml:mo>&gt;</mml:mo><mml:mi>d</mml:mi></mml:mrow></mml:math></inline-formula>), parallelism provides more substantial gains – for the dense granular packings considered here, between 4 and 16 cores is advisable for large systems (<inline-formula><mml:math id="M234" display="inline"><mml:mrow><mml:msub><mml:mi>N</mml:mi><mml:mi mathvariant="normal">particles</mml:mi></mml:msub><mml:mo>&gt;</mml:mo><mml:msup><mml:mn mathvariant="normal">10</mml:mn><mml:mn mathvariant="normal">5</mml:mn></mml:msup></mml:mrow></mml:math></inline-formula>). It is worth noting that this guidance is specific to dense packings and may vary for sparser or more heterogeneous systems.</p>
      <p id="d2e5277">In either case, efficient use of Pysammos does not require extensive parallel resources, making it well suited for shared memory computational systems. Enhanced parallel performance can further be attained by distributing independent time slices across different shared-memory processes – either as an alternative to, or in combination with, increasing the number of cores assigned to a single task.</p>
</sec>
</sec>
<sec id="Ch1.S5.SS2">
  <label>5.2</label><title>Contributions to the DEM community</title>
      <p id="d2e5289">The DEM community is inherently interdisciplinary due to the ubiquity of granular processes in nature, engineering and industry. This naturally prompted the development of a range of DEM software, both open and closed source. In academic research open-source software is favoured from an ethical point of view. However, some open-source DEM software packages do not offer CG post-processing functionalities (e.g., MFiX), leading to the production of individual codes that do not tend to be widely shared, hindering reproducibility and increasing the likelihood of error propagation. Other DEM software might employ other averaging methodologies (e.g., LAMMPS, YADE). Stand-alone CG software might find their flexibility is limited by data format diversity (e.g., MercuryCG), forcing the user to convert data files. Recent efforts in the DEM community focus on standardising workflows and interoperability-related aspects to facilitate reproducibility and direct comparison of results across DEM software and users.</p>
      <p id="d2e5292">Pysammos aims to contribute to this endeavour. Firstly, it provides a CG tool for MFiX, thus avoiding file conversion and duplication of privately produced CG codes, and ensuring consistency in outputs across MFiX users. Secondly, it is user-friendly and Python-based, to promote usage in several areas of academic research. Further, it is conceived as an open-source tool, inviting others to develop it further to be adapted to other DEM software. This is facilitated by its modular structure and the provided benchmarked examples to ensure consistency. Finally, it provides a streamlined visualisation in widely used open-source visualisation software ParaView.</p>
</sec>
<sec id="Ch1.S5.SS3">
  <label>5.3</label><title>Work in progress with MFiX: Glued-sphere particle simulations</title>
      <p id="d2e5303">Although the current MFiX release does not export individual bounding GSP data, component-sphere <italic>particle</italic> data can be coarse-grained at the GSP scale in the interim to yield reasonable results. The following example demonstrates Pysammos's ability to handle DEM simulations involving complex particle shapes represented by GSP, with the expectation that fully rigorous GSP-level CG will become possible once the relevant MFiX export functionality is complete. This is particularly relevant for applications such as volcanic ash, whose angular morphology produces rougher particle surfaces that directly influence the bulk flow behaviour of such mixtures <xref ref-type="bibr" rid="bib1.bibx24" id="paren.122"/>.</p>

      <fig id="F15" specific-use="star"><label>Figure 15</label><caption><p id="d2e5314">DEM simulation of a granular bed, fluidised with a gas velocity of 2 m s<sup>−1</sup>, using glued-sphere particles <bold>(a)</bold>. Reconstructed ash particle shape from <xref ref-type="bibr" rid="bib1.bibx24" id="text.123"/> <bold>(b)</bold>, to which the glued-sphere particles in <bold>(a)</bold> are approximated, as shown in <bold>(c)</bold>. Coarse-grained fields of the volume fraction <bold>(d)</bold> and vertical granular temperature <bold>(e)</bold> corresponding to the simulation time step shown in <bold>(a)</bold>. Note that the pale green colour in <bold>(e)</bold> indicates NaN. This occurs at locations where <inline-formula><mml:math id="M236" display="inline"><mml:mrow><mml:msub><mml:mi>T</mml:mi><mml:mi>y</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is set to 0 m<sup>2</sup> s<sup>−2</sup> by convention (see Appendix <xref ref-type="sec" rid="App1.Ch1.S3.SS2"/>). Consequently, log<inline-formula><mml:math id="M239" display="inline"><mml:mrow><mml:msub><mml:mi/><mml:mn mathvariant="normal">10</mml:mn></mml:msub><mml:mo>(</mml:mo><mml:mn mathvariant="normal">0</mml:mn><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> is undefined and is represented  as NaN in ParaView.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f15.png"/>

        </fig>

      <p id="d2e5414">To this end, we use the MFiX feature that approximates a glued-sphere particle to a target shape supplied in stereolithographic (STL) format to simulate a fluidised granular bed of volcanic ash particles (Fig. <xref ref-type="fig" rid="F15"/>). The GSP geometry is fitted to that of an ash particle, obtained from the X-ray micro-tomography by <xref ref-type="bibr" rid="bib1.bibx24" id="text.124"/>, and scaled up to reduce computational cost (Fig. <xref ref-type="fig" rid="F15"/>b–c). The granular bed is fluidised through a basal inlet at 2 m s<sup>−1</sup>, generating large bubbles that rise through the bed, as visible in the volume fraction field (Fig. <xref ref-type="fig" rid="F15"/>d). The transition between dense and collisional flow regimes is reflected in a gradient in the vertical granular temperature (Fig. <xref ref-type="fig" rid="F15"/>e). </p>
</sec>
<sec id="Ch1.S5.SS4">
  <label>5.4</label><title>Future work</title>
      <p id="d2e5451">The ethos behind Pysammos is heavily weighted by the idea of open-source code, well documented and structured to facilitate maintenance and future developments. The first version offers a range of advantageous features suitable for different types of users, nevertheless, there are aspects that can be further developed. Below we outline several implementations that would enhance the functionalities of this code package.</p>
      <p id="d2e5454">In order to work towards standardising and streamlining DEM post-processing software, future versions of this code package should incorporate data reading modules that are compatible with data from other DEM software, such as LAMMPS (available in the next release) or YADE, to fit the array structure that is used in the core functions. The current architecture is already designed to host new data readers. Regarding meshing, at present Pysammos offers a structured cuboid grid, a choice that is not optimal for all spatial model configurations. Greater flexibility in the meshing scheme would enable better alignment with complex geometries and minimise unnecessary sampling. Finally, the coarse-grained fields implemented in Pysammos are not taking into account the effect of hard boundaries as described in <xref ref-type="bibr" rid="bib1.bibx83" id="text.125"/>, as it modifies the contact stress tensor. Therefore, future versions of this code should implement the calculation of the contact stress tensor for those particles in direct contact with the walls of a DEM model.</p>
</sec>
</sec>
<sec id="Ch1.S6" sec-type="conclusions">
  <label>6</label><title>Conclusions</title>
      <p id="d2e5469">Granular flows, widespread in both natural systems and industrial applications, remain challenging to understand due to their highly complex particle–particle and particle–fluid interactions. DEM–CFD approaches provide detailed particle-scale information, but extracting relevant macroscopic continuum fields requires robust coarse-graining methodologies. In this work, we present Pysammos, a user-friendly, open-source Python package designed to streamline the coarse-graining of DEM data generated with MFiX and visualisation of results. The workflow enables flexible variable selection, mesh parametrisation, and phase-specific analysis of polydisperse mixtures of any particle shape. It produces vtkhdf outputs readily compatible with ParaView, as well as generic h5 files for further analysis. Its favourable algorithmic complexity allows it to run on standard computers or HPC systems with minimal computational overhead. We also demonstrate several key functionalities and exemplar applications, and provide guidance on best practices to ensure robust and reliable use of the code.</p>
</sec>

      
      </body>
    <back><app-group>

<app id="App1.Ch1.S1">
  <label>Appendix A</label><title>Input File Information</title>
      <p id="d2e5484">This appendix describes the input files required by Pysammos. As indicated in Fig. <xref ref-type="fig" rid="F1"/>, these consist of a plain text configuration file, a particle properties file and a particle contacts file.</p>
      <p id="d2e5489">Listing  <xref ref-type="fig" rid="LiA1"/> shows the configuration file format. For further details, visit the online documentation at <uri>https://claudia-elijas.github.io/pysammos/</uri> (last access: 1 October 2026). The file is organised into sections, each marked by a header in square brackets, as described below.</p>
      <p id="d2e5497">The <monospace>paths</monospace> section specifies the path to the input files, for the particle properties and the particle contacts, and the path to the output directory. The <monospace>timesteps</monospace> section defines the time range of the CG analysis: <monospace>t0</monospace> and <monospace>tf</monospace> are the first and last time steps, and <monospace>td</monospace> is the DEM file interval. The <monospace>smoothing_function</monospace> section specifies the weighting function for the CG, which may be <monospace>Lucy</monospace>, <monospace>Gaussian</monospace>, or <monospace>HeavySide</monospace>. The <monospace>grid_info</monospace> and <monospace>fields_to_export</monospace> sections control the CG meshing parameters and the set of continuum fields written to disk, respectively. The <monospace>output_options</monospace> section specifies the output format.</p>
      <p id="d2e5538">The <monospace>key_mapping</monospace> section maps the DEM simulation data fields to the keys expected by the source code in Pysammos. The required particle data consists of: particle ID, velocity, diameter (or radius), density, volume, mass, and optionally coordination number. The required contact data consists of: particle IDs of the two particles involved in each recorded collision, force acting on the first particle, and contact point (optional).</p><fig id="LiA1" specific-use="star"><label>Listing A1</label><caption><p id="d2e5548">Configuration file for the bedload transport example provided in the online documentation. </p></caption>
        <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-l03.png"/>

      </fig>


</app>

<app id="App1.Ch1.S2">
  <label>Appendix B</label><title>Algorithms</title>
      <p id="d2e5567">This appendix contains the description of specific algorithms used in the core code.</p>
<sec id="App1.Ch1.S2.SS1">
  <label>B1</label><title>KMeans algorithm</title>
      <p id="d2e5577">The phase detection is carried out by clustering particle data with Python's KMeans <xref ref-type="bibr" rid="bib1.bibx61" id="paren.126"/>. The <inline-formula><mml:math id="M241" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-means algorithm, also referred to as Lloyd's algorithm <xref ref-type="bibr" rid="bib1.bibx55 bib1.bibx50" id="paren.127"/>, consists of the following steps: given a set <inline-formula><mml:math id="M242" display="inline"><mml:mi>X</mml:mi></mml:math></inline-formula> of <inline-formula><mml:math id="M243" display="inline"><mml:mi>N</mml:mi></mml:math></inline-formula> samples, it assigns an initial set  <inline-formula><mml:math id="M244" display="inline"><mml:mi>C</mml:mi></mml:math></inline-formula>  of <inline-formula><mml:math id="M245" display="inline"><mml:mi>K</mml:mi></mml:math></inline-formula> clusters and allocates each sample to its nearest cluster; subsequently, it generates new centroids (i.e., mean <inline-formula><mml:math id="M246" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">μ</mml:mi><mml:mi>j</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> of the samples previously assigned to it); takes the difference between the previous and updated centroids and iterates until this difference stabilises, or similarly, inertia or the within-cluster sum-of-squares is minimised (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S2.E12"/>).

            <disp-formula id="App1.Ch1.S2.E12" content-type="numbered"><label>B1</label><mml:math id="M247" display="block"><mml:mrow><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>i</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>N</mml:mi></mml:munderover><mml:munder><mml:mo movablelimits="false">min⁡</mml:mo><mml:mrow><mml:msub><mml:mi mathvariant="italic">μ</mml:mi><mml:mi>j</mml:mi></mml:msub><mml:mo>∈</mml:mo><mml:mi>C</mml:mi></mml:mrow></mml:munder><mml:mo>(</mml:mo><mml:mo>|</mml:mo><mml:mo>|</mml:mo><mml:msub><mml:mi>X</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="italic">μ</mml:mi><mml:mi>j</mml:mi></mml:msub><mml:mo>|</mml:mo><mml:mo>|</mml:mo><mml:mo>)</mml:mo></mml:mrow></mml:math></disp-formula>

          Nevertheless this method assumes the clusters are convex and isotropic, resulting in a lower accuracy when applied to elongated clusters. Further, Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S2.E12"/>) does not represent a normalised metric, hence it is best used in relative terms within the same scaled dataset and should be used in conjunction with other metrics to decide the optimal number of clusters. For instance, the silhouette analysis calculates the distance from each point in one cluster  to the neighbouring clusters and thus provides a more robust approach to assess the optimum number of clusters <inline-formula><mml:math id="M248" display="inline"><mml:mi>K</mml:mi></mml:math></inline-formula> that fit the dataset <inline-formula><mml:math id="M249" display="inline"><mml:mi>X</mml:mi></mml:math></inline-formula>.</p>
</sec>
<sec id="App1.Ch1.S2.SS2">
  <label>B2</label><title><inline-formula><mml:math id="M250" display="inline"><mml:mi>K</mml:mi></mml:math></inline-formula>-<inline-formula><mml:math id="M251" display="inline"><mml:mi>d</mml:mi></mml:math></inline-formula> tree search algorithm</title>
      <p id="d2e5729">The particle search within a finite volume around a grid point is carried out with Python <monospace>scipy.spatial</monospace>'s <monospace>cKDTree</monospace> class, which implements the <inline-formula><mml:math id="M252" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-<inline-formula><mml:math id="M253" display="inline"><mml:mi>d</mml:mi></mml:math></inline-formula> tree form of nearest neighbour search to find all points within a radius of a query <xref ref-type="bibr" rid="bib1.bibx80" id="paren.128"/>.</p>
      <p id="d2e5755">A <inline-formula><mml:math id="M254" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-<inline-formula><mml:math id="M255" display="inline"><mml:mi>d</mml:mi></mml:math></inline-formula> tree is a data structure built from recursively bisecting the search space in every dimension and collecting the coordinates of those splitting planes (Fig. <xref ref-type="fig" rid="FB1"/>). In three dimensions, the space is first bisected through the median of the data along the <inline-formula><mml:math id="M256" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula>-axis, and subsequently divided along the <inline-formula><mml:math id="M257" display="inline"><mml:mi>y</mml:mi></mml:math></inline-formula>-axis and finally, along the <inline-formula><mml:math id="M258" display="inline"><mml:mi>z</mml:mi></mml:math></inline-formula>-axis (Fig. <xref ref-type="fig" rid="FB1"/>b). This procedure is recursively applied until the tree is built. Then, the search begins at the root and descends through the levels of the tree (Fig. <xref ref-type="fig" rid="FB1"/>a). The  branches are chosen based on the proximity of the query value to either of the split planes. This process is repeated alternating dimensions at each level until the subregions between splitting planes get sufficiently small. All points within a given radius from the query point are recorded. </p>

      <fig id="FB1"><label>Figure B1</label><caption><p id="d2e5803">Simplified example of a <inline-formula><mml:math id="M259" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-<inline-formula><mml:math id="M260" display="inline"><mml:mi>d</mml:mi></mml:math></inline-formula>-tree in 2D <bold>(a)</bold> corresponding to the divisions in space shown in <bold>(b)</bold>. Each level of the tree corresponds to a labelled line in the spatial visualisation. The levels of the tree alternate in axes (e.g., <inline-formula><mml:math id="M261" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula> is vertical, <inline-formula><mml:math id="M262" display="inline"><mml:mi>B</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M263" display="inline"><mml:mi>C</mml:mi></mml:math></inline-formula> are horizontal). Note that only a single branch is built completely, while others stop in earlier levels. </p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f16.png"/>

        </fig>

      <p id="d2e5855">Opposite branches are also visited if the splitting plane lies within the search radius of the query point. The construction of the tree shows a computational complexity of <inline-formula><mml:math id="M264" display="inline"><mml:mrow><mml:mi>O</mml:mi><mml:mo>(</mml:mo><mml:mi>N</mml:mi><mml:mi>log⁡</mml:mi><mml:mi>N</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>, and the search of the tree, <inline-formula><mml:math id="M265" display="inline"><mml:mrow><mml:mi>O</mml:mi><mml:mo>(</mml:mo><mml:mi>log⁡</mml:mi><mml:mi>N</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> <xref ref-type="bibr" rid="bib1.bibx72" id="paren.129"/>.</p>
</sec>
<sec id="App1.Ch1.S2.SS3">
  <label>B3</label><title>Lookup table algorithm</title>
      <p id="d2e5903">To speed up repeated evaluations of the CG weights for particle-grid point pairs, we implemented a lookup table algorithm <xref ref-type="bibr" rid="bib1.bibx23" id="paren.130"/>. This method discretises the input domain, and subsequently, evaluates the target function at those discrete points. The discretised points and their corresponding values yielded by the function are stored in a lookup table, with a corresponding index. Next, the continuous query values are mapped to the discrete index of the lookup table by dividing by the step size and rounding down.</p>

      <fig id="FB2"><label>Figure B2</label><caption><p id="d2e5911">Schematic diagram of the lookup table algorithm implemented in Pysammos. <inline-formula><mml:math id="M266" display="inline"><mml:mi>r</mml:mi></mml:math></inline-formula> corresponds to the distance between a particle and a grid point. The resolution of the lookup table is res. <inline-formula><mml:math id="M267" display="inline"><mml:mrow><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi>r</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> is the coarse-graining function, and <inline-formula><mml:math id="M268" display="inline"><mml:mi>c</mml:mi></mml:math></inline-formula> corresponds to its cut-off distance (i.e., <inline-formula><mml:math id="M269" display="inline"><mml:mrow><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi>c</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0</mml:mn></mml:mrow></mml:math></inline-formula>). </p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f17.png"/>

        </fig>

      <p id="d2e5966">In Pysammos, the input domain consists of distances up to the cut-off distance, the target function is the CG weighting function, and the query values are the distances between grid points and particles near each grid point (Fig. <xref ref-type="fig" rid="FB2"/>).  The application of a lookup table algorithm to CG weight calculation is particularly advantageous because the amount of particles that could physically be within a usual CG volume is finite, and therefore it scales well as the number of particles and grid points increases. Therefore, this approach avoids redundant computation, achieving the efficient retrieval of CG weights.</p>
</sec>
</app>

<app id="App1.Ch1.S3">
  <label>Appendix C</label><title>Continuum fields</title>
      <p id="d2e5980">This appendix details the calculation of the continuum fields output by Pysammos, in addition to those described in Sect. <xref ref-type="sec" rid="Ch1.S2"/>.</p>
<sec id="App1.Ch1.S3.SS1">
  <label>C1</label><title>Fundamental fields</title>
      <p id="d2e5992">The most fundamental CG fields are presented below, from which additional fields may be derived (Appendix <xref ref-type="sec" rid="App1.Ch1.S3.SS2"/>). The macroscopic volume fraction, <inline-formula><mml:math id="M270" display="inline"><mml:mi mathvariant="italic">ϕ</mml:mi></mml:math></inline-formula>, is given by Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S3.E13"/>):

            <disp-formula id="App1.Ch1.S3.E13" content-type="numbered"><label>C1</label><mml:math id="M271" display="block"><mml:mrow><mml:mi mathvariant="italic">ϕ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>i</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>N</mml:mi></mml:munderover><mml:msub><mml:mi mathvariant="italic">ν</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo><mml:mo>,</mml:mo></mml:mrow></mml:math></disp-formula>

          where <inline-formula><mml:math id="M272" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">ν</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is the volume of particle <inline-formula><mml:math id="M273" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula>.</p>
      <p id="d2e6086">The macroscopic velocity field, <inline-formula><mml:math id="M274" display="inline"><mml:mi mathvariant="bold-italic">V</mml:mi></mml:math></inline-formula>, is defined as the ratio between the momentum density vector,  <inline-formula><mml:math id="M275" display="inline"><mml:mi mathvariant="bold-italic">p</mml:mi></mml:math></inline-formula> (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E14"/>), and the mass density fields (Eq. <xref ref-type="disp-formula" rid="Ch1.E2"/>), as shown in Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S3.E15"/>).

            <disp-formula id="App1.Ch1.S3.E14" content-type="numbered"><label>C2</label><mml:math id="M276" display="block"><mml:mrow><mml:mi mathvariant="bold-italic">p</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>i</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>N</mml:mi></mml:munderover><mml:msub><mml:mi>m</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:msub><mml:mi mathvariant="bold-italic">v</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo><mml:mo>,</mml:mo></mml:mrow></mml:math></disp-formula>

          where <inline-formula><mml:math id="M277" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">v</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is particle velocity.

            <disp-formula id="App1.Ch1.S3.E15" content-type="numbered"><label>C3</label><mml:math id="M278" display="block"><mml:mrow><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:mi mathvariant="bold-italic">p</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow><mml:mrow><mml:mi mathvariant="italic">ρ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mfrac></mml:mstyle></mml:mrow></mml:math></disp-formula></p>
      <p id="d2e6234">The fabric tensor (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E16"/>) describes the contact orientation distribution <xref ref-type="bibr" rid="bib1.bibx84" id="paren.131"/>.

            <disp-formula id="App1.Ch1.S3.E16" content-type="numbered"><label>C4</label><mml:math id="M279" display="block"><mml:mtable class="split" rowspacing="0.2ex" displaystyle="true" columnalign="right left"><mml:mtr><mml:mtd><mml:mrow><mml:mi mathvariant="bold">F</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mo>=</mml:mo><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>i</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>N</mml:mi></mml:munderover><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>j</mml:mi><mml:mo>=</mml:mo><mml:mi>i</mml:mi><mml:mo>+</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mi>N</mml:mi></mml:munderover><mml:munderover><mml:mo movablelimits="false">∑</mml:mo><mml:mrow><mml:mi>k</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow><mml:mrow><mml:msub><mml:mi>C</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:munderover><mml:msub><mml:mi mathvariant="italic">ν</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:msubsup><mml:mi mathvariant="bold-italic">n</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow><mml:mi>k</mml:mi></mml:msubsup><mml:mo>⊗</mml:mo><mml:msubsup><mml:mi mathvariant="bold-italic">n</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow><mml:mi>k</mml:mi></mml:msubsup></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:munderover><mml:mo movablelimits="false">∫</mml:mo><mml:mn mathvariant="normal">0</mml:mn><mml:mn mathvariant="normal">1</mml:mn></mml:munderover><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>+</mml:mo><mml:mi>s</mml:mi><mml:msubsup><mml:mi mathvariant="bold-italic">a</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow><mml:mi>k</mml:mi></mml:msubsup><mml:mo>)</mml:mo><mml:mi mathvariant="normal">d</mml:mi><mml:mi>s</mml:mi><mml:mo>,</mml:mo></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula>

          where <inline-formula><mml:math id="M280" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">n</mml:mi><mml:mrow><mml:mi>i</mml:mi><mml:mi>j</mml:mi></mml:mrow><mml:mi>k</mml:mi></mml:msubsup></mml:mrow></mml:math></inline-formula> is the contact normal unit vector.</p>
</sec>
<sec id="App1.Ch1.S3.SS2">
  <label>C2</label><title>Secondary fields</title>
      <p id="d2e6412">The continuum fields, derived from fundamental fields, calculated in Pysammos are presented below.</p>
      <p id="d2e6415">The area-weighted and volume-weighted average diameter are calculated according to Eqs. (<xref ref-type="disp-formula" rid="App1.Ch1.S3.E17"/>) and (<xref ref-type="disp-formula" rid="App1.Ch1.S3.E18"/>), respectively.The coarse-grained coordination number <inline-formula><mml:math id="M281" display="inline"><mml:mi>Z</mml:mi></mml:math></inline-formula> is given by Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S3.E19"/>).

                <disp-formula specific-use="gather" content-type="numbered"><mml:math id="M282" display="block"><mml:mtable displaystyle="true"><mml:mlabeledtr id="App1.Ch1.S3.E17"><mml:mtd><mml:mtext>C5</mml:mtext></mml:mtd><mml:mtd><mml:mrow><mml:mstyle class="stylechange" displaystyle="true"/><mml:mi>d</mml:mi><mml:mn mathvariant="normal">32</mml:mn><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:mo>∑</mml:mo><mml:msubsup><mml:mi>d</mml:mi><mml:mi>i</mml:mi><mml:mn mathvariant="normal">3</mml:mn></mml:msubsup><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo></mml:mrow><mml:mrow><mml:mo>∑</mml:mo><mml:msubsup><mml:mi>d</mml:mi><mml:mi>i</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msubsup><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo></mml:mrow></mml:mfrac></mml:mstyle></mml:mrow></mml:mtd></mml:mlabeledtr><mml:mlabeledtr id="App1.Ch1.S3.E18"><mml:mtd><mml:mtext>C6</mml:mtext></mml:mtd><mml:mtd><mml:mrow><mml:mstyle displaystyle="true" class="stylechange"/><mml:mi>d</mml:mi><mml:mn mathvariant="normal">43</mml:mn><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:mo>∑</mml:mo><mml:msubsup><mml:mi>d</mml:mi><mml:mi>i</mml:mi><mml:mn mathvariant="normal">4</mml:mn></mml:msubsup><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo></mml:mrow><mml:mrow><mml:mo>∑</mml:mo><mml:msubsup><mml:mi>d</mml:mi><mml:mi>i</mml:mi><mml:mn mathvariant="normal">3</mml:mn></mml:msubsup><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo></mml:mrow></mml:mfrac></mml:mstyle></mml:mrow></mml:mtd></mml:mlabeledtr><mml:mlabeledtr id="App1.Ch1.S3.E19"><mml:mtd><mml:mtext>C7</mml:mtext></mml:mtd><mml:mtd><mml:mrow><mml:mstyle class="stylechange" displaystyle="true"/><mml:mi>Z</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:mo>∑</mml:mo><mml:msub><mml:mi>z</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo></mml:mrow><mml:mrow><mml:mo>∑</mml:mo><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo></mml:mrow></mml:mfrac></mml:mstyle></mml:mrow></mml:mtd></mml:mlabeledtr></mml:mtable></mml:math></disp-formula>

          where <inline-formula><mml:math id="M283" display="inline"><mml:mrow><mml:msub><mml:mi>z</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is the coordination number of a particle <inline-formula><mml:math id="M284" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula> and describes the number of contacts a given particle is involved in. The averaged particle density <inline-formula><mml:math id="M285" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="italic">ρ</mml:mi><mml:mi mathvariant="normal">p</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> results from the ratio between the mixture density and the volume fraction (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E20"/>).

            <disp-formula id="App1.Ch1.S3.E20" content-type="numbered"><label>C8</label><mml:math id="M286" display="block"><mml:mrow><mml:msub><mml:mi mathvariant="italic">ρ</mml:mi><mml:mi mathvariant="normal">p</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:mi mathvariant="italic">ρ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow><mml:mrow><mml:mi mathvariant="italic">ϕ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mfrac></mml:mstyle></mml:mrow></mml:math></disp-formula></p>
      <p id="d2e6769">The gradient of the velocity <inline-formula><mml:math id="M287" display="inline"><mml:mrow><mml:mi mathvariant="normal">∇</mml:mi><mml:mi mathvariant="bold-italic">V</mml:mi></mml:mrow></mml:math></inline-formula> computed in Pysammos corresponds to the velocity of the granular mixture, even when partial fields are requested.</p>
      <p id="d2e6782"><inline-formula><mml:math id="M288" display="inline"><mml:mrow><mml:mi mathvariant="normal">∇</mml:mi><mml:mi mathvariant="bold-italic">V</mml:mi></mml:mrow></mml:math></inline-formula> is used to carry out a linear interpolation of the coarse-grained velocity at a grid point, <inline-formula><mml:math id="M289" display="inline"><mml:mrow><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>, to the position of a particle <inline-formula><mml:math id="M290" display="inline"><mml:mi>i</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M291" display="inline"><mml:mrow><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>, in order to obtain an accurate estimate of the local particle velocity fluctuations, <inline-formula><mml:math id="M292" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>*</mml:mo></mml:msubsup></mml:mrow></mml:math></inline-formula>  (Eq. <xref ref-type="disp-formula" rid="Ch1.E7"/>), with respect to the computed macroscopic field.

            <disp-formula id="App1.Ch1.S3.E21" content-type="numbered"><label>C9</label><mml:math id="M293" display="block"><mml:mrow><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:</mml:mo><mml:mo>=</mml:mo><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>-</mml:mo><mml:mi mathvariant="normal">∇</mml:mi><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>⋅</mml:mo><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>)</mml:mo></mml:mrow></mml:math></disp-formula>

          Note that the negative sign arises from defining the displacement vector as <inline-formula><mml:math id="M294" display="inline"><mml:mrow><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> i.e. directed from the particle position to the grid point, rather than  <inline-formula><mml:math id="M295" display="inline"><mml:mrow><mml:mo>(</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>-</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>. This convention is adopted for consistency with the preceding coarse-grained fields formulations.</p>
      <p id="d2e6977">In Pysammos we offer two different ways of computing the velocity gradient. The first uses finite difference (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E22"/>). For robustness, the components of <inline-formula><mml:math id="M296" display="inline"><mml:mrow><mml:mi mathvariant="normal">∇</mml:mi><mml:mi mathvariant="bold-italic">V</mml:mi></mml:mrow></mml:math></inline-formula> match the geometry of the grid, that is, the gradient is only computed for the planes along which grid points have been generated.</p>
      <p id="d2e6992"><disp-formula id="App1.Ch1.S3.E22" content-type="numbered"><label>C10</label><mml:math id="M297" display="block"><mml:mrow><mml:mi mathvariant="normal">∇</mml:mi><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mspace width="0.25em" linebreak="nobreak"/><mml:mo>=</mml:mo><mml:mspace width="0.25em" linebreak="nobreak"/><mml:mfenced close="]" open="["><mml:mtable class="matrix" columnalign="center center center" framespacing="0em"><mml:mtr><mml:mtd><mml:mfrac><mml:mrow><mml:mo>∂</mml:mo><mml:mi>u</mml:mi></mml:mrow><mml:mrow><mml:mo>∂</mml:mo><mml:mi>x</mml:mi></mml:mrow></mml:mfrac></mml:mtd><mml:mtd><mml:mstyle displaystyle="false"><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mrow><mml:mo>∂</mml:mo><mml:mi>u</mml:mi></mml:mrow><mml:mrow><mml:mo>∂</mml:mo><mml:mi>y</mml:mi></mml:mrow></mml:mfrac></mml:mstyle></mml:mstyle></mml:mtd><mml:mtd><mml:mstyle displaystyle="false"><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mrow><mml:mo>∂</mml:mo><mml:mi>u</mml:mi></mml:mrow><mml:mrow><mml:mo>∂</mml:mo><mml:mi>z</mml:mi></mml:mrow></mml:mfrac></mml:mstyle></mml:mstyle></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mstyle displaystyle="false"><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mrow><mml:mo>∂</mml:mo><mml:mi>v</mml:mi></mml:mrow><mml:mrow><mml:mo>∂</mml:mo><mml:mi>x</mml:mi></mml:mrow></mml:mfrac></mml:mstyle></mml:mstyle></mml:mtd><mml:mtd><mml:mstyle displaystyle="false"><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mrow><mml:mo>∂</mml:mo><mml:mi>v</mml:mi></mml:mrow><mml:mrow><mml:mo>∂</mml:mo><mml:mi>y</mml:mi></mml:mrow></mml:mfrac></mml:mstyle></mml:mstyle></mml:mtd><mml:mtd><mml:mstyle displaystyle="false"><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mrow><mml:mo>∂</mml:mo><mml:mi>v</mml:mi></mml:mrow><mml:mrow><mml:mo>∂</mml:mo><mml:mi>z</mml:mi></mml:mrow></mml:mfrac></mml:mstyle></mml:mstyle></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mstyle displaystyle="false"><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mrow><mml:mo>∂</mml:mo><mml:mi>w</mml:mi></mml:mrow><mml:mrow><mml:mo>∂</mml:mo><mml:mi>x</mml:mi></mml:mrow></mml:mfrac></mml:mstyle></mml:mstyle></mml:mtd><mml:mtd><mml:mstyle displaystyle="false"><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mrow><mml:mo>∂</mml:mo><mml:mi>w</mml:mi></mml:mrow><mml:mrow><mml:mo>∂</mml:mo><mml:mi>y</mml:mi></mml:mrow></mml:mfrac></mml:mstyle></mml:mstyle></mml:mtd><mml:mtd><mml:mstyle displaystyle="false"><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mrow><mml:mo>∂</mml:mo><mml:mi>w</mml:mi></mml:mrow><mml:mrow><mml:mo>∂</mml:mo><mml:mi>z</mml:mi></mml:mrow></mml:mfrac></mml:mstyle></mml:mstyle></mml:mtd></mml:mtr></mml:mtable></mml:mfenced></mml:mrow></mml:math></disp-formula>
          where <inline-formula><mml:math id="M298" display="inline"><mml:mi>u</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M299" display="inline"><mml:mi>v</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M300" display="inline"><mml:mi>w</mml:mi></mml:math></inline-formula> are components of the coarse-grained velocity of the granular mixture <inline-formula><mml:math id="M301" display="inline"><mml:mi mathvariant="bold-italic">v</mml:mi></mml:math></inline-formula> in the <inline-formula><mml:math id="M302" display="inline"><mml:mi>x</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M303" display="inline"><mml:mi>y</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M304" display="inline"><mml:mi>z</mml:mi></mml:math></inline-formula> axes, respectively, and <inline-formula><mml:math id="M305" display="inline"><mml:mrow><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>=</mml:mo><mml:mfenced close="]" open="["><mml:mtable class="matrix" columnalign="center" framespacing="0em"><mml:mtr><mml:mtd><mml:mrow><mml:mi>x</mml:mi><mml:mo>,</mml:mo><mml:mi>y</mml:mi><mml:mo>,</mml:mo><mml:mi>z</mml:mi></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:mfenced></mml:mrow></mml:math></inline-formula>.</p>
      <p id="d2e7222">The second computes a kernel-consistent gradient of <inline-formula><mml:math id="M306" display="inline"><mml:mrow><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E15"/>), that best describes the averaged particle velocities around the kernel.  The gradient is calculated as <inline-formula><mml:math id="M307" display="inline"><mml:mrow><mml:mi mathvariant="bold">G</mml:mi><mml:mo>=</mml:mo><mml:mi mathvariant="normal">∇</mml:mi><mml:mi mathvariant="bold-italic">V</mml:mi></mml:mrow></mml:math></inline-formula> by minimising the weighted square error, <inline-formula><mml:math id="M308" display="inline"><mml:mrow><mml:mi mathvariant="italic">ε</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold">G</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E23"/>) according to least-squares linear fit, where <inline-formula><mml:math id="M309" display="inline"><mml:mrow><mml:mi mathvariant="normal">Ψ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> is written as <inline-formula><mml:math id="M310" display="inline"><mml:mi mathvariant="normal">Ψ</mml:mi></mml:math></inline-formula> for simplicity.

            <disp-formula id="App1.Ch1.S3.E23" content-type="numbered"><label>C11</label><mml:math id="M311" display="block"><mml:mrow><mml:mi mathvariant="italic">ε</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold">G</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:munder><mml:mo movablelimits="false">∑</mml:mo><mml:mi>i</mml:mi></mml:munder><mml:mi mathvariant="normal">Ψ</mml:mi><mml:msub><mml:mi>m</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>|</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">v</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>-</mml:mo><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>+</mml:mo><mml:mi mathvariant="bold">G</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:msub><mml:mo>)</mml:mo><mml:mi>i</mml:mi></mml:msub><mml:mo>⋅</mml:mo><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>)</mml:mo><mml:msup><mml:mo>|</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:msup></mml:mrow></mml:math></disp-formula>

          Solving the minimisation we obtain that <inline-formula><mml:math id="M312" display="inline"><mml:mrow><mml:mi mathvariant="bold">G</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> is given by Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S3.E24"/>).

            <disp-formula id="App1.Ch1.S3.E24" content-type="numbered"><label>C12</label><mml:math id="M313" display="block"><mml:mtable class="split" rowspacing="0.2ex" displaystyle="true" columnalign="right left"><mml:mtr><mml:mtd><mml:mrow><mml:mi mathvariant="bold">G</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mo>=</mml:mo><mml:msup><mml:mfenced open="(" close=")"><mml:mrow><mml:munder><mml:mo movablelimits="false">∑</mml:mo><mml:mi>i</mml:mi></mml:munder><mml:mi mathvariant="normal">Ψ</mml:mi><mml:msub><mml:mi>m</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>)</mml:mo><mml:mo>⊗</mml:mo><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>)</mml:mo></mml:mrow></mml:mfenced><mml:mrow><mml:mo>-</mml:mo><mml:mn mathvariant="normal">1</mml:mn></mml:mrow></mml:msup></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd/><mml:mtd><mml:mrow><mml:mfenced close=")" open="("><mml:mrow><mml:munder><mml:mo movablelimits="false">∑</mml:mo><mml:mi>i</mml:mi></mml:munder><mml:mi mathvariant="normal">Ψ</mml:mi><mml:msub><mml:mi>m</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">v</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>-</mml:mo><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo><mml:mo>⊗</mml:mo><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>-</mml:mo><mml:msub><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>)</mml:mo></mml:mrow></mml:mfenced></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:math></disp-formula></p>
      <p id="d2e7542">Granular temperature, <inline-formula><mml:math id="M314" display="inline"><mml:mi>T</mml:mi></mml:math></inline-formula>, measures the level of fluctuation of particle velocity about the macroscopic velocity of the granular mixture <xref ref-type="bibr" rid="bib1.bibx32" id="paren.132"/>. It is calculated as a spatial average of the squared velocity fluctuations; squaring is necessary because, by definition, the average of the (non-squared) fluctuation velocity is zero, so squaring avoids cancellation between fluctuations of equal magnitude but opposite sign,

            <disp-formula id="App1.Ch1.S3.E25" content-type="numbered"><label>C13</label><mml:math id="M315" display="block"><mml:mrow><mml:mi>T</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mn mathvariant="normal">1</mml:mn><mml:mrow><mml:mi>D</mml:mi><mml:mi mathvariant="italic">ρ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mfrac></mml:mstyle><mml:mtext>tr</mml:mtext><mml:mo>(</mml:mo><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mrow><mml:mi>k</mml:mi><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mo>′</mml:mo></mml:mrow></mml:msup><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mo>,</mml:mo></mml:mrow></mml:math></disp-formula>

          where <inline-formula><mml:math id="M316" display="inline"><mml:mi>D</mml:mi></mml:math></inline-formula> is the number of spatial dimensions considered. Note that the scale-independent term of the kinetic tensor must be used (<inline-formula><mml:math id="M317" display="inline"><mml:mrow><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mrow><mml:mi>k</mml:mi><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mo>′</mml:mo></mml:mrow></mml:msup></mml:mrow></mml:math></inline-formula>), as <inline-formula><mml:math id="M318" display="inline"><mml:mi>T</mml:mi></mml:math></inline-formula> focuses on the local velocity fluctuations, <inline-formula><mml:math id="M319" display="inline"><mml:mrow><mml:msubsup><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mi>i</mml:mi><mml:mo>*</mml:mo></mml:msubsup></mml:mrow></mml:math></inline-formula> (Eqs. <xref ref-type="disp-formula" rid="Ch1.E6"/> and <xref ref-type="disp-formula" rid="Ch1.E7"/>).  It is important to note that in regions with no particle influence (i.e., <inline-formula><mml:math id="M320" display="inline"><mml:mrow><mml:mi mathvariant="italic">ρ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0</mml:mn></mml:mrow></mml:math></inline-formula>), <inline-formula><mml:math id="M321" display="inline"><mml:mi>T</mml:mi></mml:math></inline-formula> is set to zero, to avoid the undefined division of 0 by 0, and subsequent NaN propagation. Although a NaN would be more mathematically accurate, we have opted for this common numerical-safety practice.</p>
      <p id="d2e7699">Pysammos also offers the computation of granular temperature following two different averaging methods by slices, and are exported separately by request, given their different structure <xref ref-type="bibr" rid="bib1.bibx62 bib1.bibx89" id="paren.133"/>. The source code for these alternative methods can be found in the sub-package <monospace>macroscopic_fields.sliced</monospace>.</p>
      <p id="d2e7708"><inline-formula><mml:math id="M322" display="inline"><mml:mrow><mml:mi mathvariant="normal">∇</mml:mi><mml:mi mathvariant="bold-italic">V</mml:mi></mml:mrow></mml:math></inline-formula> is also used to evaluate the shear rate tensor <inline-formula><mml:math id="M323" display="inline"><mml:mi mathvariant="bold">Γ</mml:mi></mml:math></inline-formula>, which describes the deformation of a granular mixture due to velocity gradients (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E26"/>).

            <disp-formula id="App1.Ch1.S3.E26" content-type="numbered"><label>C14</label><mml:math id="M324" display="block"><mml:mrow><mml:mi mathvariant="bold">Γ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mn mathvariant="normal">1</mml:mn><mml:mn mathvariant="normal">2</mml:mn></mml:mfrac></mml:mstyle><mml:mo>(</mml:mo><mml:mi mathvariant="normal">∇</mml:mi><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>+</mml:mo><mml:mi mathvariant="normal">∇</mml:mi><mml:mi mathvariant="bold-italic">V</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:msup><mml:mo>)</mml:mo><mml:mi>T</mml:mi></mml:msup><mml:mo>)</mml:mo></mml:mrow></mml:math></disp-formula>

          Deviatoric stress provides information about the anisotropic stresses (i.e., not hydrostatic) due to stress loading. We obtain any stress deviator, <inline-formula><mml:math id="M325" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold">Π</mml:mi><mml:mi mathvariant="normal">D</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>, as shown in Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S3.E27"/>).

            <disp-formula id="App1.Ch1.S3.E27" content-type="numbered"><label>C15</label><mml:math id="M326" display="block"><mml:mrow><mml:msub><mml:mi mathvariant="bold">Π</mml:mi><mml:mi mathvariant="normal">D</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:=</mml:mo><mml:mi mathvariant="bold">Π</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>-</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mn mathvariant="normal">1</mml:mn><mml:mi>D</mml:mi></mml:mfrac></mml:mstyle><mml:mtext>tr</mml:mtext><mml:mo>(</mml:mo><mml:mi mathvariant="bold">Π</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo><mml:mi mathvariant="bold">I</mml:mi></mml:mrow></mml:math></disp-formula>

          where <inline-formula><mml:math id="M327" display="inline"><mml:mi mathvariant="bold">Π</mml:mi></mml:math></inline-formula> is any tensor and <inline-formula><mml:math id="M328" display="inline"><mml:mi mathvariant="bold">I</mml:mi></mml:math></inline-formula> is the identity matrix. The magnitude of any of the computed tensors (e.g., <inline-formula><mml:math id="M329" display="inline"><mml:mrow><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>c</mml:mi></mml:msup></mml:mrow></mml:math></inline-formula>, <inline-formula><mml:math id="M330" display="inline"><mml:mrow><mml:msup><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mi>k</mml:mi></mml:msup></mml:mrow></mml:math></inline-formula>, <inline-formula><mml:math id="M331" display="inline"><mml:mi mathvariant="bold-italic">σ</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M332" display="inline"><mml:mi mathvariant="bold">Γ</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M333" display="inline"><mml:mrow><mml:msub><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mtext>D</mml:mtext></mml:msub></mml:mrow></mml:math></inline-formula>) is obtained by calculating the second invariant of the tensor, <inline-formula><mml:math id="M334" display="inline"><mml:mrow><mml:msub><mml:mi>J</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msub></mml:mrow></mml:math></inline-formula>, shown in Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S3.E28"/>).

            <disp-formula id="App1.Ch1.S3.E28" content-type="numbered"><label>C16</label><mml:math id="M335" display="block"><mml:mrow><mml:msub><mml:mi>J</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msub><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:=</mml:mo><mml:mi mathvariant="italic">α</mml:mi><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mtext>tr</mml:mtext><mml:mspace linebreak="nobreak" width="-0.125em"/><mml:mfenced close=")" open="("><mml:mrow><mml:msup><mml:mi mathvariant="bold">Π</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msup><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mfenced><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mo>,</mml:mo><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mtext>where</mml:mtext><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mi mathvariant="italic">α</mml:mi><mml:mo>=</mml:mo><mml:mfenced open="{" close=""><mml:mtable class="cases" rowspacing="5.690551pt" columnspacing="1em" columnalign="left left" framespacing="0em"><mml:mtr><mml:mtd><mml:mrow><mml:mstyle displaystyle="false"><mml:mstyle displaystyle="false"><mml:mfrac style="text"><mml:mn mathvariant="normal">1</mml:mn><mml:mn mathvariant="normal">2</mml:mn></mml:mfrac></mml:mstyle></mml:mstyle><mml:mo>,</mml:mo></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mtext>if </mml:mtext><mml:mi mathvariant="bold">Π</mml:mi><mml:mo>≠</mml:mo><mml:mi mathvariant="bold">Γ</mml:mi></mml:mrow></mml:mtd></mml:mtr><mml:mtr><mml:mtd><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:mo>,</mml:mo></mml:mrow></mml:mtd><mml:mtd><mml:mrow><mml:mtext>if </mml:mtext><mml:mi mathvariant="bold">Π</mml:mi><mml:mo>=</mml:mo><mml:mi mathvariant="bold">Γ</mml:mi></mml:mrow></mml:mtd></mml:mtr></mml:mtable></mml:mfenced></mml:mrow></mml:math></disp-formula>

          The second invariant of <inline-formula><mml:math id="M336" display="inline"><mml:mi mathvariant="bold">Γ</mml:mi></mml:math></inline-formula>  is related to the effective shear rate <inline-formula><mml:math id="M337" display="inline"><mml:mrow><mml:msub><mml:mover accent="true"><mml:mi mathvariant="italic">γ</mml:mi><mml:mo mathvariant="normal">˙</mml:mo></mml:mover><mml:mtext>eff</mml:mtext></mml:msub><mml:mo>=</mml:mo><mml:msqrt><mml:mrow><mml:mn mathvariant="normal">2</mml:mn><mml:msub><mml:mi>J</mml:mi><mml:mn mathvariant="normal">2</mml:mn></mml:msub></mml:mrow></mml:msqrt></mml:mrow></mml:math></inline-formula>, hence <inline-formula><mml:math id="M338" display="inline"><mml:mrow><mml:mi mathvariant="italic">α</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">2</mml:mn></mml:mrow></mml:math></inline-formula> when <inline-formula><mml:math id="M339" display="inline"><mml:mrow><mml:mi mathvariant="bold">Π</mml:mi><mml:mo>=</mml:mo><mml:mi mathvariant="bold">Γ</mml:mi></mml:mrow></mml:math></inline-formula>.  Pressure, <inline-formula><mml:math id="M340" display="inline"><mml:mi>p</mml:mi></mml:math></inline-formula>, corresponds to the hydrostatic components of <inline-formula><mml:math id="M341" display="inline"><mml:mi mathvariant="bold-italic">σ</mml:mi></mml:math></inline-formula> (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E29"/>).

            <disp-formula id="App1.Ch1.S3.E29" content-type="numbered"><label>C17</label><mml:math id="M342" display="block"><mml:mrow><mml:mi>p</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mn mathvariant="normal">1</mml:mn><mml:mi>D</mml:mi></mml:mfrac></mml:mstyle><mml:mtext>tr</mml:mtext><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>)</mml:mo></mml:mrow></mml:math></disp-formula>

          The coefficient of friction <inline-formula><mml:math id="M343" display="inline"><mml:mi mathvariant="italic">μ</mml:mi></mml:math></inline-formula> is also provided as shown in Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S3.E30"/>).

            <disp-formula id="App1.Ch1.S3.E30" content-type="numbered"><label>C18</label><mml:math id="M344" display="block"><mml:mrow><mml:mi mathvariant="italic">μ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:mo>|</mml:mo><mml:mi mathvariant="bold-italic">σ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>|</mml:mo></mml:mrow><mml:mrow><mml:mi>p</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:mfrac></mml:mstyle></mml:mrow></mml:math></disp-formula>

          A widely accepted rheological model for dense granular flows is the so-called <inline-formula><mml:math id="M345" display="inline"><mml:mrow><mml:mi mathvariant="italic">μ</mml:mi><mml:mo>(</mml:mo><mml:mi>I</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>-rheology. It is a phenomenological model that applies to homogeneously sheared flows in the dense, quasi-static, and inertial flow regimes. The <inline-formula><mml:math id="M346" display="inline"><mml:mrow><mml:mi mathvariant="italic">μ</mml:mi><mml:mo>(</mml:mo><mml:mi>I</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>-rheology presents a one-to-one relation between the friction coefficient (i.e. the shear-to-normal stress ratio, <inline-formula><mml:math id="M347" display="inline"><mml:mi mathvariant="italic">μ</mml:mi></mml:math></inline-formula>) and the inertial number, <inline-formula><mml:math id="M348" display="inline"><mml:mi>I</mml:mi></mml:math></inline-formula>  (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S3.E31"/>).

            <disp-formula id="App1.Ch1.S3.E31" content-type="numbered"><label>C19</label><mml:math id="M349" display="block"><mml:mrow><mml:mi>I</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>:=</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:mo>|</mml:mo><mml:mi mathvariant="bold">Γ</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>|</mml:mo><mml:mover accent="true"><mml:mi>d</mml:mi><mml:mo mathvariant="normal">¯</mml:mo></mml:mover></mml:mrow><mml:msqrt><mml:mrow><mml:mi>p</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo><mml:mo>/</mml:mo><mml:msub><mml:mi mathvariant="italic">ρ</mml:mi><mml:mi mathvariant="normal">p</mml:mi></mml:msub><mml:mo>(</mml:mo><mml:mi mathvariant="bold-italic">r</mml:mi><mml:mo>,</mml:mo><mml:mi>t</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:msqrt></mml:mfrac></mml:mstyle><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mo>,</mml:mo></mml:mrow></mml:math></disp-formula>

          where <inline-formula><mml:math id="M350" display="inline"><mml:mover accent="true"><mml:mi>d</mml:mi><mml:mo mathvariant="normal">¯</mml:mo></mml:mover></mml:math></inline-formula> is the representative particle size (Sect. <xref ref-type="sec" rid="Ch1.S3.SS4"/>). The inertial number is a measure of the dynamic state of a granular medium. It is also understood as the ratio of (1) the microscopic timescale (or scale of rearrangement), representing the time a particle takes to fall into a slit of a given diameter under a given pressure; and (2) the macroscopic time scale, linked to the average deformation  <xref ref-type="bibr" rid="bib1.bibx28" id="paren.134"/>.</p>
      <p id="d2e8373">Some of the implementations above are returned alongside possible variations. For instance, pressure is returned in 1D, 2D, and 3D. The stress tensors are provided in 2D and 3D, with their respective second invariants and deviatoric tensors. Granular temperature is also returned in 1D and 3D. The coefficient of friction is calculated with the deviatoric stress, and in 1D, 2D and 3D. The inertial number is also computed with the deviatoric shear stress , with different components of pressure, and different measures of characteristic grain size.</p>
</sec>
</app>

<app id="App1.Ch1.S4">
  <label>Appendix D</label><title>Data mapping structures</title>
      <p id="d2e8385">This appendix outlines the data structures and mapping strategies used to link different data representations within the code.</p>
<sec id="App1.Ch1.S4.SS1">
  <label>D1</label><title>Mapping particles</title>
      <p id="d2e8395">The function <monospace>data_handle.contacts.particle_mapper.map_contact_data()</monospace> maps the contact data (particle interaction pairs and force) to the particle data (position and diameter), so that the branch vectors of particle interactions can be calculated. On the one hand, the particle data consists of the following arrays: particle ID, and particle diameter, mass, velocity and position. On the other hand, contact data consists of the following arrays: particle ID of the particles upon which the contact force is exerted (particles <inline-formula><mml:math id="M351" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula>), the force acting on particles <inline-formula><mml:math id="M352" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula>, and particle ID of the particles in contact with particles <inline-formula><mml:math id="M353" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula> (particles <inline-formula><mml:math id="M354" display="inline"><mml:mi>B</mml:mi></mml:math></inline-formula>).  The arrays containing the contact data are concatenated such that both perspectives of the interaction are accounted for in a single array (i.e.,  <inline-formula><mml:math id="M355" display="inline"><mml:mrow><mml:msub><mml:mi>A</mml:mi><mml:mi mathvariant="normal">con</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mo mathvariant="italic">{</mml:mo><mml:mi mathvariant="normal">particles</mml:mi><mml:mspace linebreak="nobreak" width="0.25em"/><mml:mi>A</mml:mi><mml:mo>,</mml:mo><mml:mspace linebreak="nobreak" width="0.25em"/><mml:mi mathvariant="normal">particles</mml:mi><mml:mi>B</mml:mi><mml:mo mathvariant="italic">}</mml:mo></mml:mrow></mml:math></inline-formula> and <inline-formula><mml:math id="M356" display="inline"><mml:mrow><mml:msub><mml:mi>B</mml:mi><mml:mi mathvariant="normal">con</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mo mathvariant="italic">{</mml:mo></mml:mrow></mml:math></inline-formula>particles <inline-formula><mml:math id="M357" display="inline"><mml:mi>B</mml:mi></mml:math></inline-formula>, particles <inline-formula><mml:math id="M358" display="inline"><mml:mrow><mml:mi>A</mml:mi><mml:mo mathvariant="italic">}</mml:mo></mml:mrow></mml:math></inline-formula>). That way, Eq. (<xref ref-type="disp-formula" rid="Ch1.E5"/>) can be applied directly to contact data (Fig. <xref ref-type="fig" rid="FD1"/>b).  Hence, the contact-to-particle data mapping involves the association of each element of <inline-formula><mml:math id="M359" display="inline"><mml:mrow><mml:msub><mml:mi>A</mml:mi><mml:mi mathvariant="normal">con</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> (and <inline-formula><mml:math id="M360" display="inline"><mml:mrow><mml:msub><mml:mi>B</mml:mi><mml:mi mathvariant="normal">con</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>) with the corresponding element in particle ID array of the particle data (grey array in Fig. <xref ref-type="fig" rid="FD1"/>a).</p>

      <fig id="FD1"><label>Figure D1</label><caption><p id="d2e8524">Conceptual diagram illustrating the relationship between the particle data (blue arrays) and contact data (yellow arrays) through the index mapping (grey) array.  The grey array maps the indices of the contact data to the particle data, which is sorted by particle ID. The contact data has previously been arranged such that both sides of the interaction are taken into account in a single array, i.e., the effect on particle <inline-formula><mml:math id="M361" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula>, and on particle <inline-formula><mml:math id="M362" display="inline"><mml:mi>B</mml:mi></mml:math></inline-formula> <bold>(b)</bold>. </p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f18.png"/>

        </fig>

</sec>
<sec id="App1.Ch1.S4.SS2">
  <label>D2</label><title>Correcting for periodic boundaries</title>
      <p id="d2e8558">The module <monospace>data_handle.contacts.complete.branch_vectors</monospace> provides functions to calculate the branch vectors from contact points to particle centres (<monospace>from_contacts</monospace>) or from particle diameters to particle centres (<monospace>from_diameters</monospace>), in case the contact point is not provided.  Both functions handle periodic boundary corrections along each axis using the Minimum Image Convention (MIC), by which displacements are calculated to the nearest periodic equivalent as shown in Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S4.E32"/>) <xref ref-type="bibr" rid="bib1.bibx33" id="paren.135"/>.

            <disp-formula id="App1.Ch1.S4.E32" content-type="numbered"><label>D1</label><mml:math id="M363" display="block"><mml:mrow><mml:mi mathvariant="normal">Δ</mml:mi><mml:msubsup><mml:mi>r</mml:mi><mml:mi>i</mml:mi><mml:mi mathvariant="normal">c</mml:mi></mml:msubsup><mml:mo>=</mml:mo><mml:mo>(</mml:mo><mml:msubsup><mml:mi>r</mml:mi><mml:mi>i</mml:mi><mml:mi>A</mml:mi></mml:msubsup><mml:mo>-</mml:mo><mml:msubsup><mml:mi>r</mml:mi><mml:mi>i</mml:mi><mml:mi>B</mml:mi></mml:msubsup><mml:mo>)</mml:mo><mml:mo>-</mml:mo><mml:msub><mml:mi>L</mml:mi><mml:mi>i</mml:mi></mml:msub><mml:mo>⌊</mml:mo><mml:mstyle displaystyle="true"><mml:mfrac style="display"><mml:mrow><mml:msubsup><mml:mi>r</mml:mi><mml:mi>i</mml:mi><mml:mi>A</mml:mi></mml:msubsup><mml:mo>-</mml:mo><mml:msubsup><mml:mi>r</mml:mi><mml:mi>i</mml:mi><mml:mi>B</mml:mi></mml:msubsup></mml:mrow><mml:mrow><mml:msub><mml:mi>L</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:mfrac></mml:mstyle><mml:mo>⌉</mml:mo><mml:mo>,</mml:mo><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mi>i</mml:mi><mml:mo>∈</mml:mo><mml:mo mathvariant="italic">{</mml:mo><mml:mi>x</mml:mi><mml:mo>,</mml:mo><mml:mi>y</mml:mi><mml:mo>,</mml:mo><mml:mi>z</mml:mi><mml:mo mathvariant="italic">}</mml:mo><mml:mo>,</mml:mo></mml:mrow></mml:math></disp-formula>

          where <inline-formula><mml:math id="M364" display="inline"><mml:mrow><mml:mi mathvariant="normal">Δ</mml:mi><mml:msubsup><mml:mi>r</mml:mi><mml:mi>i</mml:mi><mml:mi mathvariant="normal">c</mml:mi></mml:msubsup></mml:mrow></mml:math></inline-formula> is the corrected displacement between particles <inline-formula><mml:math id="M365" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M366" display="inline"><mml:mi>B</mml:mi></mml:math></inline-formula> in a given dimension, <inline-formula><mml:math id="M367" display="inline"><mml:mrow><mml:msubsup><mml:mi>r</mml:mi><mml:mi>i</mml:mi><mml:mi>A</mml:mi></mml:msubsup><mml:mo>-</mml:mo><mml:msubsup><mml:mi>r</mml:mi><mml:mi>i</mml:mi><mml:mi>B</mml:mi></mml:msubsup></mml:mrow></mml:math></inline-formula> is the uncorrected displacement between the two particles in a given dimension and <inline-formula><mml:math id="M368" display="inline"><mml:mrow><mml:msub><mml:mi>L</mml:mi><mml:mi>i</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>  is the length of the box in a given dimension. The application of the MIC to a two-dimensional scenario is illustrated in Fig. <xref ref-type="fig" rid="FD2"/>.</p>

      <fig id="FD2" specific-use="star"><label>Figure D2</label><caption><p id="d2e8753">Two-dimensional illustration of the application of the Minimum Image Convention (MIC) for particle pairs located well within the model domain <bold>(a)</bold> and interacting across periodic boundaries <bold>(b)</bold>. In case <bold>(b)</bold>, displacement vectors are computed using the nearest periodic image, following Eq. (<xref ref-type="disp-formula" rid="App1.Ch1.S4.E32"/>). All particles have identical radius (<inline-formula><mml:math id="M369" display="inline"><mml:mrow><mml:mi>R</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">0.5</mml:mn></mml:mrow></mml:math></inline-formula>). The contact point, <inline-formula><mml:math id="M370" display="inline"><mml:mrow><mml:msub><mml:mi>r</mml:mi><mml:mi mathvariant="normal">C</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula>, is defined on particle <inline-formula><mml:math id="M371" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula> (purple) and is depicted with a black point. The branch vector from the contact point to the centre of particle <inline-formula><mml:math id="M372" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M373" display="inline"><mml:mrow><mml:msub><mml:mi>r</mml:mi><mml:mrow><mml:mi mathvariant="normal">C</mml:mi><mml:mi>A</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula>, is shown by the black arrow, while the vector from the centre of particle <inline-formula><mml:math id="M374" display="inline"><mml:mi>B</mml:mi></mml:math></inline-formula> (red) to the centre of particle <inline-formula><mml:math id="M375" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula>, <inline-formula><mml:math id="M376" display="inline"><mml:mrow><mml:msub><mml:mi>r</mml:mi><mml:mrow><mml:mi>B</mml:mi><mml:mi>A</mml:mi></mml:mrow></mml:msub></mml:mrow></mml:math></inline-formula>, is indicated by the blue arrow. The boundaries of the model domain are delineated by the black box.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f19.png"/>

        </fig>

</sec>
<sec id="App1.Ch1.S4.SS3">
  <label>D3</label><title>Deletion of duplicates</title>
      <p id="d2e8862">The module <monospace>data_handle.contacts.quality_check.duplicates</monospace> provides the tools to check for duplicate particle contacts in the contact data files, and delete them if present. Duplicate particle contacts often correspond to ghost particles near CPU region bounds used in parallel DEM computations. Ghost particles may be written by several CPUs, generating duplicate contacts in the output files. If this artefact is not addressed, the CG measures that rely on contact forces or branch vectors could be somewhat skewed.</p>
      <p id="d2e8870">In the function <monospace>data_handle.contacts.quality_check.duplicates.get_unique_pairs()</monospace> we sort the array of particles <inline-formula><mml:math id="M377" display="inline"><mml:mi>A</mml:mi></mml:math></inline-formula> and particles <inline-formula><mml:math id="M378" display="inline"><mml:mi>B</mml:mi></mml:math></inline-formula> involved in contact, ensuring that <inline-formula><mml:math id="M379" display="inline"><mml:mrow><mml:mo>(</mml:mo><mml:mi>A</mml:mi><mml:mo>,</mml:mo><mml:mi>B</mml:mi><mml:mo>)</mml:mo><mml:mo>=</mml:mo><mml:mo>(</mml:mo><mml:mi>B</mml:mi><mml:mo>,</mml:mo><mml:mi>A</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula> (Eq. <xref ref-type="disp-formula" rid="App1.Ch1.S4.E33"/>), and record the indices of the unique pairs. Any non-unique pairs are deleted with the function <monospace>data_handle.contacts.quality_check.duplicates.delete()</monospace>.

            <disp-formula id="App1.Ch1.S4.E33" content-type="numbered"><label>D2</label><mml:math id="M380" display="block"><mml:mrow><mml:msub><mml:mi>p</mml:mi><mml:mi>k</mml:mi></mml:msub><mml:mo>=</mml:mo><mml:mfenced close=")" open="("><mml:mrow><mml:mtext>min</mml:mtext><mml:mo>(</mml:mo><mml:msub><mml:mi>a</mml:mi><mml:mi>k</mml:mi></mml:msub><mml:mo>,</mml:mo><mml:msub><mml:mi>b</mml:mi><mml:mi>k</mml:mi></mml:msub><mml:mo>)</mml:mo><mml:mo>,</mml:mo><mml:mtext>max</mml:mtext><mml:mo>(</mml:mo><mml:msub><mml:mi>a</mml:mi><mml:mi>k</mml:mi></mml:msub><mml:mo>,</mml:mo><mml:msub><mml:mi>b</mml:mi><mml:mi>k</mml:mi></mml:msub><mml:mo>)</mml:mo></mml:mrow></mml:mfenced><mml:mo>,</mml:mo><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mspace width="0.125em" linebreak="nobreak"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mspace linebreak="nobreak" width="0.125em"/><mml:mi>k</mml:mi><mml:mo>=</mml:mo><mml:mn mathvariant="normal">1</mml:mn><mml:mo>,</mml:mo><mml:mi mathvariant="normal">…</mml:mi><mml:mo>,</mml:mo><mml:mi>N</mml:mi><mml:mo>,</mml:mo></mml:mrow></mml:math></disp-formula>

          where <inline-formula><mml:math id="M381" display="inline"><mml:mrow><mml:msub><mml:mi>p</mml:mi><mml:mi>k</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> is the <inline-formula><mml:math id="M382" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>th particle pair, <inline-formula><mml:math id="M383" display="inline"><mml:mrow><mml:msub><mml:mi>a</mml:mi><mml:mi>k</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> and <inline-formula><mml:math id="M384" display="inline"><mml:mrow><mml:msub><mml:mi>b</mml:mi><mml:mi>k</mml:mi></mml:msub></mml:mrow></mml:math></inline-formula> are the IDs of the particles involved in the <inline-formula><mml:math id="M385" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>th contact, and <inline-formula><mml:math id="M386" display="inline"><mml:mi>N</mml:mi></mml:math></inline-formula> is the total number of recorded particle pairs.</p>
</sec>
<sec id="App1.Ch1.S4.SS4">
  <label>D4</label><title>Particle-node association</title>
      <p id="d2e9075">The particle-node association data are exported by the <inline-formula><mml:math id="M387" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-<inline-formula><mml:math id="M388" display="inline"><mml:mi>d</mml:mi></mml:math></inline-formula> tree algorithm as two arrays (Appendix <xref ref-type="sec" rid="App1.Ch1.S2.SS2"/>). The first array contains the indices of particle data arrays (Fig. <xref ref-type="fig" rid="FD3"/>a, e.g., position), for each particle at each grid point in sequential order (Fig. <xref ref-type="fig" rid="FD3"/>b). The second array contains the offsets into the first array, providing the starting index of the particles associated with a given grid point (Fig. <xref ref-type="fig" rid="FD3"/>c). Note that this relation is correct given that the particle data arrays are sorted by particle ID just after being read.</p>

      <fig id="FD3"><label>Figure D3</label><caption><p id="d2e9103">Schematic representation of the relation between the particle properties arrays <bold>(a)</bold> and the arrays exported by the function neighbour_search.grid_particle_search.particle_node_match: the particle indices array <bold>(b)</bold>,  containing the indices of particle properties arrays in sequential order for each particle at each grid point; and the start indices array <bold>(c)</bold>, providing the starting index of the particles associated with a given grid point. This relation is correct given that the arrays containing particle properties are sorted by particle ID.</p></caption>
          <graphic xlink:href="https://gmd.copernicus.org/articles/19/9519/2026/gmd-19-9519-2026-f20.png"/>

        </fig>

      <p id="d2e9121">Empty grid points (i.e., those with no particles within the cut-off radius) are handled by appearing as zero-length slices in the second array, thus ensuring both efficiency and robustness. This structure is employed because it only uses arrays. The use of lists of arrays with variable lengths is avoided, as it is more computationally costly to check the type and size of each element of the list.</p>
</sec>
</app>

<app id="App1.Ch1.S5">
  <label>Appendix E</label><title>Optimisation strategies</title>
      <p id="d2e9133">This appendix outlines the structural design choices in Pysammos. The computational cost of the code is dominated by data handling rather than individual numerical operations. The scalability of the execution gives rise to bottlenecks that limit the efficiency by memory bandwidth rather than raw CPU performance. Code performance was enhanced by tackling bottlenecks identified in the resource usage analysis, employing algorithmic optimisation or the Numba Python compiler. Each bottleneck was addressed with a unique strategy that suited that particular operation, specified below: <list list-type="order"><list-item>
      <p id="d2e9138"><italic>Reading and writing data</italic>. Large portions of memory are required to load and write single data files meaning that it is an operation that should be done in succession. This was accommodated by an architecture that loops over time steps and optimises the operations within each time step.</p></list-item><list-item>
      <p id="d2e9144"><italic>Particle to grid point association</italic>. There are many ways to perform proximity searches with ranging scalability complexity. We applied the <inline-formula><mml:math id="M389" display="inline"><mml:mi>k</mml:mi></mml:math></inline-formula>-<inline-formula><mml:math id="M390" display="inline"><mml:mi>d</mml:mi></mml:math></inline-formula> tree algorithm <xref ref-type="bibr" rid="bib1.bibx72" id="paren.136"/>, a space partitioning proximity search with runtime <inline-formula><mml:math id="M391" display="inline"><mml:mrow><mml:mi>O</mml:mi><mml:mo>(</mml:mo><mml:mi>log⁡</mml:mi><mml:mi>N</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>, as opposed to the linear search with complexity <inline-formula><mml:math id="M392" display="inline"><mml:mrow><mml:mi>O</mml:mi><mml:mo>(</mml:mo><mml:mi mathvariant="normal">d</mml:mi><mml:mi>N</mml:mi><mml:mo>)</mml:mo></mml:mrow></mml:math></inline-formula>, where <inline-formula><mml:math id="M393" display="inline"><mml:mi>d</mml:mi></mml:math></inline-formula> and <inline-formula><mml:math id="M394" display="inline"><mml:mi>N</mml:mi></mml:math></inline-formula> are the dimensionality and number of elements of the system (Appendix <xref ref-type="sec" rid="App1.Ch1.S2.SS2"/>).</p></list-item><list-item>
      <p id="d2e9216"><italic>Particle to grid point weighting</italic>. The re-computation of CG weighting functions, in particular the Gaussian, is increasingly inefficient as the number of particles and grid points grows. Lookup tables of precomputed weights reduce the number of times these weights are actually calculated, and thus increase the efficiency of this operation (Appendix <xref ref-type="sec" rid="App1.Ch1.S2.SS3"/>).</p></list-item><list-item>
      <p id="d2e9224"><italic>Weighted average computation at all grid points</italic>. In the presence of a large number of grid points, the runtime of this calculation grows linearly with time if done in loops or requires too much memory if approached with vectorisation. Hence, this operation could benefit from Numba acceleration and parallel computing, given that it is completely independent from one grid point to another (Appendix <xref ref-type="sec" rid="App1.Ch1.S5.SS1"/>).</p></list-item></list></p>
<sec id="App1.Ch1.S5.SS1">
  <label>E1</label><title>Numba compilation</title>
      <p id="d2e9238">Numba is an open-source just-in-time (JIT) compiler for Python <xref ref-type="bibr" rid="bib1.bibx48" id="paren.137"/>. It translates functions marked with the JIT decorator into (faster) machine code, using Low Level Virtual Machine (LLVM), and caches it until execution. Once Numba has identified the functions to translate, it determines the data types of the function arguments prior to runtime to avoid overhead, as is the case of Python's dynamic typing approach. Numba supports NumPy library objects and operations, making it an invaluable tool for scientific computing and data analysis.</p>
      <p id="d2e9244">Numba also offers the possibility to compute loops in parallel. This option allows CPU multi-threading, where each thread executes a chunk of the loop independently and combines the results at the end. Numba may additionally vectorise inner loops within a parallelised task using single instruction multiple data (SIMD) operations. The parallelisation option offered by Numba requires the user to ensure the robustness of the parallelised loop, that is, there are no cross-iteration dependencies.</p>
      <p id="d2e9247">In Pysammos, the capabilities of Numba that reduce Python-level overhead were leveraged in operations that involved the totality of grid points and particles, like the calculation of continuum fields (bottleneck 4). The parallelisation option was implemented as well, however, the nature of the problem, i.e., memory-bandwidth bound, meant that computation did not overly benefit from parallelisation.</p>
</sec>
</app>
  </app-group><notes notes-type="codedataavailability"><title>Code and data availability</title>

      <p id="d2e9255">The current version of Pysammos is available from the project <uri>https://github.com/Claudia-Elijas/pysammos/</uri> (last access: 1 October 2026) under the licence GNU General Public License. The code documentation can be found at <uri>https://claudia-elijas.github.io/pysammos/</uri> (last access: 1 October 2026). The exact version of the model used to produce the results presented in this paper is archived on repository under <ext-link xlink:href="https://doi.org/10.5281/zenodo.19355667" ext-link-type="DOI">10.5281/zenodo.19355667</ext-link> <xref ref-type="bibr" rid="bib1.bibx21" id="paren.138"/>, as are the scripts to process the example simulations shown here. The data corresponding to the example simulations are archived on repository under <ext-link xlink:href="https://doi.org/10.5281/zenodo.19351802" ext-link-type="DOI">10.5281/zenodo.19351802</ext-link> <xref ref-type="bibr" rid="bib1.bibx22" id="paren.139"/>.</p>
  </notes><notes notes-type="authorcontribution"><title>Author contributions</title>

      <p id="d2e9280">CEP: conceptualisation, data curation, formal analysis, methodology, software, validation, visualisation, writing (original draft). ECPB: conceptualisation, data curation, funding acquisition, methodology, supervision, validation, visualisation, writing (review and editing). JPM: data curation, validation, writing (review and editing). PJZ: methodology, validation, writing (review and editing). MN: methodology, software, writing (review and editing).</p>
  </notes><notes notes-type="competinginterests"><title>Competing interests</title>

      <p id="d2e9286">The contact author has declared that none of the authors has any competing interests.</p>
  </notes><notes notes-type="disclaimer"><title>Disclaimer</title>

      <p id="d2e9292">Publisher's note: Copernicus Publications remains neutral with regard to jurisdictional claims made in the text, published maps, institutional affiliations, or any other geographical representation in this paper. The authors bear the ultimate responsibility for providing appropriate place names. Views expressed in the text are those of the authors and do not necessarily reflect the views of the publisher.</p>
  </notes><ack><title>Acknowledgements</title><p id="d2e9298">The authors gratefully acknowledge the UKRI ARCHER2 High Performance Computing facility for providing the computational resources required to run the showcase simulations. The authors also thank Jean F. Dietiker (National Energy Technology Laboratory), developer of MFiX-DEM, for providing valuable updates on its evolving capabilities and planned developments, which helped guide the integration of MFiX-DEM with the present work.</p></ack><notes notes-type="financialsupport"><title>Financial support</title>

      <p id="d2e9303">C.E.P. was supported by the Natural Environment Research Council (NERC) Edinburgh Earth Ecology and Environment Doctoral Training Partnership (E4DTP) (grant no. NE/S007407/1). E.C.P.B. and P.J.Z. were supported by the Leverhulme Trust (grant no. LT RPG award – RPG-2024-294). E.C.P.B. was additionally supported by the UK Research and Innovation (UKRI) with the NERC-IRF (grant no. IEC<inline-formula><mml:math id="M395" display="inline"><mml:mo>\</mml:mo></mml:math></inline-formula>NSFC<inline-formula><mml:math id="M396" display="inline"><mml:mo>\</mml:mo></mml:math></inline-formula>42381)  and The Royal Society (grant no. IECnNSFCn42381).</p>
  </notes><notes notes-type="reviewstatement"><title>Review statement</title>

      <p id="d2e9324">This paper was edited by Thomas Poulet and reviewed by Alexandre Sac-Morane and Francois Guillard.</p>
  </notes><ref-list>
    <title>References</title>

      <ref id="bib1.bibx1"><label>Alihosseini et al.(2020)Alihosseini, Sægrov, and Thamsen</label><mixed-citation>Alihosseini, M., Sægrov, S., and Thamsen, P. U.: CFD-DEM modelling of sediment transport in sewer systems under steady and unsteady flow conditions, Water Sci. Technol., 80, 2141–2147, <ext-link xlink:href="https://doi.org/10.2166/wst.2020.030" ext-link-type="DOI">10.2166/wst.2020.030</ext-link>, 2020.</mixed-citation></ref>
      <ref id="bib1.bibx2"><label>Altair Engineering, Inc.(2025)</label><mixed-citation>Altair Engineering, Inc.: Altair EDEM, Software, Siemens, <uri>https://altair.com/edem/</uri> (last access: 1 October 2026), 2025.</mixed-citation></ref>
      <ref id="bib1.bibx3"><label>Archimedes(2009)</label><mixed-citation>Archimedes: The Sand-Reckoner,  Cambridge Library Collection – Mathematics, Cambridge University Press, Cambridge,  221–232, <ext-link xlink:href="https://doi.org/10.1017/CBO9780511695124.018" ext-link-type="DOI">10.1017/CBO9780511695124.018</ext-link>, 2009.</mixed-citation></ref>
      <ref id="bib1.bibx4"><label>Artoni and Richard(2015)</label><mixed-citation>Artoni, R. and Richard, P.: Average balance equations, scale dependence, and energy cascade for granular materials, Phys. Rev. E, 91, 032202, <ext-link xlink:href="https://doi.org/10.1103/PhysRevE.91.032202" ext-link-type="DOI">10.1103/PhysRevE.91.032202</ext-link>, 2015.</mixed-citation></ref>
      <ref id="bib1.bibx5"><label>Babic(1997)</label><mixed-citation>Babic, M.: Average balance equations for granular materials, Int. J. Eng. Sci., 35, 523–548, <ext-link xlink:href="https://doi.org/10.1016/S0020-7225(96)00094-8" ext-link-type="DOI">10.1016/S0020-7225(96)00094-8</ext-link>, 1997.</mixed-citation></ref>
      <ref id="bib1.bibx6"><label>Baghban et al.(2021)Baghban, Arulrajah, Narsilio, and Horpibulsuk</label><mixed-citation>Baghban, H., Arulrajah, A., Narsilio, G. A., and Horpibulsuk, S.: DEM simulation of the thermo-geomechanical effect of recycled concrete aggregate assemblies in geothermal pavement bases, Transport. Geotech., 28, 100528, <ext-link xlink:href="https://doi.org/10.1016/j.trgeo.2021.100528" ext-link-type="DOI">10.1016/j.trgeo.2021.100528</ext-link>, 2021.</mixed-citation></ref>
      <ref id="bib1.bibx7"><label>Barker and Gray(2017)</label><mixed-citation>Barker, T. and Gray, J. M. N. T.: Partial regularisation of the incompressible <inline-formula><mml:math id="M397" display="inline"><mml:mi mathvariant="italic">μ</mml:mi></mml:math></inline-formula>(I)-rheology for granular flow, J. Fluid Mech., 828, 5–32, <ext-link xlink:href="https://doi.org/10.1017/jfm.2017.428" ext-link-type="DOI">10.1017/jfm.2017.428</ext-link>, 2017.</mixed-citation></ref>
      <ref id="bib1.bibx8"><label>Blatny et al.(2024)Blatny, Gray, and Gaume</label><mixed-citation>Blatny, L., Gray, J., and Gaume, J.: A critical state μ(I)-rheology model for cohesive granular flows, J. Fluid Mech., 997, A67, <ext-link xlink:href="https://doi.org/10.1017/jfm.2024.643" ext-link-type="DOI">10.1017/jfm.2024.643</ext-link>, 2024.</mixed-citation></ref>
      <ref id="bib1.bibx9"><label>Boyer et al.(2011)Boyer, Guazzelli, and Pouliquen</label><mixed-citation>Boyer, F. M. C., Guazzelli, E., and Pouliquen, O.: Unifying Suspension and Granular Rheology, Phys. Rev. Lett., 107, 188301, <ext-link xlink:href="https://doi.org/10.1103/PhysRevLett.107.188301" ext-link-type="DOI">10.1103/PhysRevLett.107.188301</ext-link>, 2011.</mixed-citation></ref>
      <ref id="bib1.bibx10"><label>Breard et al.(2022)Breard, Fullard, Dufek, Thomas, Wadsworth, Heap, and Lavallée</label><mixed-citation>Breard, E. C. P., Fullard, L., Dufek, J., Thomas, N., Wadsworth, F. B., Heap, M. J., and Lavallée, Y.: Investigating the rheology of fluidized and non-fluidized gas-particle beds: implications for the dynamics of geophysical flows and substrate entrainment, Granular Matter, 24, 34, <ext-link xlink:href="https://doi.org/10.1007/s10035-021-01192-5" ext-link-type="DOI">10.1007/s10035-021-01192-5</ext-link>, 2022.</mixed-citation></ref>
      <ref id="bib1.bibx11"><label>Breard et al.(2023a)Breard, Dufek, Charbonnier, Valentin, Giachetti, and Walsh</label><mixed-citation>Breard, E. C. P., Dufek, J., Charbonnier, S., Valentin, G., Giachetti, T., and Walsh, B.: The fragmentation-induced fluidisation of pyroclastic density currents, Nat. Commun., 14, 2079, <ext-link xlink:href="https://doi.org/10.1038/s41467-023-37867-1" ext-link-type="DOI">10.1038/s41467-023-37867-1</ext-link>, 2023a.</mixed-citation></ref>
      <ref id="bib1.bibx12"><label>Brockbank et al.(1997)Brockbank, Huntley, and Ball</label><mixed-citation>Brockbank, R., Huntley, J., and Ball, R.: Contact force distribution beneath a three-dimensional granular pile, J. Phys. II, 7, 1521–1532, <ext-link xlink:href="https://doi.org/10.1051/jp2:1997200" ext-link-type="DOI">10.1051/jp2:1997200</ext-link>, 1997.</mixed-citation></ref>
      <ref id="bib1.bibx13"><label>Carrara et al.(2024)Carrara, Burgisser, and Bergantz</label><mixed-citation>Carrara, A., Burgisser, A., and Bergantz, G. W.: Numerical simulations of the mingling caused by a magma intruding a resident mush, Volcanica, 7, 89–104, <ext-link xlink:href="https://doi.org/10.30909/vol.07.01.89104" ext-link-type="DOI">10.30909/vol.07.01.89104</ext-link>, 2024.</mixed-citation></ref>
      <ref id="bib1.bibx14"><label>Christoffersen et al.(1981)Christoffersen, Mehrabadi, and Nemat-Nasser</label><mixed-citation>Christoffersen, J., Mehrabadi, M. M., and Nemat-Nasser, S.: A micromechanical description of granular material behavior, J. Appl. Mech., 48, 339–344, <ext-link xlink:href="https://doi.org/10.1115/1.3157601" ext-link-type="DOI">10.1115/1.3157601</ext-link>, 1981.</mixed-citation></ref>
      <ref id="bib1.bibx15"><label>Cundall(1971)</label><mixed-citation> Cundall, P. A.: A Computer Model for Progressive Simulating Large-Scale Movements in Blocky Rock Systems, in: Proceedings of the Symposium of the International Society for Rock Mechanics, Nancy,  vol. 1,  11–18,  1971.</mixed-citation></ref>
      <ref id="bib1.bibx16"><label>Cundall and Strack(1979)</label><mixed-citation>Cundall, P. A. and Strack, O. D. L.: A discrete numerical model for granular assemblies, Géotechnique, 29, 47–65, <ext-link xlink:href="https://doi.org/10.1680/geot.1979.29.1.47" ext-link-type="DOI">10.1680/geot.1979.29.1.47</ext-link>, 1979.</mixed-citation></ref>
      <ref id="bib1.bibx17"><label>Dai et al.(2025)Dai, Gao, Niu, Zhou, Zhang, Tian, Guo, and Zhang</label><mixed-citation>Dai, S., Gao, F., Niu, G., Zhou, W., Zhang, C., Tian, Y., Guo, Y., and Zhang, J.: Dynamics of particle segregation and its impact on mechanical properties, Acta Geotech., 20, 1991–2007, <ext-link xlink:href="https://doi.org/10.1007/s11440-025-02547-5" ext-link-type="DOI">10.1007/s11440-025-02547-5</ext-link>, 2025.</mixed-citation></ref>
      <ref id="bib1.bibx18"><label>de Gennes(1999)</label><mixed-citation>de Gennes, P. G.: Granular matter: a tentative view, Rev. Mod. Phys., 71, S374–S382, <ext-link xlink:href="https://doi.org/10.1103/RevModPhys.71.S374" ext-link-type="DOI">10.1103/RevModPhys.71.S374</ext-link>, 1999.</mixed-citation></ref>
      <ref id="bib1.bibx19"><label>Dobry and Ng(1992)</label><mixed-citation>Dobry, R. and Ng, T.-T.: Discrete modelling of stress-strain behaviour of granular media at small and large strains, Eng. Comput., 9, 129–143, <ext-link xlink:href="https://doi.org/10.1108/eb023853" ext-link-type="DOI">10.1108/eb023853</ext-link>, 1992.</mixed-citation></ref>
      <ref id="bib1.bibx20"><label>Drahun and Bridgwater(1983)</label><mixed-citation>Drahun, J. A. and Bridgwater, J.: The mechanisms of free surface segregation, Powder Technol., 36, 39–53, <ext-link xlink:href="https://doi.org/10.1016/0032-5910(83)80007-2" ext-link-type="DOI">10.1016/0032-5910(83)80007-2</ext-link>, 1983.</mixed-citation></ref>
      <ref id="bib1.bibx21"><label>Elijas-Parra et al.(2026a)Elijas-Parra, Breard, Morrissey, Zrelak, and Naylor</label><mixed-citation>Elijas-Parra, C., Breard, E., Morrissey, J., Zrelak, P. J., and Naylor, M.: Claudia-Elijas/pysammos: Pysammos v1.0.0, Zenodo [code], <ext-link xlink:href="https://doi.org/10.5281/zenodo.19355667" ext-link-type="DOI">10.5281/zenodo.19355667</ext-link>, 2026a.</mixed-citation></ref>
      <ref id="bib1.bibx22"><label>Elijas-Parra et al.(2026b)Elijas-Parra, Breard, Morrissey, Zrelak, and Naylor</label><mixed-citation>Elijas-Parra, C., Breard, E., Morrissey, J., Zrelak, P. J., and Naylor, M.: Example granular material simulation data for the Pysammos Python package, Zenodo [code], <ext-link xlink:href="https://doi.org/10.5281/zenodo.19351802" ext-link-type="DOI">10.5281/zenodo.19351802</ext-link>, 2026b.</mixed-citation></ref>
      <ref id="bib1.bibx23"><label>Fateman(1989)</label><mixed-citation>Fateman, R. J.: Lookup tables, recurrences and complexity, in: Proceedings of the ACM-SIGSAM 1989 International Symposium on Symbolic and Algebraic Computation, ISSAC '89, Association for Computing Machinery, New York, NY, USA,  68–73, ISBN 0897913256, <ext-link xlink:href="https://doi.org/10.1145/74540.74549" ext-link-type="DOI">10.1145/74540.74549</ext-link>, 1989.</mixed-citation></ref>
      <ref id="bib1.bibx24"><label>Gabellini et al.(2025)Gabellini, Rossi, Cioni et al.</label><mixed-citation>Gabellini, P., Rossi, E., Cioni, R., Pistolesi, M., Baumgartner, L. P., and Bonadonna, C.: X-Ray micro-tomography unveils the internal features of volcanic ash aggregates, Commun. Earth Environ., 6, 521, <ext-link xlink:href="https://doi.org/10.1038/s43247-025-02378-y" ext-link-type="DOI">10.1038/s43247-025-02378-y</ext-link>, 2025.</mixed-citation></ref>
      <ref id="bib1.bibx25"><label>Gallier et al.(2014)Gallier, Lemaire, Peters, and Lobry</label><mixed-citation>Gallier, S., Lemaire, E., Peters, F., and Lobry, L.: Rheology of sheared suspensions of rough frictional particles, J. Fluid Mech., 757, 514–549, <ext-link xlink:href="https://doi.org/10.1017/jfm.2014.507" ext-link-type="DOI">10.1017/jfm.2014.507</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bibx26"><label>Gao et al.(2022)Gao, Yu, Portal, Dietiker, Shahnam, and Rogers</label><mixed-citation>Gao, X., Yu, J., Portal, R. J., Dietiker, J.-F., Shahnam, M., and Rogers, W. A.: Development and validation of SuperDEM for non-spherical particulate systems using a superquadric particle method, Particuology, 61, 74–90, <ext-link xlink:href="https://doi.org/10.1016/j.partic.2020.11.007" ext-link-type="DOI">10.1016/j.partic.2020.11.007</ext-link>, 2022.</mixed-citation></ref>
      <ref id="bib1.bibx27"><label>Garres-Díaz et al.(2020)Garres-Díaz, Bouchut, Fernández-Nieto, Mangeney, and Narbona-Reina</label><mixed-citation>Garres-Díaz, J., Bouchut, F., Fernández-Nieto, E., Mangeney, A., and Narbona-Reina, G.: Multilayer models for shallow two-phase debris flows with dilatancy effects, J. Comput. Phys., 419, 109699, <ext-link xlink:href="https://doi.org/10.1016/j.jcp.2020.109699" ext-link-type="DOI">10.1016/j.jcp.2020.109699</ext-link>, 2020.</mixed-citation></ref>
      <ref id="bib1.bibx28"><label>GDR MiDi(2004)</label><mixed-citation>GDR MiDi: On dense granular flows,  European Phys. J. E, 14, 341–365, <ext-link xlink:href="https://doi.org/10.1140/epje/i2003-10153-0" ext-link-type="DOI">10.1140/epje/i2003-10153-0</ext-link>, 2004.</mixed-citation></ref>
      <ref id="bib1.bibx29"><label>Giordano et al.(2008)Giordano, Russell, and Dingwell</label><mixed-citation>Giordano, D., Russell, J. K., and Dingwell, D. B.: Viscosity of magmatic liquids: A model, Earth   Planet. Sc. Lett., 271, 123–134, <ext-link xlink:href="https://doi.org/10.1016/j.epsl.2008.03.038" ext-link-type="DOI">10.1016/j.epsl.2008.03.038</ext-link>, 2008.</mixed-citation></ref>
      <ref id="bib1.bibx30"><label>Glasser and Goldhirsch(2001)</label><mixed-citation>Glasser, B. J. and Goldhirsch, I.: Scale dependence, correlations, and fluctuations of stresses in rapid granular flows, Phys. Fluid., 13, 407–420, <ext-link xlink:href="https://doi.org/10.1063/1.1338543" ext-link-type="DOI">10.1063/1.1338543</ext-link>, 2001.</mixed-citation></ref>
      <ref id="bib1.bibx31"><label>Goldenberg et al.(2006)Goldenberg, Atman, Claudin, Combe, and Goldhirsch</label><mixed-citation>Goldenberg, C., Atman, A. P. F., Claudin, P., Combe, G., and Goldhirsch, I.: Scale Separation in Granular Packings: Stress Plateaus and Fluctuations, Phys. Rev. Lett., 96, 168001, <ext-link xlink:href="https://doi.org/10.1103/PhysRevLett.96.168001" ext-link-type="DOI">10.1103/PhysRevLett.96.168001</ext-link>, 2006.</mixed-citation></ref>
      <ref id="bib1.bibx32"><label>Goldhirsch(2008)</label><mixed-citation>Goldhirsch, I.: Introduction to granular temperature, Powder Technol., 182, 130–136, <ext-link xlink:href="https://doi.org/10.1016/j.powtec.2007.12.002" ext-link-type="DOI">10.1016/j.powtec.2007.12.002</ext-link>, 2008.</mixed-citation></ref>
      <ref id="bib1.bibx33"><label>Gorbunov et al.(2022)Gorbunov, Volkov, and Voronkov</label><mixed-citation>Gorbunov, S., Volkov, A., and Voronkov, R.: Periodic boundary conditions effects on atomic dynamics analysis, Comput. Phys. Commun., 279, 108454, <ext-link xlink:href="https://doi.org/10.1016/j.cpc.2022.108454" ext-link-type="DOI">10.1016/j.cpc.2022.108454</ext-link>, 2022.</mixed-citation></ref>
      <ref id="bib1.bibx34"><label>Guazzelli(2024)</label><mixed-citation>Guazzelli, E.: Rheology of dense granular suspensions across flow regimes, Phys. Rev. Fluids, 9, 090501, <ext-link xlink:href="https://doi.org/10.1103/PhysRevFluids.9.090501" ext-link-type="DOI">10.1103/PhysRevFluids.9.090501</ext-link>, 2024.</mixed-citation></ref>
      <ref id="bib1.bibx35"><label>Harper et al.(2025)Harper, Dufek, and Breard</label><mixed-citation>Harper, C., Dufek, J., and Breard, E. C. P.: Role of compressional dynamics in setting the scale-dependent rheology of granular flows: An explanation for the emergence of thin layer stability, Phys. Rev. E, 111, 065409, <ext-link xlink:href="https://doi.org/10.1103/qk3y-24s5" ext-link-type="DOI">10.1103/qk3y-24s5</ext-link>, 2025.</mixed-citation></ref>
      <ref id="bib1.bibx36"><label>Harris et al.(2020)Harris, Millman, van der Walt, Gommers, Virtanen, Cournapeau, Wieser, Taylor, Berg, Smith et al.</label><mixed-citation>Harris, C. R., Millman, K. J., van der Walt, S. J., Gommers, R., Virtanen, P., Cournapeau, D., Wieser, E., Taylor, J., Berg, S., Smith, N. J., Kern, R., Picus, M., Hoyer, S., van Kerkwijk, M. H., Brett, M., Haldane, A., Fernández del Río, J., Wiebe, M., Peterson, P., Gérard-Marchant, P., Sheppard, K., Reddy, T., Weckesser, W., Abbasi, H., Gohlke, C., and Oliphant, T. E.: Array programming with NumPy, Nature, 585, 357–362, <ext-link xlink:href="https://doi.org/10.1038/s41586-020-2649-2" ext-link-type="DOI">10.1038/s41586-020-2649-2</ext-link>, 2020.</mixed-citation></ref>
      <ref id="bib1.bibx37"><label>Houssais et al.(2015)Houssais, Ortiz, Durian, and Jerolmack</label><mixed-citation>Houssais, M., Ortiz, C., Durian, D., and Jerolmack, D.: Onset of Sediment Transport Is a Continuous Transition Driven by Fluid Shear and Granular Creep, Nat. Commun., 6, 6527, <ext-link xlink:href="https://doi.org/10.1038/ncomms7527" ext-link-type="DOI">10.1038/ncomms7527</ext-link>, 2015.</mixed-citation></ref>
      <ref id="bib1.bibx38"><label>Hoyer and Hamman(2017)</label><mixed-citation>Hoyer, S. and Hamman, J. J.: xarray: N-D labeled Arrays and Datasets in Python, J. Open Res. Softw., 5, 10, <ext-link xlink:href="https://doi.org/10.5334/jors.148" ext-link-type="DOI">10.5334/jors.148</ext-link>, 2017.</mixed-citation></ref>
      <ref id="bib1.bibx39"><label>Huang(1987)</label><mixed-citation> Huang, K.: Statistical Mechanics, John Wiley &amp; Sons, New York, 2nd Edn., ISBN 978-0-471-81518-1, 1987.</mixed-citation></ref>
      <ref id="bib1.bibx40"><label>IEEE(1990)</label><mixed-citation>IEEE: IEEE Standard Glossary of Software Engineering Terminology, IEEE Std 610.12-1990,   1–84, <ext-link xlink:href="https://doi.org/10.1109/IEEESTD.1990.101064" ext-link-type="DOI">10.1109/IEEESTD.1990.101064</ext-link>, 1990.</mixed-citation></ref>
      <ref id="bib1.bibx41"><label>Itasca Consulting Group(2025)</label><mixed-citation>Itasca Consulting Group, I.: PFC (Particle Flow Code), DEM simulation software, <uri>https://docs.itascacg.com/itasca930/pfc/docproject/source/manual/numerical_simulations_with_pfc/pfc_overview/pfc_overview.html</uri> (last access: 1 October 2026), 2025.</mixed-citation></ref>
      <ref id="bib1.bibx42"><label>Jaynes(1957)</label><mixed-citation>Jaynes, E. T.: Information Theory and Statistical Mechanics, Phys. Rev., 106, 620–630, <ext-link xlink:href="https://doi.org/10.1103/PhysRev.106.620" ext-link-type="DOI">10.1103/PhysRev.106.620</ext-link>, 1957.</mixed-citation></ref>
      <ref id="bib1.bibx43"><label>Jenkins and Savage(1983)</label><mixed-citation>Jenkins, J. T. and Savage, S. B.: A theory for the rapid flow of identical, smooth, nearly elastic, spherical particles, J. Fluid Mech., 130, 187–202, <ext-link xlink:href="https://doi.org/10.1017/S0022112083001044" ext-link-type="DOI">10.1017/S0022112083001044</ext-link>, 1983.</mixed-citation></ref>
      <ref id="bib1.bibx44"><label>Kamrin et al.(2024)Kamrin, Hill, Goldman, and Andrade</label><mixed-citation>Kamrin, K., Hill, K. M., Goldman, D. I., and Andrade, J. E.: Advances in Modeling Dense Granular Media, Annu. Rev. Fluid Mech., 56, 215–240, <ext-link xlink:href="https://doi.org/10.1146/annurev-fluid-121021-022045" ext-link-type="DOI">10.1146/annurev-fluid-121021-022045</ext-link>, 2024.</mixed-citation></ref>
      <ref id="bib1.bibx45"><label>Kishida et al.(2025)Kishida, Nakamura, Ohsaki, and Watano</label><mixed-citation>Kishida, N., Nakamura, H., Ohsaki, S., and Watano, S.: Coarse-grained DEM simulation for mixing and segregation of binary-sized particles, Adv. Powder Technol., 36, 104875, <ext-link xlink:href="https://doi.org/10.1016/j.apt.2025.104875" ext-link-type="DOI">10.1016/j.apt.2025.104875</ext-link>, 2025.</mixed-citation></ref>
      <ref id="bib1.bibx46"><label>Kloss et al.(2012)Kloss, Goniva, Hager, Amberger, and Pirker</label><mixed-citation>Kloss, C., Goniva, C., Hager, A., Amberger, S., and Pirker, S.: Models, algorithms and validation for opensource DEM and CFD–DEM, Prog. Comput. Fl. Dynam., 12, 140–152, <ext-link xlink:href="https://doi.org/10.1504/PCFD.2012.047457" ext-link-type="DOI">10.1504/PCFD.2012.047457</ext-link>, 2012.</mixed-citation></ref>
      <ref id="bib1.bibx47"><label>Koval et al.(2009)Koval, Roux, Corfdir, and Chevoir</label><mixed-citation>Koval, G., Roux, J.-N., Corfdir, A., and Chevoir, F. m. c.: Annular shear of cohesionless granular materials: From the inertial to quasistatic regime, Phys. Rev. E, 79, 021306, <ext-link xlink:href="https://doi.org/10.1103/PhysRevE.79.021306" ext-link-type="DOI">10.1103/PhysRevE.79.021306</ext-link>, 2009.</mixed-citation></ref>
      <ref id="bib1.bibx48"><label>Lam et al.(2015)Lam, Pitrou, and Seibert</label><mixed-citation>Lam, S. K., Pitrou, A., and Seibert, S.: Numba: a LLVM-based Python JIT compiler, in: Proceedings of the Second Workshop on the LLVM Compiler Infrastructure in HPC, LLVM '15, Association for Computing Machinery, New York, NY, USA, ISBN 9781450340052, <ext-link xlink:href="https://doi.org/10.1145/2833157.2833162" ext-link-type="DOI">10.1145/2833157.2833162</ext-link>, 2015.</mixed-citation></ref>
      <ref id="bib1.bibx49"><label>LeCroy(2025)</label><mixed-citation>LeCroy, T.: IOTA Software Suite,   protocol analysis and visualization software, <uri>https://www.teledynelecroy.com/protocolanalyzer/embedded-instruments/iota-software-suite</uri> (last access: 1 October 2026), 2025.</mixed-citation></ref>
      <ref id="bib1.bibx50"><label>Lloyd(1982)</label><mixed-citation>Lloyd, S.: Least squares quantization in PCM, IEEE T. Inform. Theor., 28, 129–137, <ext-link xlink:href="https://doi.org/10.1109/TIT.1982.1056489" ext-link-type="DOI">10.1109/TIT.1982.1056489</ext-link>, 1982.</mixed-citation></ref>
      <ref id="bib1.bibx51"><label>Lu et al.(2021)Lu, Gao, Shahnam, and Rogers</label><mixed-citation>Lu, L., Gao, X., Shahnam, M., and Rogers, W.: Open source implementation of glued sphere discrete element method and nonspherical biomass fast pyrolysis simulation, AIChE J., 67, <ext-link xlink:href="https://doi.org/10.1002/aic.17211" ext-link-type="DOI">10.1002/aic.17211</ext-link>, 2021.</mixed-citation></ref>
      <ref id="bib1.bibx52"><label>Lube et al.(2020)Lube, Breard, Esposti Ongaro, Dufek, and Brand</label><mixed-citation>Lube, G., Breard, E., Esposti Ongaro, T., Dufek, J., and Brand, B.: Multiphase flow behaviour and hazard prediction of pyroclastic density currents, Nat. Rev. Earth  Environ., 1, 348–365, <ext-link xlink:href="https://doi.org/10.1038/s43017-020-0064-8" ext-link-type="DOI">10.1038/s43017-020-0064-8</ext-link>, 2020.</mixed-citation></ref>
      <ref id="bib1.bibx53"><label>Lucas et al.(2014)Lucas, Mangeney, and Ampuero</label><mixed-citation>Lucas, A., Mangeney, A., and Ampuero, J. P.: Frictional velocity-weakening in landslides on Earth and on other planetary bodies, Nat. Commun., 5, 3417, <ext-link xlink:href="https://doi.org/10.1038/ncomms4417" ext-link-type="DOI">10.1038/ncomms4417</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bibx54"><label>Lucy(1977)</label><mixed-citation>Lucy, L. B.: A numerical approach to the testing of the fission hypothesis, Astron. J., 82, 1013–1024, <ext-link xlink:href="https://doi.org/10.1086/112164" ext-link-type="DOI">10.1086/112164</ext-link>, 1977.</mixed-citation></ref>
      <ref id="bib1.bibx55"><label>MacQueen(1967)</label><mixed-citation> MacQueen, J. B.: Some Methods for Classification and Analysis of Multivariate Observations, in: Proceedings of the 5th Berkeley Symposium on Mathematical Statistics and Probability, Volume 1: Statistics,  University of California Press, Berkeley, CA,  281–297, 1967.</mixed-citation></ref>
      <ref id="bib1.bibx56"><label>McIntire et al.(2019)McIntire, Bergantz, and Schleicher</label><mixed-citation>McIntire, M. Z., Bergantz, G. W., and Schleicher, J. M.: On the hydrodynamics of crystal clustering, Philos. T. Roy. Soc. A, 377, 20180015, <ext-link xlink:href="https://doi.org/10.1098/rsta.2018.0015" ext-link-type="DOI">10.1098/rsta.2018.0015</ext-link>, 2019.</mixed-citation></ref>
      <ref id="bib1.bibx57"><label>Morand et al.(2024)Morand, Poppe, Harnett, Cornillon, Heap, and Mège</label><mixed-citation>Morand, A., Poppe, S., Harnett, C., Cornillon, A., Heap, M., and Mège, D.: Fracturing and Dome-Shaped Surface Displacements Above Laccolith Intrusions: Insights From Discrete Element Method Modeling, J. Geophys. Res.-Sol. Ea., 129, e2023JB027423, <ext-link xlink:href="https://doi.org/10.1029/2023JB027423" ext-link-type="DOI">10.1029/2023JB027423</ext-link>, 2024.</mixed-citation></ref>
      <ref id="bib1.bibx58"><label>Morrissey et al.(2020)Morrissey, Totoo, Hanley, Papanicolopulos, Ooi, Gonzalez, Raffin, Mostajabodaveh, and Gierlinger</label><mixed-citation>Morrissey, J., Totoo, P., Hanley, K., Papanicolopulos, S.-A., Ooi, J., Gonzalez, I., Raffin, B., Mostajabodaveh, S., and Gierlinger, T.: Post-processing and visualization of large-scale DEM simulation data with the open-source VELaSSCo platform, SIMULATION, 96, 003754972090646, <ext-link xlink:href="https://doi.org/10.1177/0037549720906465" ext-link-type="DOI">10.1177/0037549720906465</ext-link>, 2020.</mixed-citation></ref>
      <ref id="bib1.bibx59"><label>Murdoch and Bedeaux(1994)</label><mixed-citation>Murdoch, A. I. and Bedeaux, D.: Continuum Equations of Balance Via Weighted Averages of Microscopic Quantities, P. Roy. Soc A., 445, 157–179, <ext-link xlink:href="https://doi.org/10.1098/rspa.1994.0054" ext-link-type="DOI">10.1098/rspa.1994.0054</ext-link>, 1994.</mixed-citation></ref>
      <ref id="bib1.bibx60"><label>O'Donovan et al.(2016)O'Donovan, Ibraim, O'Sullivan et al.</label><mixed-citation>O’Donovan, J., Ibraim, E., O’Sullivan, C., Hamlin, S., Muir Wood, D., and Marketos, G.: Micromechanics of seismic wave propagation in granular materials, Granular Matter, 18, 56, <ext-link xlink:href="https://doi.org/10.1007/s10035-015-0599-4" ext-link-type="DOI">10.1007/s10035-015-0599-4</ext-link>, 2016.</mixed-citation></ref>
      <ref id="bib1.bibx61"><label>Pedregosa et al.(2011)Pedregosa, Varoquaux, Gramfort, Michel, Thirion, Grisel, Blondel, Prettenhofer, Weiss, Dubourg, Vanderplas, Passos, Cournapeau, Brucher, Perrot, and Duchesnay</label><mixed-citation>Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., Vanderplas, J., Passos, A., Cournapeau, D., Brucher, M., Perrot, M., and Duchesnay, E.: Scikit-learn: Machine Learning in Python, J. Mach. Learn. Res., 12, 2825–2830, <ext-link xlink:href="https://doi.org/10.5555/1953048.2078195" ext-link-type="DOI">10.5555/1953048.2078195</ext-link>, 2011.</mixed-citation></ref>
      <ref id="bib1.bibx62"><label>Plimpton(1995)</label><mixed-citation>Plimpton, S.: Fast parallel algorithms for short-range molecular dynamics, J. Comput. Phys., 117, 1–19, <ext-link xlink:href="https://doi.org/10.1006/jcph.1995.1039" ext-link-type="DOI">10.1006/jcph.1995.1039</ext-link>, 1995.</mixed-citation></ref>
      <ref id="bib1.bibx63"><label>Polanía et al.(2025)Polanía, Renouf, Cabrera, Estrada, and Azéma</label><mixed-citation>Polanía, O., Renouf, M., Cabrera, M., Estrada, N., and Azéma, E.: Monodisperse behavior of polydisperse flows, Phys. Rev. E, 111, L043401, <ext-link xlink:href="https://doi.org/10.1103/PhysRevE.111.L043401" ext-link-type="DOI">10.1103/PhysRevE.111.L043401</ext-link>, 2025.</mixed-citation></ref>
      <ref id="bib1.bibx64"><label>Qin et al.(2020)Qin, Allison, and Suckale</label><mixed-citation>Qin, Z., Allison, K., and Suckale, J.: Direct numerical simulations of viscous suspensions with variably shaped crystals, J.  Comput. Phys., 401, 109021, <ext-link xlink:href="https://doi.org/10.1016/j.jcp.2019.109021" ext-link-type="DOI">10.1016/j.jcp.2019.109021</ext-link>, 2020.</mixed-citation></ref>
      <ref id="bib1.bibx65"><label>Quammen(2015)</label><mixed-citation>Quammen, C.: Scientific Data Analysis and Visualization with Python, VTK, and ParaView, in: Proceedings of the 14th Python in Science Conference, edited by: Huff, K. and Bergstra, J., vol. 14,  30–36, <ext-link xlink:href="https://doi.org/10.25080/Majora-7b98e3ed-005" ext-link-type="DOI">10.25080/Majora-7b98e3ed-005</ext-link>, 2015.</mixed-citation></ref>
      <ref id="bib1.bibx66"><label>Rothenburg and Bathurst(1989)</label><mixed-citation>Rothenburg, L. and Bathurst, R. J.: Analytical study of induced anisotropy in idealized granular materials, Géotechnique, 39, 601–614, <ext-link xlink:href="https://doi.org/10.1680/geot.1989.39.4.601" ext-link-type="DOI">10.1680/geot.1989.39.4.601</ext-link>, 1989.</mixed-citation></ref>
      <ref id="bib1.bibx67"><label>Roux and Radjai(1998)</label><mixed-citation>Roux, S. and Radjai, F.: Texture-dependent rigid-plastic behavior, vol. 350, Springer, ISBN 978-94-017-2653-5, <ext-link xlink:href="https://doi.org/10.1007/978-94-017-2653-5_13" ext-link-type="DOI">10.1007/978-94-017-2653-5_13</ext-link>, 1998.</mixed-citation></ref>
      <ref id="bib1.bibx68"><label>Sánchez et al.(2022)Sánchez, Scheeres, and Quillen</label><mixed-citation>Sánchez, P., Scheeres, D. J., and Quillen, A. C.: Transmission of a Seismic Wave Generated by Impacts on Granular Asteroids,   Planet. Sci. J., 3, 245, <ext-link xlink:href="https://doi.org/10.3847/PSJ/ac960c" ext-link-type="DOI">10.3847/PSJ/ac960c</ext-link>, 2022.</mixed-citation></ref>
      <ref id="bib1.bibx69"><label>Savage(1984)</label><mixed-citation>Savage, S. B.: The Mechanics of Rapid Granular Flows, Adv. Appl. Mech., 24, 289–366, <ext-link xlink:href="https://doi.org/10.1016/S0065-2156(08)70047-4" ext-link-type="DOI">10.1016/S0065-2156(08)70047-4</ext-link>, 1984.</mixed-citation></ref>
      <ref id="bib1.bibx70"><label>Schofield and Wroth(1968)</label><mixed-citation> Schofield, A. N. and Wroth, P.: Critical state soil mechanics, vol. 310, McGraw-hill London, ISBN 9780641940484, 1968.</mixed-citation></ref>
      <ref id="bib1.bibx71"><label>Schroeder et al.(2006)Schroeder, Martin, and Lorensen</label><mixed-citation> Schroeder, W., Martin, K., and Lorensen, B.: The Visualization Toolkit, 4th Edn., Kitware, ISBN 978-1-930934-19-1, 2006.</mixed-citation></ref>
      <ref id="bib1.bibx72"><label>Skrodzki(2019)</label><mixed-citation>Skrodzki, M.: The k-d tree data structure and a proof for neighborhood computation in expected logarithmic time, arXiv [preprint], <ext-link xlink:href="https://doi.org/10.48550/arXiv.1903.04936" ext-link-type="DOI">10.48550/arXiv.1903.04936</ext-link>, 2019.</mixed-citation></ref>
      <ref id="bib1.bibx73"><label>Smilauer et al.(2015)Smilauer, Catalano, Chareyre, Dorofeenko, Duriez, Dyck, Elias, Er, Eulitz, Gladky, Guo, Jakob, Kneib, Kozicki, Marzougui, Maurin, Modenese, Scholtes, Sibille, Stransky, Sweijen, Thoeni, and Yuan</label><mixed-citation>Smilauer, V., Catalano, E., Chareyre, B., Dorofeenko, S., Duriez, J., Dyck, N., Elias, J., Er, B., Eulitz, A., Gladky, A., Guo, N., Jakob, C., Kneib, F., Kozicki, J., Marzougui, D., Maurin, R., Modenese, C., Scholtes, L., Sibille, L., Stransky, J., Sweijen, T., Thoeni, K., and Yuan, C.: Yade Documentation 2nd ed, Zenodo, <ext-link xlink:href="https://doi.org/10.5281/zenodo.34073" ext-link-type="DOI">10.5281/zenodo.34073</ext-link>, 2015.</mixed-citation></ref>
      <ref id="bib1.bibx74"><label>Syamlal et al.(1993)Syamlal, Rogers, and O'Brien</label><mixed-citation>Syamlal, M., Rogers, W., and O'Brien, T. J.: MFIX documentation theory guide, Office of Scientific and Technical Information (OSTI), <ext-link xlink:href="https://doi.org/10.2172/10145548" ext-link-type="DOI">10.2172/10145548</ext-link>, 1993.</mixed-citation></ref>
      <ref id="bib1.bibx75"><label>Tong et al.(2022)Tong, Zhai, Li, Zhang, and Sheng</label><mixed-citation>Tong, C.-X., Zhai, M.-Y., Li, H.-C., Zhang, S., and Sheng, D.: Particle breakage of granular soils: changing critical state line and constitutive modelling, Acta Geotech., 17, 755–768, <ext-link xlink:href="https://doi.org/10.1007/s11440-021-01231-8" ext-link-type="DOI">10.1007/s11440-021-01231-8</ext-link>, 2022.</mixed-citation></ref>
      <ref id="bib1.bibx76"><label>Tripathi and Khakhar(2013)</label><mixed-citation>Tripathi, A. and Khakhar, D. V.: Density difference-driven segregation in a dense granular flow, J. Fluid Mech., 717, 643–669, <ext-link xlink:href="https://doi.org/10.1017/jfm.2012.585" ext-link-type="DOI">10.1017/jfm.2012.585</ext-link>, 2013.</mixed-citation></ref>
      <ref id="bib1.bibx77"><label>Tsuji et al.(1993)Tsuji, Tanaka, and Ishida</label><mixed-citation>Tsuji, Y., Tanaka, T., and Ishida, T.: Lagrangian numerical simulation of plug flow of cohesionless particles in a horizontal pipe, Powder Technol., 77, 79–87, <ext-link xlink:href="https://doi.org/10.1016/0032-5910(92)88030-L" ext-link-type="DOI">10.1016/0032-5910(92)88030-L</ext-link>, 1993.</mixed-citation></ref>
      <ref id="bib1.bibx78"><label>Tunuguntla et al.(2014)Tunuguntla, Bokhove, and Thornton</label><mixed-citation>Tunuguntla, D., Bokhove, O., and Thornton, A. R.: A mixture theory for size and density segregation in shallow granular free-surface flows, J. Fluid Mech., 749, 99–112, <ext-link xlink:href="https://doi.org/10.1017/jfm.2014.223" ext-link-type="DOI">10.1017/jfm.2014.223</ext-link>, 2014.</mixed-citation></ref>
      <ref id="bib1.bibx79"><label>Tunuguntla et al.(2017)Tunuguntla, Weinhart, and Thornton</label><mixed-citation>Tunuguntla, D. R., Weinhart, T., and Thornton, A. R.: Comparing and contrasting size-based particle segregation models, Comput. Particle Mech., 4, 387–405, <ext-link xlink:href="https://doi.org/10.1007/s40571-016-0136-1" ext-link-type="DOI">10.1007/s40571-016-0136-1</ext-link>, 2017.</mixed-citation></ref>
      <ref id="bib1.bibx80"><label>Virtanen et al.(2020)Virtanen, Gommers, Oliphant, Haberland, Reddy, Cournapeau, Burovski, Peterson, Weckesser, Bright, van der Walt, Brett, Wilson, Millman, Mayorov, Nelson, Jones, Kern, Larson, Carey, Polat, Feng, Moore, VanderPlas, Laxalde, Perktold, Cimrman, Henriksen, Quintero, Harris, Archibald, Ribeiro, Pedregosa, van Mulbregt, and SciPy 1.0 Contributors</label><mixed-citation>Virtanen, P., Gommers, R., Oliphant, T. E., Haberland, M., Reddy, T., Cournapeau, D., Burovski, E., Peterson, P., Weckesser, W., Bright, J., van der Walt, S. J., Brett, M., Wilson, J., Millman, K. J., Mayorov, N., Nelson, A. R. J., Jones, E., Kern, R., Larson, E., Carey, C. J., Polat, İ., Feng, Y., Moore, E. W., VanderPlas, J., Laxalde, D., Perktold, J., Cimrman, R., Henriksen, I., Quintero, E. A., Harris, C. R., Archibald, A. M., Ribeiro, A. H., Pedregosa, F., van Mulbregt, P., and SciPy 1.0 Contributors: SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python, Nat. Meth., 17, 261–272, <ext-link xlink:href="https://doi.org/10.1038/s41592-019-0686-2" ext-link-type="DOI">10.1038/s41592-019-0686-2</ext-link>, 2020.</mixed-citation></ref>
      <ref id="bib1.bibx81"><label>Walton(1980)</label><mixed-citation>Walton, O. R.: Particle-Dynamics Modeling of Geological Materials, Ph.d. dissertation, University of California, Davis, ISBN 979-8-204-17112-1, <uri>https://www.proquest.com/dissertations-theses/particle-dynamics-modeling-geological-materials/docview/303008003</uri> (last access: 1 October 2026), 1980.</mixed-citation></ref>
      <ref id="bib1.bibx82"><label>Walton and Braun(1986)</label><mixed-citation>Walton, O. R. and Braun, R. L.: Viscosity, granular‐temperature, and stress calculations for shearing assemblies of inelastic, frictional disks, J. Rheol., 30, 949–980, <ext-link xlink:href="https://doi.org/10.1122/1.549893" ext-link-type="DOI">10.1122/1.549893</ext-link>, 1986.</mixed-citation></ref>
      <ref id="bib1.bibx83"><label>Weinhart et al.(2012)Weinhart, Thornton, Luding, and Bokhove</label><mixed-citation>Weinhart, T., Thornton, A. R., Luding, S., and Bokhove, O.: From discrete particles to continuum fields near a boundary, Granular Matter, 14, 289–294, <ext-link xlink:href="https://doi.org/10.1007/s10035-012-0317-4" ext-link-type="DOI">10.1007/s10035-012-0317-4</ext-link>, 2012.</mixed-citation></ref>
      <ref id="bib1.bibx84"><label>Weinhart et al.(2013)Weinhart, Hartkamp, Thornton, and Luding</label><mixed-citation>Weinhart, T., Hartkamp, R., Thornton, A. R., and Luding, S.: Coarse-grained local and objective continuum description of three-dimensional granular flows down an inclined surface, Phys. Fluids, 25, 070605, <ext-link xlink:href="https://doi.org/10.1063/1.4812809" ext-link-type="DOI">10.1063/1.4812809</ext-link>, 2013.</mixed-citation></ref>
      <ref id="bib1.bibx85"><label>Weinhart et al.(2016)Weinhart, Labra, Luding, and Ooi</label><mixed-citation>Weinhart, T., Labra, C., Luding, S., and Ooi, J. Y.: Influence of coarse-graining parameters on the analysis of DEM simulations of silo flow, Powder Technol., 293, 138–148, <ext-link xlink:href="https://doi.org/10.1016/j.powtec.2015.11.052" ext-link-type="DOI">10.1016/j.powtec.2015.11.052</ext-link>, 2016.</mixed-citation></ref>
      <ref id="bib1.bibx86"><label>Weinhart et al.(2020a)Weinhart, Orefice, Post, van Schrojenstein Lantman, Denissen, Tunuguntla, Tsang, Cheng, Shaheen, Shi, Rapino, Grannonio, Losacco, Barbosa, Jing, Alvarez Naranjo, Roy, den Otter, and Thornton</label><mixed-citation>Weinhart, T., Orefice, L., Post, M., van Schrojenstein Lantman, M. P., Denissen, I. F., Tunuguntla, D. R., Tsang, J., Cheng, H., Shaheen, M. Y., Shi, H., Rapino, P., Grannonio, E., Losacco, N., Barbosa, J., Jing, L., Alvarez Naranjo, J. E., Roy, S., den Otter, W. K., and Thornton, A. R.: Fast, flexible particle simulations – An introduction to MercuryDPM, Comput. Phys. Commun., 249, 107129, <ext-link xlink:href="https://doi.org/10.1016/j.cpc.2019.107129" ext-link-type="DOI">10.1016/j.cpc.2019.107129</ext-link>, 2020a.</mixed-citation></ref>
      <ref id="bib1.bibx87"><label>Weinhart et al.(2020b)Weinhart, Orefice, Post, van Schrojenstein Lantman, Denissen, Tunuguntla, Tsang, Cheng, Shaheen, Shi, Rapino, Grannonio, Losacco, Barbosa, Jing, Alvarez Naranjo, Roy, den Otter, and Thornton</label><mixed-citation>Weinhart, T., Orefice, L., Post, M., van Schrojenstein Lantman, M. P., Denissen, I. F., Tunuguntla, D. R., Tsang, J., Cheng, H., Shaheen, M. Y., Shi, H., Rapino, P., Grannonio, E., Losacco, N., Barbosa, J., Jing, L., Alvarez Naranjo, J. E., Roy, S., den Otter, W. K., and Thornton, A. R.: Fast, flexible particle simulations – An introduction to MercuryDPM, Comput. Phys. Commun., 249, 107129, <ext-link xlink:href="https://doi.org/10.1016/j.cpc.2019.107129" ext-link-type="DOI">10.1016/j.cpc.2019.107129</ext-link>, 2020b.</mixed-citation></ref>
      <ref id="bib1.bibx88"><label>Windows-Yule et al.(2019)Windows-Yule, Mühlbauer, Cisneros, Nair, Marzulli, and Pöschel</label><mixed-citation>Windows-Yule, C. R. K., Mühlbauer, S., Cisneros, L. A. T., Nair, P., Marzulli, V., and Pöschel, T.: Janssen effect in dynamic particulate systems, Phys. Rev. E, 100, 022902, <ext-link xlink:href="https://doi.org/10.1103/PhysRevE.100.022902" ext-link-type="DOI">10.1103/PhysRevE.100.022902</ext-link>, 2019. </mixed-citation></ref>
      <ref id="bib1.bibx89"><label>Zhang and Kamrin(2017)</label><mixed-citation>Zhang, Q. and Kamrin, K.: Microscopic Description of the Granular Fluidity Field in Nonlocal Flow Modeling, Phys. Rev. Lett., 118, 058001, <ext-link xlink:href="https://doi.org/10.1103/PhysRevLett.118.058001" ext-link-type="DOI">10.1103/PhysRevLett.118.058001</ext-link>, 2017.</mixed-citation></ref>
      <ref id="bib1.bibx90"><label>Zhang and Campbell(1992)</label><mixed-citation>Zhang, Y. and Campbell, C. S.: The interface between fluid-like and solid-like behaviour in two-dimensional granular flows, J. Fluid Mech., 237, 541–568, <ext-link xlink:href="https://doi.org/10.1017/S0022112092003525" ext-link-type="DOI">10.1017/S0022112092003525</ext-link>, 1992.</mixed-citation></ref>
      <ref id="bib1.bibx91"><label>Zrelak et al.(2024)Zrelak, Breard, and Dufek</label><mixed-citation>Zrelak, P., Breard, E. C. P., and Dufek, J.: Basal Force Fluctuations and Granular Rheology: Linking Macroscopic Descriptions of Granular Flows to Bed Forces With Implications for Monitoring Signals, J. Geophys. Res.-Earth, 129, e2024JF007760, <ext-link xlink:href="https://doi.org/10.1029/2024JF007760" ext-link-type="DOI">10.1029/2024JF007760</ext-link>, 2024.</mixed-citation></ref>
      <ref id="bib1.bibx92"><label>Zrelak et al.(2026)Zrelak, Breard, and Dufek</label><mixed-citation>Zrelak, P., Breard, E. C. P., and Dufek, J.: The Role of Basal Roughness and Assemblage Grain-Size Distribution in Shaping Granular Rheology and Basal-Force Signals, J. Geophys. Res.-Earth, 131, e2025JF008538, <ext-link xlink:href="https://doi.org/10.1029/2025JF008538" ext-link-type="DOI">10.1029/2025JF008538</ext-link>, 2026.</mixed-citation></ref>

  </ref-list></back>
    <!--<article-title-html>Pysammos 1.0.0: a discrete-to-continuum transformation Python tool to analyse the rheology of granular materials</article-title-html>
<abstract-html/>
<ref-html id="bib1.bib1"><label>Alihosseini et al.(2020)Alihosseini, Sægrov, and
Thamsen</label><mixed-citation>
      
Alihosseini, M., Sægrov, S., and Thamsen, P. U.: CFD-DEM modelling of
sediment transport in sewer systems under steady and unsteady flow
conditions, Water Sci. Technol., 80, 2141–2147,
<a href="https://doi.org/10.2166/wst.2020.030" target="_blank">https://doi.org/10.2166/wst.2020.030</a>, 2020.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib2"><label>Altair Engineering, Inc.(2025)</label><mixed-citation>
      
Altair Engineering, Inc.: Altair EDEM, Software, Siemens,
<a href="https://altair.com/edem/" target="_blank"/> (last access: 1 October 2026), 2025.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib3"><label>Archimedes(2009)</label><mixed-citation>
      
Archimedes: The Sand-Reckoner,  Cambridge Library Collection –
Mathematics, Cambridge University Press, Cambridge,  221–232,
<a href="https://doi.org/10.1017/CBO9780511695124.018" target="_blank">https://doi.org/10.1017/CBO9780511695124.018</a>, 2009.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib4"><label>Artoni and Richard(2015)</label><mixed-citation>
      
Artoni, R. and Richard, P.: Average balance equations, scale dependence, and
energy cascade for granular materials, Phys. Rev. E, 91, 032202,
<a href="https://doi.org/10.1103/PhysRevE.91.032202" target="_blank">https://doi.org/10.1103/PhysRevE.91.032202</a>, 2015.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib5"><label>Babic(1997)</label><mixed-citation>
      
Babic, M.: Average balance equations for granular materials, Int.
J. Eng. Sci., 35, 523–548,
<a href="https://doi.org/10.1016/S0020-7225(96)00094-8" target="_blank">https://doi.org/10.1016/S0020-7225(96)00094-8</a>, 1997.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib6"><label>Baghban et al.(2021)Baghban, Arulrajah, Narsilio, and
Horpibulsuk</label><mixed-citation>
      
Baghban, H., Arulrajah, A., Narsilio, G. A., and Horpibulsuk, S.: DEM
simulation of the thermo-geomechanical effect of recycled concrete aggregate
assemblies in geothermal pavement bases, Transport. Geotech., 28,
100528, <a href="https://doi.org/10.1016/j.trgeo.2021.100528" target="_blank">https://doi.org/10.1016/j.trgeo.2021.100528</a>, 2021.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib7"><label>Barker and Gray(2017)</label><mixed-citation>
      
Barker, T. and Gray, J. M. N. T.: Partial regularisation of the incompressible
<i>μ</i>(I)-rheology for granular flow, J. Fluid Mech., 828, 5–32,
<a href="https://doi.org/10.1017/jfm.2017.428" target="_blank">https://doi.org/10.1017/jfm.2017.428</a>, 2017.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib8"><label>Blatny et al.(2024)Blatny, Gray, and Gaume</label><mixed-citation>
      
Blatny, L., Gray, J., and Gaume, J.: A critical state μ(I)-rheology model for
cohesive granular flows, J. Fluid Mech., 997, A67,
<a href="https://doi.org/10.1017/jfm.2024.643" target="_blank">https://doi.org/10.1017/jfm.2024.643</a>, 2024.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib9"><label>Boyer et al.(2011)Boyer, Guazzelli, and
Pouliquen</label><mixed-citation>
      
Boyer, F. M. C., Guazzelli, E., and Pouliquen, O.: Unifying Suspension and
Granular Rheology, Phys. Rev. Lett., 107, 188301,
<a href="https://doi.org/10.1103/PhysRevLett.107.188301" target="_blank">https://doi.org/10.1103/PhysRevLett.107.188301</a>, 2011.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib10"><label>Breard et al.(2022)Breard, Fullard, Dufek, Thomas, Wadsworth, Heap,
and Lavallée</label><mixed-citation>
      
Breard, E. C. P., Fullard, L., Dufek, J., Thomas, N., Wadsworth, F. B., Heap,
M. J., and Lavallée, Y.: Investigating the rheology of fluidized and
non-fluidized gas-particle beds: implications for the dynamics of geophysical
flows and substrate entrainment, Granular Matter, 24, 34,
<a href="https://doi.org/10.1007/s10035-021-01192-5" target="_blank">https://doi.org/10.1007/s10035-021-01192-5</a>, 2022.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib11"><label>Breard et al.(2023a)Breard, Dufek, Charbonnier, Valentin, Giachetti,
and Walsh</label><mixed-citation>
      
Breard, E. C. P., Dufek, J., Charbonnier, S., Valentin, G., Giachetti, T., and
Walsh, B.: The fragmentation-induced fluidisation of pyroclastic density
currents, Nat. Commun., 14, 2079, <a href="https://doi.org/10.1038/s41467-023-37867-1" target="_blank">https://doi.org/10.1038/s41467-023-37867-1</a>,
2023a.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib12"><label>Brockbank et al.(1997)Brockbank, Huntley, and
Ball</label><mixed-citation>
      
Brockbank, R., Huntley, J., and Ball, R.: Contact force distribution beneath a
three-dimensional granular pile, J. Phys. II, 7, 1521–1532,
<a href="https://doi.org/10.1051/jp2:1997200" target="_blank">https://doi.org/10.1051/jp2:1997200</a>, 1997.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib13"><label>Carrara et al.(2024)Carrara, Burgisser, and
Bergantz</label><mixed-citation>
      
Carrara, A., Burgisser, A., and Bergantz, G. W.: Numerical simulations of the
mingling caused by a magma intruding a resident mush, Volcanica, 7, 89–104,
<a href="https://doi.org/10.30909/vol.07.01.89104" target="_blank">https://doi.org/10.30909/vol.07.01.89104</a>, 2024.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib14"><label>Christoffersen et al.(1981)Christoffersen, Mehrabadi, and
Nemat-Nasser</label><mixed-citation>
      
Christoffersen, J., Mehrabadi, M. M., and Nemat-Nasser, S.: A micromechanical
description of granular material behavior, J. Appl. Mech., 48,
339–344, <a href="https://doi.org/10.1115/1.3157601" target="_blank">https://doi.org/10.1115/1.3157601</a>, 1981.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib15"><label>Cundall(1971)</label><mixed-citation>
      
Cundall, P. A.: A Computer Model for Progressive Simulating Large-Scale
Movements in Blocky Rock Systems, in: Proceedings of the Symposium of the
International Society for Rock Mechanics, Nancy,  vol. 1,  11–18,  1971.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib16"><label>Cundall and Strack(1979)</label><mixed-citation>
      
Cundall, P. A. and Strack, O. D. L.: A discrete numerical model for granular
assemblies, Géotechnique, 29, 47–65, <a href="https://doi.org/10.1680/geot.1979.29.1.47" target="_blank">https://doi.org/10.1680/geot.1979.29.1.47</a>, 1979.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib17"><label>Dai et al.(2025)Dai, Gao, Niu, Zhou, Zhang, Tian, Guo, and
Zhang</label><mixed-citation>
      
Dai, S., Gao, F., Niu, G., Zhou, W., Zhang, C., Tian, Y., Guo, Y., and Zhang,
J.: Dynamics of particle segregation and its impact on mechanical properties,
Acta Geotech., 20, 1991–2007, <a href="https://doi.org/10.1007/s11440-025-02547-5" target="_blank">https://doi.org/10.1007/s11440-025-02547-5</a>, 2025.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib18"><label>de Gennes(1999)</label><mixed-citation>
      
de Gennes, P. G.: Granular matter: a tentative view, Rev. Mod. Phys., 71,
S374–S382, <a href="https://doi.org/10.1103/RevModPhys.71.S374" target="_blank">https://doi.org/10.1103/RevModPhys.71.S374</a>, 1999.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib19"><label>Dobry and Ng(1992)</label><mixed-citation>
      
Dobry, R. and Ng, T.-T.: Discrete modelling of stress-strain behaviour of
granular media at small and large strains, Eng. Comput., 9,
129–143, <a href="https://doi.org/10.1108/eb023853" target="_blank">https://doi.org/10.1108/eb023853</a>, 1992.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib20"><label>Drahun and Bridgwater(1983)</label><mixed-citation>
      
Drahun, J. A. and Bridgwater, J.: The mechanisms of free surface segregation,
Powder Technol., 36, 39–53, <a href="https://doi.org/10.1016/0032-5910(83)80007-2" target="_blank">https://doi.org/10.1016/0032-5910(83)80007-2</a>, 1983.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib21"><label>Elijas-Parra et al.(2026a)Elijas-Parra, Breard,
Morrissey, Zrelak, and Naylor</label><mixed-citation>
      
Elijas-Parra, C., Breard, E., Morrissey, J., Zrelak, P. J., and Naylor, M.:
Claudia-Elijas/pysammos: Pysammos v1.0.0, Zenodo [code], <a href="https://doi.org/10.5281/zenodo.19355667" target="_blank">https://doi.org/10.5281/zenodo.19355667</a>,
2026a.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib22"><label>Elijas-Parra et al.(2026b)Elijas-Parra, Breard,
Morrissey, Zrelak, and Naylor</label><mixed-citation>
      
Elijas-Parra, C., Breard, E., Morrissey, J., Zrelak, P. J., and Naylor, M.:
Example granular material simulation data for the Pysammos Python package, Zenodo [code],
<a href="https://doi.org/10.5281/zenodo.19351802" target="_blank">https://doi.org/10.5281/zenodo.19351802</a>, 2026b.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib23"><label>Fateman(1989)</label><mixed-citation>
      
Fateman, R. J.: Lookup tables, recurrences and complexity, in: Proceedings of
the ACM-SIGSAM 1989 International Symposium on Symbolic and Algebraic
Computation, ISSAC '89, Association for Computing Machinery, New
York, NY, USA,  68–73, ISBN 0897913256, <a href="https://doi.org/10.1145/74540.74549" target="_blank">https://doi.org/10.1145/74540.74549</a>, 1989.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib24"><label>Gabellini et al.(2025)Gabellini, Rossi, Cioni
et al.</label><mixed-citation>
      
Gabellini, P., Rossi, E., Cioni, R., Pistolesi, M., Baumgartner, L. P., and Bonadonna, C.: X-Ray micro-tomography unveils the
internal features of volcanic ash aggregates, Commun. Earth
Environ., 6, 521, <a href="https://doi.org/10.1038/s43247-025-02378-y" target="_blank">https://doi.org/10.1038/s43247-025-02378-y</a>, 2025.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib25"><label>Gallier et al.(2014)Gallier, Lemaire, Peters, and
Lobry</label><mixed-citation>
      
Gallier, S., Lemaire, E., Peters, F., and Lobry, L.: Rheology of sheared
suspensions of rough frictional particles, J. Fluid Mech., 757,
514–549, <a href="https://doi.org/10.1017/jfm.2014.507" target="_blank">https://doi.org/10.1017/jfm.2014.507</a>, 2014.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib26"><label>Gao et al.(2022)Gao, Yu, Portal, Dietiker, Shahnam, and
Rogers</label><mixed-citation>
      
Gao, X., Yu, J., Portal, R. J., Dietiker, J.-F., Shahnam, M., and Rogers,
W. A.: Development and validation of SuperDEM for non-spherical particulate
systems using a superquadric particle method, Particuology, 61, 74–90,
<a href="https://doi.org/10.1016/j.partic.2020.11.007" target="_blank">https://doi.org/10.1016/j.partic.2020.11.007</a>, 2022.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib27"><label>Garres-Díaz et al.(2020)Garres-Díaz, Bouchut, Fernández-Nieto,
Mangeney, and Narbona-Reina</label><mixed-citation>
      
Garres-Díaz, J., Bouchut, F., Fernández-Nieto, E., Mangeney, A., and
Narbona-Reina, G.: Multilayer models for shallow two-phase debris flows with
dilatancy effects, J. Comput. Phys., 419, 109699,
<a href="https://doi.org/10.1016/j.jcp.2020.109699" target="_blank">https://doi.org/10.1016/j.jcp.2020.109699</a>, 2020.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib28"><label>GDR MiDi(2004)</label><mixed-citation>
      
GDR MiDi: On dense granular flows,  European Phys. J. E, 14, 341–365,
<a href="https://doi.org/10.1140/epje/i2003-10153-0" target="_blank">https://doi.org/10.1140/epje/i2003-10153-0</a>, 2004.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib29"><label>Giordano et al.(2008)Giordano, Russell, and
Dingwell</label><mixed-citation>
      
Giordano, D., Russell, J. K., and Dingwell, D. B.: Viscosity of magmatic
liquids: A model, Earth   Planet. Sc. Lett., 271, 123–134,
<a href="https://doi.org/10.1016/j.epsl.2008.03.038" target="_blank">https://doi.org/10.1016/j.epsl.2008.03.038</a>, 2008.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib30"><label>Glasser and Goldhirsch(2001)</label><mixed-citation>
      
Glasser, B. J. and Goldhirsch, I.: Scale dependence, correlations, and
fluctuations of stresses in rapid granular flows, Phys. Fluid., 13,
407–420, <a href="https://doi.org/10.1063/1.1338543" target="_blank">https://doi.org/10.1063/1.1338543</a>, 2001.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib31"><label>Goldenberg et al.(2006)Goldenberg, Atman, Claudin, Combe, and
Goldhirsch</label><mixed-citation>
      
Goldenberg, C., Atman, A. P. F., Claudin, P., Combe, G., and Goldhirsch, I.:
Scale Separation in Granular Packings: Stress Plateaus and Fluctuations,
Phys. Rev. Lett., 96, 168001, <a href="https://doi.org/10.1103/PhysRevLett.96.168001" target="_blank">https://doi.org/10.1103/PhysRevLett.96.168001</a>, 2006.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib32"><label>Goldhirsch(2008)</label><mixed-citation>
      
Goldhirsch, I.: Introduction to granular temperature, Powder Technol., 182,
130–136, <a href="https://doi.org/10.1016/j.powtec.2007.12.002" target="_blank">https://doi.org/10.1016/j.powtec.2007.12.002</a>, 2008.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib33"><label>Gorbunov et al.(2022)Gorbunov, Volkov, and
Voronkov</label><mixed-citation>
      
Gorbunov, S., Volkov, A., and Voronkov, R.: Periodic boundary conditions
effects on atomic dynamics analysis, Comput. Phys. Commun., 279,
108454, <a href="https://doi.org/10.1016/j.cpc.2022.108454" target="_blank">https://doi.org/10.1016/j.cpc.2022.108454</a>, 2022.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib34"><label>Guazzelli(2024)</label><mixed-citation>
      
Guazzelli, E.: Rheology of dense granular suspensions across flow regimes,
Phys. Rev. Fluids, 9, 090501, <a href="https://doi.org/10.1103/PhysRevFluids.9.090501" target="_blank">https://doi.org/10.1103/PhysRevFluids.9.090501</a>, 2024.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib35"><label>Harper et al.(2025)Harper, Dufek, and
Breard</label><mixed-citation>
      
Harper, C., Dufek, J., and Breard, E. C. P.: Role of compressional dynamics in
setting the scale-dependent rheology of granular flows: An explanation for
the emergence of thin layer stability, Phys. Rev. E, 111, 065409,
<a href="https://doi.org/10.1103/qk3y-24s5" target="_blank">https://doi.org/10.1103/qk3y-24s5</a>, 2025.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib36"><label>Harris et al.(2020)Harris, Millman, van der Walt, Gommers, Virtanen,
Cournapeau, Wieser, Taylor, Berg, Smith et al.</label><mixed-citation>
      
Harris, C. R., Millman, K. J., van der Walt, S. J., Gommers, R., Virtanen, P., Cournapeau, D., Wieser, E., Taylor, J., Berg, S., Smith, N. J.,
Kern, R., Picus, M., Hoyer, S., van Kerkwijk, M. H., Brett, M., Haldane, A., Fernández del Río, J., Wiebe, M., Peterson, P., Gérard-Marchant, P., Sheppard, K., Reddy, T., Weckesser, W., Abbasi, H., Gohlke, C., and Oliphant, T. E.: Array
programming with NumPy, Nature, 585, 357–362,
<a href="https://doi.org/10.1038/s41586-020-2649-2" target="_blank">https://doi.org/10.1038/s41586-020-2649-2</a>, 2020.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib37"><label>Houssais et al.(2015)Houssais, Ortiz, Durian, and
Jerolmack</label><mixed-citation>
      
Houssais, M., Ortiz, C., Durian, D., and Jerolmack, D.: Onset of Sediment
Transport Is a Continuous Transition Driven by Fluid Shear and Granular
Creep, Nat. Commun., 6, 6527, <a href="https://doi.org/10.1038/ncomms7527" target="_blank">https://doi.org/10.1038/ncomms7527</a>, 2015.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib38"><label>Hoyer and Hamman(2017)</label><mixed-citation>
      
Hoyer, S. and Hamman, J. J.: xarray: N-D labeled Arrays and Datasets in
Python, J. Open Res. Softw., 5, 10, <a href="https://doi.org/10.5334/jors.148" target="_blank">https://doi.org/10.5334/jors.148</a>,
2017.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib39"><label>Huang(1987)</label><mixed-citation>
      
Huang, K.: Statistical Mechanics, John Wiley &amp; Sons, New York, 2nd Edn., ISBN
978-0-471-81518-1, 1987.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib40"><label>IEEE(1990)</label><mixed-citation>
      
IEEE: IEEE Standard Glossary of Software Engineering Terminology, IEEE Std
610.12-1990,   1–84, <a href="https://doi.org/10.1109/IEEESTD.1990.101064" target="_blank">https://doi.org/10.1109/IEEESTD.1990.101064</a>, 1990.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib41"><label>Itasca Consulting Group(2025)</label><mixed-citation>
      
Itasca Consulting Group, I.: PFC (Particle Flow Code), DEM simulation software,
<a href="https://docs.itascacg.com/itasca930/pfc/docproject/source/manual/numerical_simulations_with_pfc/pfc_overview/pfc_overview.html" target="_blank"/> (last access: 1 October 2026),
2025.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib42"><label>Jaynes(1957)</label><mixed-citation>
      
Jaynes, E. T.: Information Theory and Statistical Mechanics, Phys. Rev., 106,
620–630, <a href="https://doi.org/10.1103/PhysRev.106.620" target="_blank">https://doi.org/10.1103/PhysRev.106.620</a>, 1957.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib43"><label>Jenkins and Savage(1983)</label><mixed-citation>
      
Jenkins, J. T. and Savage, S. B.: A theory for the rapid flow of identical,
smooth, nearly elastic, spherical particles, J. Fluid Mech., 130,
187–202, <a href="https://doi.org/10.1017/S0022112083001044" target="_blank">https://doi.org/10.1017/S0022112083001044</a>, 1983.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib44"><label>Kamrin et al.(2024)Kamrin, Hill, Goldman, and
Andrade</label><mixed-citation>
      
Kamrin, K., Hill, K. M., Goldman, D. I., and Andrade, J. E.: Advances in
Modeling Dense Granular Media, Annu. Rev. Fluid Mech., 56,
215–240, <a href="https://doi.org/10.1146/annurev-fluid-121021-022045" target="_blank">https://doi.org/10.1146/annurev-fluid-121021-022045</a>, 2024.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib45"><label>Kishida et al.(2025)Kishida, Nakamura, Ohsaki, and
Watano</label><mixed-citation>
      
Kishida, N., Nakamura, H., Ohsaki, S., and Watano, S.: Coarse-grained DEM
simulation for mixing and segregation of binary-sized particles, Adv.
Powder Technol., 36, 104875, <a href="https://doi.org/10.1016/j.apt.2025.104875" target="_blank">https://doi.org/10.1016/j.apt.2025.104875</a>, 2025.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib46"><label>Kloss et al.(2012)Kloss, Goniva, Hager, Amberger, and
Pirker</label><mixed-citation>
      
Kloss, C., Goniva, C., Hager, A., Amberger, S., and Pirker, S.: Models,
algorithms and validation for opensource DEM and CFD–DEM, Prog.
Comput. Fl. Dynam., 12, 140–152, <a href="https://doi.org/10.1504/PCFD.2012.047457" target="_blank">https://doi.org/10.1504/PCFD.2012.047457</a>,
2012.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib47"><label>Koval et al.(2009)Koval, Roux, Corfdir, and
Chevoir</label><mixed-citation>
      
Koval, G., Roux, J.-N., Corfdir, A., and Chevoir, F. m. c.: Annular shear of
cohesionless granular materials: From the inertial to quasistatic regime,
Phys. Rev. E, 79, 021306, <a href="https://doi.org/10.1103/PhysRevE.79.021306" target="_blank">https://doi.org/10.1103/PhysRevE.79.021306</a>, 2009.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib48"><label>Lam et al.(2015)Lam, Pitrou, and Seibert</label><mixed-citation>
      
Lam, S. K., Pitrou, A., and Seibert, S.: Numba: a LLVM-based Python JIT
compiler, in: Proceedings of the Second Workshop on the LLVM Compiler
Infrastructure in HPC, LLVM '15, Association for Computing Machinery, New
York, NY, USA, ISBN 9781450340052, <a href="https://doi.org/10.1145/2833157.2833162" target="_blank">https://doi.org/10.1145/2833157.2833162</a>, 2015.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib49"><label>LeCroy(2025)</label><mixed-citation>
      
LeCroy, T.: IOTA Software Suite,   protocol analysis and visualization software,
<a href="https://www.teledynelecroy.com/protocolanalyzer/embedded-instruments/iota-software-suite" target="_blank"/> (last access: 1 October 2026),
2025.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib50"><label>Lloyd(1982)</label><mixed-citation>
      
Lloyd, S.: Least squares quantization in PCM, IEEE T.
Inform. Theor., 28, 129–137, <a href="https://doi.org/10.1109/TIT.1982.1056489" target="_blank">https://doi.org/10.1109/TIT.1982.1056489</a>, 1982.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib51"><label>Lu et al.(2021)Lu, Gao, Shahnam, and Rogers</label><mixed-citation>
      
Lu, L., Gao, X., Shahnam, M., and Rogers, W.: Open source implementation of
glued sphere discrete element method and nonspherical biomass fast pyrolysis
simulation, AIChE J., 67, <a href="https://doi.org/10.1002/aic.17211" target="_blank">https://doi.org/10.1002/aic.17211</a>, 2021.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib52"><label>Lube et al.(2020)Lube, Breard, Esposti Ongaro, Dufek, and
Brand</label><mixed-citation>
      
Lube, G., Breard, E., Esposti Ongaro, T., Dufek, J., and Brand, B.: Multiphase
flow behaviour and hazard prediction of pyroclastic density currents, Nat.
Rev. Earth  Environ., 1, 348–365, <a href="https://doi.org/10.1038/s43017-020-0064-8" target="_blank">https://doi.org/10.1038/s43017-020-0064-8</a>,
2020.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib53"><label>Lucas et al.(2014)Lucas, Mangeney, and
Ampuero</label><mixed-citation>
      
Lucas, A., Mangeney, A., and Ampuero, J. P.: Frictional velocity-weakening in
landslides on Earth and on other planetary bodies, Nat. Commun., 5,
3417, <a href="https://doi.org/10.1038/ncomms4417" target="_blank">https://doi.org/10.1038/ncomms4417</a>, 2014.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib54"><label>Lucy(1977)</label><mixed-citation>
      
Lucy, L. B.: A numerical approach to the testing of the fission hypothesis,
Astron. J., 82, 1013–1024, <a href="https://doi.org/10.1086/112164" target="_blank">https://doi.org/10.1086/112164</a>, 1977.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib55"><label>MacQueen(1967)</label><mixed-citation>
      
MacQueen, J. B.: Some Methods for Classification and Analysis of Multivariate
Observations, in: Proceedings of the 5th Berkeley Symposium on Mathematical
Statistics and Probability, Volume 1: Statistics,  University of
California Press, Berkeley, CA,  281–297, 1967.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib56"><label>McIntire et al.(2019)McIntire, Bergantz, and
Schleicher</label><mixed-citation>
      
McIntire, M. Z., Bergantz, G. W., and Schleicher, J. M.: On the hydrodynamics
of crystal clustering, Philos. T. Roy. Soc. A, 377, 20180015,
<a href="https://doi.org/10.1098/rsta.2018.0015" target="_blank">https://doi.org/10.1098/rsta.2018.0015</a>, 2019.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib57"><label>Morand et al.(2024)Morand, Poppe, Harnett, Cornillon, Heap, and
Mège</label><mixed-citation>
      
Morand, A., Poppe, S., Harnett, C., Cornillon, A., Heap, M., and Mège, D.:
Fracturing and Dome-Shaped Surface Displacements Above Laccolith Intrusions:
Insights From Discrete Element Method Modeling, J. Geophys.
Res.-Sol. Ea., 129, e2023JB027423, <a href="https://doi.org/10.1029/2023JB027423" target="_blank">https://doi.org/10.1029/2023JB027423</a>,
2024.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib58"><label>Morrissey et al.(2020)Morrissey, Totoo, Hanley, Papanicolopulos, Ooi,
Gonzalez, Raffin, Mostajabodaveh, and Gierlinger</label><mixed-citation>
      
Morrissey, J., Totoo, P., Hanley, K., Papanicolopulos, S.-A., Ooi, J.,
Gonzalez, I., Raffin, B., Mostajabodaveh, S., and Gierlinger, T.:
Post-processing and visualization of large-scale DEM simulation data with the
open-source VELaSSCo platform, SIMULATION, 96, 003754972090646,
<a href="https://doi.org/10.1177/0037549720906465" target="_blank">https://doi.org/10.1177/0037549720906465</a>, 2020.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib59"><label>Murdoch and Bedeaux(1994)</label><mixed-citation>
      
Murdoch, A. I. and Bedeaux, D.: Continuum Equations of Balance Via Weighted
Averages of Microscopic Quantities, P. Roy. Soc A., 445, 157–179, <a href="https://doi.org/10.1098/rspa.1994.0054" target="_blank">https://doi.org/10.1098/rspa.1994.0054</a>, 1994.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib60"><label>O'Donovan et al.(2016)O'Donovan, Ibraim, O'Sullivan
et al.</label><mixed-citation>
      
O’Donovan, J., Ibraim, E., O’Sullivan, C., Hamlin, S., Muir Wood, D., and Marketos, G.: Micromechanics of seismic
wave propagation in granular materials, Granular Matter, 18, 56,
<a href="https://doi.org/10.1007/s10035-015-0599-4" target="_blank">https://doi.org/10.1007/s10035-015-0599-4</a>, 2016.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib61"><label>Pedregosa et al.(2011)Pedregosa, Varoquaux, Gramfort, Michel,
Thirion, Grisel, Blondel, Prettenhofer, Weiss, Dubourg, Vanderplas, Passos,
Cournapeau, Brucher, Perrot, and Duchesnay</label><mixed-citation>
      
Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel,
O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., Vanderplas, J.,
Passos, A., Cournapeau, D., Brucher, M., Perrot, M., and Duchesnay, E.:
Scikit-learn: Machine Learning in Python, J. Mach. Learn.
Res., 12, 2825–2830, <a href="https://doi.org/10.5555/1953048.2078195" target="_blank">https://doi.org/10.5555/1953048.2078195</a>, 2011.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib62"><label>Plimpton(1995)</label><mixed-citation>
      
Plimpton, S.: Fast parallel algorithms for short-range molecular dynamics, J.
Comput. Phys., 117, 1–19, <a href="https://doi.org/10.1006/jcph.1995.1039" target="_blank">https://doi.org/10.1006/jcph.1995.1039</a>, 1995.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib63"><label>Polanía et al.(2025)Polanía, Renouf, Cabrera, Estrada, and
Azéma</label><mixed-citation>
      
Polanía, O., Renouf, M., Cabrera, M., Estrada, N., and Azéma, E.:
Monodisperse behavior of polydisperse flows, Phys. Rev. E, 111, L043401,
<a href="https://doi.org/10.1103/PhysRevE.111.L043401" target="_blank">https://doi.org/10.1103/PhysRevE.111.L043401</a>, 2025.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib64"><label>Qin et al.(2020)Qin, Allison, and Suckale</label><mixed-citation>
      
Qin, Z., Allison, K., and Suckale, J.: Direct numerical simulations of viscous
suspensions with variably shaped crystals, J.  Comput. Phys.,
401, 109021, <a href="https://doi.org/10.1016/j.jcp.2019.109021" target="_blank">https://doi.org/10.1016/j.jcp.2019.109021</a>, 2020.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib65"><label>Quammen(2015)</label><mixed-citation>
      
Quammen, C.: Scientific Data Analysis and Visualization with Python, VTK,
and ParaView, in: Proceedings of the 14th Python in Science Conference,
edited by: Huff, K. and Bergstra, J., vol. 14,  30–36,
<a href="https://doi.org/10.25080/Majora-7b98e3ed-005" target="_blank">https://doi.org/10.25080/Majora-7b98e3ed-005</a>, 2015.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib66"><label>Rothenburg and Bathurst(1989)</label><mixed-citation>
      
Rothenburg, L. and Bathurst, R. J.: Analytical study of induced anisotropy in
idealized granular materials, Géotechnique, 39, 601–614,
<a href="https://doi.org/10.1680/geot.1989.39.4.601" target="_blank">https://doi.org/10.1680/geot.1989.39.4.601</a>, 1989.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib67"><label>Roux and Radjai(1998)</label><mixed-citation>
      
Roux, S. and Radjai, F.: Texture-dependent rigid-plastic behavior, vol. 350,
Springer, ISBN 978-94-017-2653-5, <a href="https://doi.org/10.1007/978-94-017-2653-5_13" target="_blank">https://doi.org/10.1007/978-94-017-2653-5_13</a>, 1998.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib68"><label>Sánchez et al.(2022)Sánchez, Scheeres, and
Quillen</label><mixed-citation>
      
Sánchez, P., Scheeres, D. J., and Quillen, A. C.: Transmission of a Seismic
Wave Generated by Impacts on Granular Asteroids,   Planet. Sci.
J., 3, 245, <a href="https://doi.org/10.3847/PSJ/ac960c" target="_blank">https://doi.org/10.3847/PSJ/ac960c</a>, 2022.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib69"><label>Savage(1984)</label><mixed-citation>
      
Savage, S. B.: The Mechanics of Rapid Granular Flows, Adv. Appl.
Mech., 24, 289–366, <a href="https://doi.org/10.1016/S0065-2156(08)70047-4" target="_blank">https://doi.org/10.1016/S0065-2156(08)70047-4</a>, 1984.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib70"><label>Schofield and Wroth(1968)</label><mixed-citation>
      
Schofield, A. N. and Wroth, P.: Critical state soil mechanics, vol. 310,
McGraw-hill London, ISBN 9780641940484, 1968.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib71"><label>Schroeder et al.(2006)Schroeder, Martin, and
Lorensen</label><mixed-citation>
      
Schroeder, W., Martin, K., and Lorensen, B.: The Visualization Toolkit, 4th
Edn., Kitware, ISBN 978-1-930934-19-1, 2006.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib72"><label>Skrodzki(2019)</label><mixed-citation>
      
Skrodzki, M.: The k-d tree data structure and a proof for neighborhood
computation in expected logarithmic time, arXiv [preprint],
<a href="https://doi.org/10.48550/arXiv.1903.04936" target="_blank">https://doi.org/10.48550/arXiv.1903.04936</a>, 2019.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib73"><label>Smilauer et al.(2015)Smilauer, Catalano, Chareyre, Dorofeenko,
Duriez, Dyck, Elias, Er, Eulitz, Gladky, Guo, Jakob, Kneib, Kozicki,
Marzougui, Maurin, Modenese, Scholtes, Sibille, Stransky, Sweijen, Thoeni,
and Yuan</label><mixed-citation>
      
Smilauer, V., Catalano, E., Chareyre, B., Dorofeenko, S., Duriez, J., Dyck, N.,
Elias, J., Er, B., Eulitz, A., Gladky, A., Guo, N., Jakob, C., Kneib, F.,
Kozicki, J., Marzougui, D., Maurin, R., Modenese, C., Scholtes, L., Sibille,
L., Stransky, J., Sweijen, T., Thoeni, K., and Yuan, C.: Yade Documentation
2nd ed, Zenodo, <a href="https://doi.org/10.5281/zenodo.34073" target="_blank">https://doi.org/10.5281/zenodo.34073</a>, 2015.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib74"><label>Syamlal et al.(1993)Syamlal, Rogers, and O'Brien</label><mixed-citation>
      
Syamlal, M., Rogers, W., and O'Brien, T. J.: MFIX documentation theory guide,
Office of Scientific and Technical Information (OSTI),
<a href="https://doi.org/10.2172/10145548" target="_blank">https://doi.org/10.2172/10145548</a>, 1993.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib75"><label>Tong et al.(2022)Tong, Zhai, Li, Zhang, and
Sheng</label><mixed-citation>
      
Tong, C.-X., Zhai, M.-Y., Li, H.-C., Zhang, S., and Sheng, D.: Particle
breakage of granular soils: changing critical state line and constitutive
modelling, Acta Geotech., 17, 755–768, <a href="https://doi.org/10.1007/s11440-021-01231-8" target="_blank">https://doi.org/10.1007/s11440-021-01231-8</a>,
2022.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib76"><label>Tripathi and Khakhar(2013)</label><mixed-citation>
      
Tripathi, A. and Khakhar, D. V.: Density difference-driven segregation in a
dense granular flow, J. Fluid Mech., 717, 643–669,
<a href="https://doi.org/10.1017/jfm.2012.585" target="_blank">https://doi.org/10.1017/jfm.2012.585</a>, 2013.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib77"><label>Tsuji et al.(1993)Tsuji, Tanaka, and Ishida</label><mixed-citation>
      
Tsuji, Y., Tanaka, T., and Ishida, T.: Lagrangian numerical simulation of plug
flow of cohesionless particles in a horizontal pipe, Powder Technol., 77,
79–87, <a href="https://doi.org/10.1016/0032-5910(92)88030-L" target="_blank">https://doi.org/10.1016/0032-5910(92)88030-L</a>, 1993.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib78"><label>Tunuguntla et al.(2014)Tunuguntla, Bokhove, and
Thornton</label><mixed-citation>
      
Tunuguntla, D., Bokhove, O., and Thornton, A. R.: A mixture theory for size and
density segregation in shallow granular free-surface flows, J. Fluid
Mech., 749, 99–112, <a href="https://doi.org/10.1017/jfm.2014.223" target="_blank">https://doi.org/10.1017/jfm.2014.223</a>, 2014.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib79"><label>Tunuguntla et al.(2017)Tunuguntla, Weinhart, and
Thornton</label><mixed-citation>
      
Tunuguntla, D. R., Weinhart, T., and Thornton, A. R.: Comparing and contrasting
size-based particle segregation models, Comput. Particle Mech., 4,
387–405, <a href="https://doi.org/10.1007/s40571-016-0136-1" target="_blank">https://doi.org/10.1007/s40571-016-0136-1</a>, 2017.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib80"><label>Virtanen et al.(2020)Virtanen, Gommers, Oliphant, Haberland, Reddy,
Cournapeau, Burovski, Peterson, Weckesser, Bright, van der Walt, Brett,
Wilson, Millman, Mayorov, Nelson, Jones, Kern, Larson, Carey, Polat, Feng,
Moore, VanderPlas, Laxalde, Perktold, Cimrman, Henriksen, Quintero, Harris,
Archibald, Ribeiro, Pedregosa, van Mulbregt, and SciPy 1.0
Contributors</label><mixed-citation>
      
Virtanen, P., Gommers, R., Oliphant, T. E., Haberland, M., Reddy, T.,
Cournapeau, D., Burovski, E., Peterson, P., Weckesser, W., Bright, J., van
der Walt, S. J., Brett, M., Wilson, J., Millman, K. J., Mayorov, N., Nelson,
A. R. J., Jones, E., Kern, R., Larson, E., Carey, C. J., Polat, İ., Feng,
Y., Moore, E. W., VanderPlas, J., Laxalde, D., Perktold, J., Cimrman, R.,
Henriksen, I., Quintero, E. A., Harris, C. R., Archibald, A. M., Ribeiro,
A. H., Pedregosa, F., van Mulbregt, P., and SciPy 1.0 Contributors:
SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python,
Nat. Meth., 17, 261–272, <a href="https://doi.org/10.1038/s41592-019-0686-2" target="_blank">https://doi.org/10.1038/s41592-019-0686-2</a>, 2020.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib81"><label>Walton(1980)</label><mixed-citation>
      
Walton, O. R.: Particle-Dynamics Modeling of Geological Materials, Ph.d. dissertation, University of California, Davis, ISBN 979-8-204-17112-1, <a href="https://www.proquest.com/dissertations-theses/particle-dynamics-modeling-geological-materials/docview/303008003" target="_blank"/> (last access: 1 October 2026), 1980.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib82"><label>Walton and Braun(1986)</label><mixed-citation>
      
Walton, O. R. and Braun, R. L.: Viscosity, granular‐temperature, and stress
calculations for shearing assemblies of inelastic, frictional disks, J.
Rheol., 30, 949–980, <a href="https://doi.org/10.1122/1.549893" target="_blank">https://doi.org/10.1122/1.549893</a>, 1986.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib83"><label>Weinhart et al.(2012)Weinhart, Thornton, Luding, and
Bokhove</label><mixed-citation>
      
Weinhart, T., Thornton, A. R., Luding, S., and Bokhove, O.: From discrete
particles to continuum fields near a boundary, Granular Matter, 14, 289–294,
<a href="https://doi.org/10.1007/s10035-012-0317-4" target="_blank">https://doi.org/10.1007/s10035-012-0317-4</a>, 2012.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib84"><label>Weinhart et al.(2013)Weinhart, Hartkamp, Thornton, and
Luding</label><mixed-citation>
      
Weinhart, T., Hartkamp, R., Thornton, A. R., and Luding, S.: Coarse-grained
local and objective continuum description of three-dimensional granular flows
down an inclined surface, Phys. Fluids, 25, 070605,
<a href="https://doi.org/10.1063/1.4812809" target="_blank">https://doi.org/10.1063/1.4812809</a>, 2013.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib85"><label>Weinhart et al.(2016)Weinhart, Labra, Luding, and
Ooi</label><mixed-citation>
      
Weinhart, T., Labra, C., Luding, S., and Ooi, J. Y.: Influence of
coarse-graining parameters on the analysis of DEM simulations of silo flow,
Powder Technol., 293, 138–148, <a href="https://doi.org/10.1016/j.powtec.2015.11.052" target="_blank">https://doi.org/10.1016/j.powtec.2015.11.052</a>, 2016.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib86"><label>Weinhart et al.(2020a)Weinhart, Orefice, Post, van
Schrojenstein Lantman, Denissen, Tunuguntla, Tsang, Cheng, Shaheen, Shi,
Rapino, Grannonio, Losacco, Barbosa, Jing, Alvarez Naranjo, Roy, den
Otter, and Thornton</label><mixed-citation>
      
Weinhart, T., Orefice, L., Post, M., van Schrojenstein Lantman, M. P.,
Denissen, I. F., Tunuguntla, D. R., Tsang, J., Cheng, H., Shaheen, M. Y.,
Shi, H., Rapino, P., Grannonio, E., Losacco, N., Barbosa, J., Jing, L.,
Alvarez Naranjo, J. E., Roy, S., den Otter, W. K., and Thornton, A. R.:
Fast, flexible particle simulations – An introduction to MercuryDPM,
Comput. Phys. Commun., 249, 107129,
<a href="https://doi.org/10.1016/j.cpc.2019.107129" target="_blank">https://doi.org/10.1016/j.cpc.2019.107129</a>, 2020a.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib87"><label>Weinhart et al.(2020b)Weinhart, Orefice, Post, van
Schrojenstein Lantman, Denissen, Tunuguntla, Tsang, Cheng, Shaheen, Shi,
Rapino, Grannonio, Losacco, Barbosa, Jing, Alvarez Naranjo, Roy, den
Otter, and Thornton</label><mixed-citation>
      
Weinhart, T., Orefice, L., Post, M., van Schrojenstein Lantman, M. P.,
Denissen, I. F., Tunuguntla, D. R., Tsang, J., Cheng, H., Shaheen, M. Y.,
Shi, H., Rapino, P., Grannonio, E., Losacco, N., Barbosa, J., Jing, L.,
Alvarez Naranjo, J. E., Roy, S., den Otter, W. K., and Thornton, A. R.:
Fast, flexible particle simulations – An introduction to MercuryDPM,
Comput. Phys. Commun., 249, 107129,
<a href="https://doi.org/10.1016/j.cpc.2019.107129" target="_blank">https://doi.org/10.1016/j.cpc.2019.107129</a>, 2020b.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib88"><label>Windows-Yule et al.(2019)Windows-Yule, Mühlbauer, Cisneros, Nair,
Marzulli, and Pöschel</label><mixed-citation>
      
Windows-Yule, C. R. K., Mühlbauer, S., Cisneros, L. A. T., Nair, P.,
Marzulli, V., and Pöschel, T.: Janssen effect in dynamic particulate
systems, Phys. Rev. E, 100, 022902, <a href="https://doi.org/10.1103/PhysRevE.100.022902" target="_blank">https://doi.org/10.1103/PhysRevE.100.022902</a>,
2019.


    </mixed-citation></ref-html>
<ref-html id="bib1.bib89"><label>Zhang and Kamrin(2017)</label><mixed-citation>
      
Zhang, Q. and Kamrin, K.: Microscopic Description of the Granular Fluidity
Field in Nonlocal Flow Modeling, Phys. Rev. Lett., 118, 058001,
<a href="https://doi.org/10.1103/PhysRevLett.118.058001" target="_blank">https://doi.org/10.1103/PhysRevLett.118.058001</a>, 2017.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib90"><label>Zhang and Campbell(1992)</label><mixed-citation>
      
Zhang, Y. and Campbell, C. S.: The interface between fluid-like and solid-like
behaviour in two-dimensional granular flows, J. Fluid Mech., 237,
541–568, <a href="https://doi.org/10.1017/S0022112092003525" target="_blank">https://doi.org/10.1017/S0022112092003525</a>, 1992.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib91"><label>Zrelak et al.(2024)Zrelak, Breard, and
Dufek</label><mixed-citation>
      
Zrelak, P., Breard, E. C. P., and Dufek, J.: Basal Force Fluctuations and
Granular Rheology: Linking Macroscopic Descriptions of Granular Flows to Bed
Forces With Implications for Monitoring Signals, J. Geophys.
Res.-Earth, 129, e2024JF007760, <a href="https://doi.org/10.1029/2024JF007760" target="_blank">https://doi.org/10.1029/2024JF007760</a>,
2024.

    </mixed-citation></ref-html>
<ref-html id="bib1.bib92"><label>Zrelak et al.(2026)Zrelak, Breard, and Dufek</label><mixed-citation>
      
Zrelak, P., Breard, E. C. P., and Dufek, J.: The Role of Basal Roughness and
Assemblage Grain-Size Distribution in Shaping Granular Rheology and
Basal-Force Signals, J. Geophys. Res.-Earth, 131,
e2025JF008538, <a href="https://doi.org/10.1029/2025JF008538" target="_blank">https://doi.org/10.1029/2025JF008538</a>, 2026.

    </mixed-citation></ref-html>--></article>
