Simulation framework for coherent and incoherent X-ray imaging and its application in Talbot-Lau dark-field imaging

A simulation framework for coherent X-ray imaging, based on scalar diffraction theory, is presented. It contains a core C++ library and an additional Python interface. A workflow is presented to include contributions of inelastic scattering obtained with Monte-Carlo methods. X-ray Talbot-Lau interferometry is the primary focus of the framework. Simulations are in agreement with measurements obtained with such an interferometer. Especially, the dark-field signal of densely packed PMMA microspheres is predicted. A realistic modeling of the microsphere distribution, which is necessary for correct results, is presented. The framework can be used for both setup design and optimization but also to test and improve reconstruction methods. © 2014 Optical Society of America OCIS codes: (070.6760) Talbot and self-imaging effects; (070.7345) Wave propagation; (110.7440) X-ray imaging; (110.3175) Interferometric imaging; (340.7450) X-ray interferometry. References and links 1. F. Pfeiffer, T. Weitkamp, O. Bunk, and C. David, “Phase retrieval and differential phase-contrast imaging with low-brilliance X-ray sources,” Nature (London) Phys. 2(4), 258–261 (2006). 2. T. Weitkamp, A. Diaz, C. David, F. Pfeiffer, and M. Stampanoni, “X-ray phase imaging with a grating interferometer,” Opt. Express 13(16), 6296-6304 (2005). 3. D. M. Paganin, Coherent X-Ray optics (Oxford University, 2006). 4. A. Momose, “Phase-sensitive imaging and phase tomography using X-ray interferometers,” Opt. Express 11(19), 2303–2314 (2003). 5. K. Matsushima and T. Shimobaba, “Band-limited angular spectrum method for numerical simulation of freespace propagation in far and near fields,” Opt. Express 17(22), 19662–19673 (2009). 6. G. Van Rossum and F. L. J. Drake, The Python Language Reference Manual (Network Theory, 2011). 7. C++, ISO/IEC 14882:2011. 8. M. Frigo and S. G. Johnson, “The design and implementation of FFTW3,” Proc. IEEE 93(2), 216–231 (2005). 9. Boost C++ Libraries, http://www.boost.org . 10. C. T. Chantler, “Theoretical form factor, attenuation and scattering tabulation for Z=1-92 from E=1-10 eV to E=0.4-1.0 MeV,” J. Phys. Chem. Ref. Data 24, 71–642 (1995). #214005 $15.00 USD Received 13 Jun 2014; revised 4 Aug 2014; accepted 7 Aug 2014; published 16 Sep 2014 (C) 2014 OSA 22 September 2014 | Vol. 22, No. 19 | DOI:10.1364/OE.22.023276 | OPTICS EXPRESS 23276 11. S. Agostinelli, J. Allison, K. Amako, J. Apostolakis, H. Araujo, P. Arce, M. Asai, D. Axen, S. Banerjee, G. Barrand, F. Behner, L. Bellagamba, J. Boudreau, L. Broglia, A. Brunengo, H. Burkhardt, S. Chauvie, J. Chuma, R. Chytracek, G. Cooperman, G. Cosmo, P. Degtyarenko, A. Dell’Acqua, G. Depaola, D. Dietrich, R. Enami, A. Feliciello, C. Ferguson, H. Fesefeldt, G. Folger, F. Foppiano, A. Forti, S. Garelli, S. Giani, R. Giannitrapani, D. Gibin, J.J. Gómez Cadenas, I. González, G. Gracia Abril, G. Greeniaus, W. Greiner, V. Grichine, A. Grossheim, S. Guatelli, P. Gumplinger, R. Hamatsu, K. Hashimoto, H. Hasui, A. Heikkinen, A. Howard, V. Ivanchenko, A. Johnson, F.W. Jones, J. Kallenbach, N. Kanaya, M. Kawabata, Y. Kawabata, M. Kawaguti, S. Kelner, P. Kent, A. Kimura, T. Kodama, R. Kokoulin, M. Kossov, H. Kurashige, E. Lamanna, T. Lampén, V. Lara, V. Lefebure, F. Lei, M. Liendl, W. Lockman, F. Longo, S. Magni, M. Maire, E. Medernach, K. Minamimoto, P. Mora de Freitas, Y. Morita, K. Murakami, M. Nagamatu, R. Nartallo, P. Nieminen, T. Nishimura, K. Ohtsubo, M. Okamura, S. O’Neale, Y. Oohata, K. Paech, J. Perl, A. Pfeiffer, M.G. Pia, F. Ranjard, A. Rybin, S. Sadilov, E. Di Salvo, G. Santin, T. Sasaki, N. Savvas, Y. Sawada, S. Scherer, S. Sei, V. Sirotenko, D. Smith, N. Starkov, H. Stoecker, J. Sulkimo, M. Takahata, S. Tanaka, E. Tcherniaev, E. Safai Tehrani, M. Tropeano, P. Truscott, H. Uno, L. Urban, P. Urban, M. Verderi, A. Walkden, W. Wander, H. Weber, J.P. Wellisch, T. Wenaus, D.C. Williams, D. Wright, T. Yamada, H. Yoshida, D. Zschiesche, Geant4 Collaboration, “Geant4—a simulation toolkit,” Nucl. Instr. Meth. Phys. Res. A 506(3), 250 – 303 (2003). 12. A. Malecki, G. Potdevin, and F. Pfeiffer, “Quantitative wave-optical numerical analysis of the dark-field signal in grating-based X-ray interferometry,” EPL 99(4), 48001 (2012). 13. F. Dullien and H. Brenner, Porous media: Fluid Transport and Pore Structure, 2nd Edition (Academic, 1992). 14. M. Bargieł and J. Mościński, “C-language program for the irregular close packing of hard spheres,” Comput. Phys. Commun. 64, 183–192 (1991).


Introduction
X-ray Talbot-Lau interferometry [1,2] has gained increasing interest in the recent years.In the strive for optimized setups and in the search and evaluation for possible applications in X-ray Talbot-Lau interferometry, simulations are of great value.In this work we present a simulation framework, which was primarily developed for X-ray Talbot-Lau interferometry.The framework is based on classical scalar diffraction theory [3] and thus should also in general be suited for coherent X-ray imaging methods [3,4].While scalar diffraction theory is suited for the predication of diffraction effects it lacks support for predicting intensity distributions generated by inelastic scattering due to quantum mechanical processes, for example Compton scattering or X-ray fluorescence.Nevertheless, these processes can play an important role in coherent Xray imaging methods and therefore, depending on the problem at hand, might not be neglected.To solve this issue, we developed interface components in our framework and a workflow to incorporate the contributions of inelastic scattering obtained by Monte-Carlo methods.
In the first part of this work we present the basics of discrete scalar diffraction theory used within the framework.Additionally, we motivate and present our approach to combine the coherent wave-field simulation with the inelastic contributions from Monte-Carlo methods.In the second part we present details on design and implementation of the framework.
It is important to test that simulation results for intended applications are valid.If the simulation has shown to predict true values for certain sets of parameters in different use cases, it is more likely that the simulation will also predict true values for different sets of parameters.In X-ray Talbot-Lau interferometry setups have not been fully optimized yet.Here, a validated simulation is a valuable tool for setup design and optimization for different applications of Xray Talbot-Lau interferometry.Additionally, test data and look up tables can be created with the simulation to improve image reconstruction.Therefore, in the last part of this work, we show comparisons of results obtained by measurements and equivalent simulations.This is done for the intended primary application X-ray Talbot-Lau interferometry and especially the dark-field signal generated by sub resolution structures.

Physics in the simulation
In the following we give a short introduction on scalar diffraction theory as it is used in the simulation framework.Further, we will describe the concept of combining coherent and inealastic contributions gained from wave-field simulations and Monte-Carlo simulations.

Scalar diffraction theory in the simulation
Figure 1 shows a typical imaging setup with X-Ray Talbot-Lau interferometry.Assuming all matter present within this setup has an isotropic refractive index we can describe the physics of coherent X-ray propagation within this setup by the so-called scalar diffraction theory [3].Accordingly, electromagnetic wave fields are represented by time-dependent complex scalar fields Ψ(r) which can be decomposed into spectral components ψ ω (r), which have to obey the Helmholtz equation where k is the wave number, ω is the angular frequency with ω = ck and c is the speed of light.The vector r comprises the euclidean coordinates (x, y, z).The frequency dependent refractive index n ω (r) describes the optical property of matter and is equal to one in vacuum.Due to the relation between photon energy E and angular frequency E = hω it is possible to replace the frequency ω by E in the notation.Meaning that ψ E (r) is the monochromatic spectral component ψ ω (r,t) with the angular frequency ω = E/h.In the following we will drop the index E, assuming implicitly that ψ(r) is only one spectral component of the system.Additionally, we use the operator theory of imaging [3].In this theory an imaging system can be cascaded into several subsystems.Each subsystem has an input plane where a forward propagating wave field ψ in (u) enters the sub-system.The wave field on the output plane is gained by applying an operator O, which describes the action of the imaging system on the entry wave field.The euclidean coordinates u = (x, y) mark a point on such an input respectively output plane.The euclidean coordinate z describes the coordinate along the optical axis, i.e. each plane has a different z position.The output of one subsystem then serves as input for the next subsystem in the propagation order.Furthermore, we assume that each monochromatic component can be propagated independently through the imaging system.Finally, the intensity of each propagated monochromatic component can be summed up to obtain the total intensity of the propagated wave field.In the case that the energy response of a detector has to be taken into account, the intensity of each spectral component is used as input for the simulation of the detector.
In the example of the Talbot-Lau setup in Fig. 1, a typical operation would be the propagation of the wave-field through free space from diffraction grating G1 to analyzer grating G2.For this we use the angular spectrum method [3], especially the numerical implementation of the bandlimited angular spectrum method [5].With the angular spectrum method the wave field after propagating a distance ∆z through free space is given by with F and F −1 denoting the Fourier transform and its inverse and k x and k y being the angular components of the wave-field.
An object in a setup, for example a grating, is handled in the projection approximation [3].The wave field on the exit plane of an object is thus given by with z 0 and z 0 + ∆z being the position of the entry and exit planes.The refractivity and the absorption of the object are described by δ and β , which both are part of the complex refractive index n E (r) = 1 − δ E (r) + iβ E (r). ( Projection approximation will only work for sufficiently thin objects.A solution for thick objects might be the use of a multi-slice method [3].In this method a thick object is divided into several slices.Each slice then combines the projection approximation and free space propagation to propagate the wave field to the next slice.

Combination of coherent and inelastic contributions
In coherent X-ray imaging, inelastic scattering (see chapter 2.10 of [3]), for example Compton scattering and photoelectric absorption and fluorescence, plays an important role.Depending on the amount of matter between source and detector, the X-ray spectrum and the effort that is taken to suppress large angle scattering contributions, inelastic scattering may considerably contribute to the detectable intensity at the detector.Inelastic scattering can have an impact on the image obtained with coherent X-ray imaging methods.Thus, a simulation framework for coherent X-ray imaging should be able to include effects of inelastic scattering.Both elastic and inelastic processes within matter contribute to refractivity and absorption.This is expressed by the complex refractive index, which is used within the wave-field simulation.There is no way to calculate the intensity distribution of the inelastically scattered photons within the wave-field simulation as the underlying processes are quantum mechanical in nature and the wave-field simulation is based on a classical theory of electronmagnetism.Thus, within the wave-field simulation the intensity distribution of inelastically scattered photons is not existent and no longer contributes to the total intensity at the detector.Furthermore, inelastically scattered photons can be regarded as being incoherent to the primary wave field  and thus only the intensities and not the amplitudes of the inelastically scattered photons and the coherent contribution can be summed.Monte-Carlo simulations can be used to determine the inelastically scattered photons, and therefore the inelastic contribution.On the other hand, Monte-Carlo simulations are not able to predict diffractive effects.By using both a wave-field simulation to compute the coherent contribution and a Monte-Carlo simulation to compute the inelastic contribution it is possible to get a combined simulation result which is more realistic than that of each single simulation on its own.Figure 2 shows the scheme of the simulation flow model for combining coherent and inelastic contributions to the intensity I(x, y) at the surface of a detector.The chosen input parameters for a simulation are used for both, a Monte-Carlo simulation and a wave-field simulation.These simulations are then executed in parallel.Afterwards all photons that are scattered by an inelastic process in the Monte-Carlo simulation are selected and can be regarded as the inelastic contribution.The wave-field simulation in turn provides intensities of the coherent contributions to the photon field.
There are two possibilities to combine these contributions.On the one hand, the intensities provided by the wave-field simulation can be reinterpreted as probability density functions for the coherently scattered photons.With a random generator a list of coherently scattered photon events is obtained, which can be added to the list of inelastically scattered events.
On the other hand, the list of inelastically scattered photons can be used to create an intensity of these inelastic contributions which can then be combined with the intensity of the coherent contributions.For this, a sufficiently high number of photon events has to be simulated to obtain expectation values of the intensity with sufficient precision.
Both, the combined intensity and the combined photon event list can serve as input to a subse- quent detector simulation.The detector simulation, together with a detector response function, can then give the detector response to the impinging photon field either with or without photon noise.Depending on the level of detail of the detector simulation it is also possible to include noise of the detector.

Implementation of the simulation framework
The framework consists of a core framework library libcxi.The functionality of the core framework library is exported into the Python [6] extension package cxi.The Python extension itself is used by the Python package cxi which provides further functionality and a simplified programming interface for common tasks.The framework design is explained in more detail in the following subsections.Figure 3 gives a visualized overview of the framework components.

Core framework library libcxi
The core framework library libcxi is implemented in C++ [7] and depends on the FFTW [8] and the Boost C++ libraries [9].The core framework library includes a dynamically managed two-dimensional array of complex values.This array is intended to sample a complex scalar wave field on a two-dimensional plain rectangular surface in three dimensional space.The wave field given on such a surface can then be propagated through a coherent X-ray imaging setup according to the operator theory of imaging.Free space propagation is provided by the angular spectrum formalism or Fresnel diffraction (see section 2.1).Iterators to rectangular slices of the array provide access to the sampled wave field values and their coordinates on the surface.Map and reduce operations in conjunction with a collection of functions of the sampled value and its coordinates allow a simple manipulation of the sampled surface.This includes the creation of incident waves, apertures or zero padding and allows the calculation of the total intensity over a given rectangular region.Additionally, functions to calculate the transmission through thin objects in projection approximation are provided.These include geometric objects like spheres, ellipsoids and polygons, but also simple grating structures are provided.
Further, the included geometry package allows to define more intricate hierarchic geometric structures.Algorithms to calculate the transmission of such structures in projection approximation are supplied.These algorithms can be combined with free space propagation to create multi-slice algorithms that propagate wave fields through more extensive objects.
The spatial distribution of the complex refractive index, consisting of a refractive index decrement and an extinction coefficient, is required to calculate the wave propagation through an object slice.The complex refractive index depends on the photon energy but also on the material composition.Therefore, the library has built-in access to a library of pre-calculated complex refractive index tables for a variety of materials.These tables can be calculated with methods and data given in [10], provided that the elemental mass ratios and the density of the material are known.
The simulated wave fields are monochromatic.To gain polychromatic simulations the spectral power density of the source can be discretized.For each discrete energy the monochromatic propagation is calculated using the appropriate photon energy or wavelength.The resulting monochromatic intensities are then weighted by the spectral power and summed.
The coherent simulation is supplemented by a Monte-Carlo simulation, the framework provides algorithms that create photon events based on the intensities calculated with the coherent simulation.For this, random generators and distributions of the boost random library are included into the core framework library.These distributions can also be used for modeling random variations in setup parameters when needed.
The core framework library can be used to build native simulation applications.Native applications have to be recompiled when changes are made to the application code.Additionally, the simulation results have to be exported when needed.

Python bindings and module
Using the boost Python library most of the classes and functions of the core framework library libcxi are exported into the Python extension cxi.This Python extension module provides no additional functionality.The extension module is used as a base for the Python package cxi which eases the use of the core framework library programming interface.It provides algorithms for common tasks when building simulations for coherent X-ray imaging.Besides these additions, results of the wave field simulations can easily be used for further analysis with existing Python packages for numeric and scientific calculations and visualization.Thus, simulations can be built and modified in a more convenient way than it is possible with native applications.Nonetheless, the simulations stay efficient as the computationally demanding parts are still in native code.

Dark-field simulations for an X-ray Talbot-Lau interferometry setup
Talbot-Lau interferometry has gained increasing interest for X-ray imaging in recent years.Especially dark-field imaging offers interesting information due to the fact that it is sensitive to structures in an object which are smaller than the pixel size defined by the imaging detector.We therefore consider the dark-field signatures in a Talbot-Lau setup in our simulation and compare it with measurements.
The Talbot-Lau setup consists of the following components which are listed in the order beginning at the X-ray source and ending at the X-ray detector, see Fig. 1.The X-ray tube has a tungsten anode and is operated at 40 kV acceleration voltage.A source grating G0 is placed at a distance of 140 mm to the tube focus.G0 has a period of 24.39 µm and has gold bars with a height of 150 µm.The distance between G0 and the object position is 1495 mm.The distance from the object position to the diffraction grating G1 is 235 mm.In sum the distance between G0 and G1 is 1730 mm.G1 has a period of 4.37 µm and has nickel bars with a height of 8.7 µm.
G1 is designed to be π-shifting for a design energy of 25 keV.The distance between G1 and the analyzer grating G2 is 170 mm.G2 has a period of 2.4 µm and has gold bars with a height of 110 µm.The distance between G2 and the detector is 430 mm.All three gratings have a duty cycle of 0.5.The detector has a caesium-iodine scintillator with 600 µm thickness and a pixel pitch of 127 µm.The given parameters and components fully describe both the experimental apparatus as well as the setup within the simulation.If not stated otherwise, the given parameters are used for all comparisons shown in the rest of this section and these parameters are always equal in simulation and measurement for each comparison.Due to the Talbot effect the grating G1 induces a periodic intensity pattern in the plane of G2.G2 is mounted on a piezo stepper for the so-called phase-stepping [2] procedure: by taking images at different x-positions of G2 the obtained intensity as a function of the position results in a sampling of the periodic intensity pattern for each pixel of the detector.From these data for each pixel i of the detector the visibility V i is calculated by the quotient of the amplitude a i of the first order harmonics of the phase-stepping curve and the mean value m i of the phase-stepping curve.Both amplitude a i and mean value m i are obtained by a discrete Fourier transform of the phase-stepping curve for each pixel i.The object visibility V i and the reference visibility V ref,i are obtained by equivalent measurements with and without object.This yields the dark-field The simulation considers one detector pixel centered around the optical axis of the setup.No distance between G2 grating and detector pixel is assumed, which results in an effective pixel width of 105 µm.The area of the sampled two dimensional wave field in the simulation exceeds that of the pixel by a margin of 20 µm in each dimension.Additionally, the sample area is doubled in both dimensions and zero padding is done to avoid aliasing when using the band limited angular spectrum formalism [5] for free space propagation.The sampling distance for both dimensions is 0.2 µm.
The wave-field array is initialized directly in front of the object position with a monochromatic spherical wave which is emitted at the tube focus position.Then the transmission through the object is calculated with projection approximation.This is followed by a free space propagation to the G1 position.The transmission of G1 is again calculated with projection approximation and followed by another free space propagation to the position of G2.The squared modulus of the complex wave field amplitude is calculated to obtain the intensity of the wave field.The normalized spatial power density of the tube source and the intensity transmission function of the source grating G0 are projected over G1 onto the G2 plane.The product of both projected functions provides a blurring function which is convolved with the intensity field.
In the last step the intensity field is transmitted by G2 using the projection approximation and the total intensity in the pixel area is summed up.This last step is performed for different lateral positions of the G2 grating, which yields a monochromatic phase-stepping curve.The spectral power density of the tube source, which was measured or simulated, and the transmission of the silicon grating wavers as well as the detection probability of the CsI scintilator is taken into account by a numerical computation.This gives a discrete spectral power density, which is taken to gain a polychromatic phase-stepping curve by a weighted sum of monochromatic simulated phase-stepping curves for a given object realization.The visibility V is gained by the quotient of the amplitude a and the mean m of the polychromatic phase-stepping curve.Both values are obtained by a discrete Fourier transform.

Comparison of simulation and measurement
For a first validation of the simulation we vary parameters of the Talbot-Lau setup and compare simulation and measurement of the visibility.Figure 4(a) shows the visibility as function of the acceleration voltage of the X-ray tube, Fig. 4(b) shows the visibility as function of the distance between the gratings G1 and G2.We can see agreement between simulation and measurement within the uncertainties of the measurement.
For a further test, a homogeneous cube of PMMA with dimensions 30 × 30 × 5.35cm 3 is positioned in front of G1.The parameters for this test are slightly different to the setup introduced in the beginning of section 4. The distance between source and G0 is 164 mm, between G0 and sample 370 mm, between sample and G1 242 mm, between G1 and G2 158.6 mm and between G2 and detector 114.4 mm.All three gratings G0, G1 and G2 have gold bars with bar heights of 150 µm, 4.37 µm and 70 µm.The grating periods are the same.The simulation is performed in two ways.Firstly, only the coherent wave propagation is taken into account resulting in the dark-field value of 0.83.Secondly, the inelastic contribution is considered in addition resulting in the dark-field value of 0.77.The inelastic contribution is obtained by a Monte-Carlo simulation with the Geant4 [11] toolkit using the Penelope low energy physics list.The measurement shows a dark-field value of 0.73.Differences between the absolute dark-field values of simulation and measurement can most likely be explained by details of the measurement setup, which are not implemented in the simulation.These details might further reduce the dark-field value seen in the measurement compared to the simulation through inelastic scattering.Additionally, simulation runs with a measured and a simulated X-ray tube spectrum show relative changes of up to 3% of the resulting dark-field value incorporating inelastic scattering.In conclusion, by comparing the two results with the measurement we see, that inelastic scattering is not negligible for thick objects.

Simulation of an object containing microspheres
As a next step a more complicated object is investigated.The object consists of a cubic volume containing microspheres of varying packing density, i.e. relative volume filled by the spheres.The cuboid has a thickness t in beam direction.For each set of these parameters -i.e.thickness and packing density -the dark-field is calculated repeatedly to obtain an averaged dark-field D(t) depending on the thickness t.   6. Dark-field values of 250, 500 and 1000 calcium spheres placed in a cuboid with different sphere diameters.The original design of this simulation can be found in [12] with the results in Fig. 3 of the cited article.The data presented in the figure here is obtained with the simulation framework cxi.The simulation was done once with the assumption that the packing density is sufficiently low to ignore sphere overlap.For this a distribution method is used, which creates distributions of spheres which are comparable to the ones found in [12].Additionally the simulation was also repeated with a high packing density of 0.5 and with a relaxation method which is additionally used in our work, which minimizes the overlap between spheres.See the text for a detailed explanation of the different used distribution methods.The centers of the spheres are randomly distributed in the object volume according to a uniform 3-dimensional probability density.The number of spheres corresponds to a given packing density.It is important to note that in this model the distance between any two spheres can be as low as zero.Which means that their volumes may overlap, which is unrealistic by geometry.But the influence on the wave field is taken into account because overlapping volumes are projected multiple times in the projection-approximation algorithm.In Fig. 5(a) a cross section within the volume of such a generated distribution can be seen.One can see, that some spheres are overlapping.Accordingly, this simulation can only be realistic for objects with a very low packing density.
Malecki et al. [12] have published simulation results for calcium spheres distributed on a two-dimensional area, called layer.They calculated the expected dark-field for different sizes of spheres, number of spheres per layer and number of layers.They distributed relatively large numbers of spheres which overlapped on a layer.Effectively, a realization of such a sphere distribution may be possible by taking a sufficient thickness for a layer so that the overlapping of spheres could be avoided, which means that the packing density has to be low.This is nicely indicated Fig. 1 of [12], where the spheres in each layer seem to be placed with sufficiently low packing density to reduce the probability of overlapping.
We tried to repeat the simulation for which the original results can be found in Fig. 3 of [12] by placing the according number of spheres in our cuboid with a low packing density, i.e. using a relatively large cuboid thickness t.The result is shown in Fig. 6 and it agrees very well with the results of [12].If we simulate the same number of spheres in a cuboid with lower thickness, i.e. with higher packing density, we obtain different results.With higher packing density a more regular distribution of microsphere material is given in the volume.This leads to less reduction of the visibility, and thus a higher dark-field value, in the simulation compared to small packing densities.

Dark-field measurements with microspheres
In order to probe the validity of the simulation we performed a measurement with an object containing microspheres.The sample holder consists of a hollow right angled prism made of PMMA walls of 3 mm thickness, see Fig. 7.The hollow volume of the prism is filled by PMMA microspheres each having a diameter of 6.3 µm.The tangent of the prism angle is 5  80 .The shorter tangent of the right angled prism base is placed parallel to the optical axis of the setup.The longer tangent is placed perpendicular to the optical axis.The base and the axis of the prism is aligned to the detector edges.Thus, the thickness t of the object changes when moving along the pixel matrix in x-direction (for the coordinate system see Fig. 1).It is possible to obtain repeated measurements for the same thickness when moving along the y-direction of the pixel matrix.
This powder of microspheres has been poured into the hollow prism and the prism was shaken afterwards to let the spheres settle.According to [13] the packing density of the random close pack of mono-dispersed spheres should be between 0.56 and 0.64.An approximate measurement of mass and volume of the powder used in the measurement gives together with the known density of PMMA a packing density of about 0.53.Therefore, we assume that the real packing density lies between 0.53 and 0.64.
In Fig. 8(a) the results of the measurement compared to the simulation with the uniform random distribution method can be seen.The simulation has been repeated for packing densities between 0.1 and 0.6.From Fig. 8(a) it can be seen that the simulation would be in agreement with the measurement assuming a packing density between 0.2 and 0.3.This is contradictory to the measurement where a packing density between 0.53 and 0.64 is found.While most of the parameters in the simulation have been chosen in tight accordance to the measurement, the uniform random distribution of sphere centers does not reflect the fact that an overlap of the spheres is not possible in reality.This leads to the second method for generating sphere distributions described in the following subsection.

Simulation of a realistic distribution of densely-packed microspheres
To overcome the limitations of the uniform distribution method a method which iteratively minimizes the overlap between spheres has been implemented.The implementation is loosely based on ideas found in [14].The method starts with a realization of sphere centers according to the uniform distribution method.Each sphere is assumed to be in a potential caused by surrounding spheres.The potential of each sphere has a shape falling from one the center of the sphere with a cosine function to zero at the doubled radius of the sphere and above.In each iteration the spheres are selected one by one in random order.In its turn, each sphere center is then displaced by a fraction of the radius in the direction of the gradient of the potential.Thus, with each iteration the distribution of spheres relaxes into a state where overlap is minimized.An example of this process can be seen in Fig. 5.This figure shows cross sections of the volume of an initial sphere distribution and the distribution after a certain number of iterations.This method allows to generate densely packed irregular distributions of microspheres with minimized overlap.The so generated distribution is more realistic as overlap is minimized and overlap is not possible in the real sample of hardcore PMMA spheres.The relaxated sphere distribution can then be used to fully repeat the simulations that have been done before with spheres distributed according to a uniform probability distribution.
Figure 8(b) shows the results of the simulation with the relaxation method compared to the measurement.The simulation is repeated for packing densities between 0.1 and 0.6 again.This time it can be seen that the curve for the measurement lies between the simulated curves for packing densities of 0.5 and 0.6.This is in agreement with the expected packing density between 0.53 and 0.64 of the measurement.
In total, the results presented here show that a quantitative simulation of the dark-field signal is possible with the presented simulation framework.As a side result we have seen that the dark-field signal is very sensitive to how microstructures are distributed, as the results of the simulation are different for different distribution methods.

Conclusion and outlook
This work presents a simulation framework for coherent X-ray imaging with a focus on X-ray Talbot-Lau interferometry.The core framework library is implemented in C++, while Python bindings and a Python package provide the programming interface for users implementing simulations with the framework.This offers high computational performance and flexibility, yet retaining a convenient to use programming interface.
The framework allows to calculate the coherent contribution with a wave-field simulation based on classical scalar diffraction theory.It also provides methods to include inelastic contributions which cannot be obtained by the wave-field simulation.Instead, the inelastic contribution can be obtained by established Monte-Carlo methods.A workflow for combining the results with those from the wave-field simulations is presented.
In the last part of this work the performance of simulations based on the framework is compared to different experiments performed with an X-ray Talbot-Lau interferometer.The simulation is able to quantitatively predict the polychromatic visibility of the experimental setup as a function of acceleration voltage and the distance between diffraction grating and analyzer grating.In a further comparison an object, which is suited to generate a considerable amount of inelastic scattering, was placed in the setup.In this case, quantitative agreement of the predicted dark-field signal to the measured dark-field signal is improved if the presented workflow to incorporate inelastic contributions into the simulation result is used.Further comparisons show that the framework is able to quantitatively predict the dark-field signal originating from sparsely and densely packed microspheres.In order to achieve this result a realistic modeling of the distribution of densely packed spheres has been developed.Its validity has been proven by comparison to measurements.
Several points can be concluded from this comparison.First, as a side results, we see that the dark-field signal does not only depend on the shape and amount of volume filled by a microstructure, as has been shown by several works before, it also depends on how the single elements are distributed within the volume.Therefore, precise knowledge about microstructures including the distribution of its elements is important for a realistic simulation.The framework and the packing algorithm presented in this work allow a more realistic simulation of densely packed structures than it has been possible before.Second, our approach of combining coherent wave-field simulation and inelastic scattering improve the simulation result with regard to the measurement at least for X-ray Talbot-Lau interferometry.Third, and this was the primary purpose of this work, it could be shown that simulations based on the framework are able to predict quantitative values for X-ray Talbot-Lau interferometry.Thus, the validated framework allows to optimize and improve the setup design and reconstruction methods for X-ray Talbot-Lau interferometry.

Fig. 2 .
Fig. 2. Flow diagram of the simulation combining coherent contributions gained from a wave-field simulation and inelastic contributions gained from a Monte-Carlo simulation.

Fig. 3 .
Fig.3.The framework CXI with its three components.A C++ core framework library libcxi, which implements the computationally demanding parts of scalar diffraction theory.The Python extension module cxi exports the core library to a python namespace.The latter is imported by the Python module cxi which supplements it by a convenient programming interface.

Fig. 4 .
Fig. 4. Visibility as a function of the X-ray tube acceleration voltage (a) and as a function of the distance between the gratings G1 and G2 (b).

Fig. 5 .
Fig. 5. Cross sections of exemplary volumes filled with spheres as it was used for simulations.In the initial volume (a) sphere centers are distributed uniformly within the volume.The volumes (b), (c) and (d) show volumes after 20, 200 and 2000 iterations of a relaxation algorithm which minimized overlap between spheres.The packing density is 0.4.

Fig.
Fig.6.Dark-field values of 250, 500 and 1000 calcium spheres placed in a cuboid with different sphere diameters.The original design of this simulation can be found in[12]  with the results in Fig.3of the cited article.The data presented in the figure here is obtained with the simulation framework cxi.The simulation was done once with the assumption that the packing density is sufficiently low to ignore sphere overlap.For this a distribution method is used, which creates distributions of spheres which are comparable to the ones found in[12].Additionally the simulation was also repeated with a high packing density of 0.5 and with a relaxation method which is additionally used in our work, which minimizes the overlap between spheres.See the text for a detailed explanation of the different used distribution methods.

Fig. 7 .
Fig. 7. Photographic images of the sample used for the measurement.A prism is formed by PMMA walls and filled with a powder of PMMA microspheres with a diameter of 6.3 µm.The scale is in units of cm.(a) top view, (b) view along the beam axis.