CMInject: Python framework for the numerical simulation of nanoparticle injection pipelines
CCMInject : Python framework for the numerical simulationof nanoparticle injection pipelines
Simon Welker, Muhamed Amin,
1, 2, 3 and Jochen Küpper
1, 4, 5, ∗ Center for Free-Electron Laser Science, Deutsches Elektronen-Synchrotron DESY, Notkestraße 85, 22607 Hamburg, Germany Department of Sciences, University College Groningen, University of Groningen,Hoendiepskade 23/24, 9718 BG Groningen, Netherlands Groningen Biomolecular Sciences and Biotechnology Institute,University of Groningen, Nijenborgh 4, 9747 AG Groningen, Netherlands Center for Ultrafast Imaging, Universität Hamburg, Luruper Chaussee 149, 22761 Hamburg, Germany Department of Physics, Universität Hamburg, Luruper Chaussee 149, 22761 Hamburg, Germany (Dated: 2021-02-12)
CMInject simulates nanoparticle injection experiments of particles with diameters in the micrometerto nanometer-regime, e. g., for single-particle-imaging experiments. Particle-particle interactionsand particle-induced changes in the surrounding fields are disregarded, due to low nanoparticleconcentration in these experiments.
CMInject ’s focus lies on the correct modeling of different forceson such particles, such as fluid-dynamics or light-induced interactions, to allow for simulations thatfurther the scientific development of nanoparticle injection pipelines. To provide a usable basis forthis framework and allow for a variety of experiments to be simulated, we implemented first specificforce models: fluid drag forces, Brownian motion, and photophoretic forces. For verification, webenchmarked a drag-force-based simulation against a nanoparticle focusing experiment. We envisionits use and further development by experimentalists, theorists, and software developers.
Keywords:
Nanoparticles, Injection, Numerical simulation, Single-particle imaging, X-ray imaging,Framework
PROGRAM SUMMARY
Program Title:
CMInject
CPC Library link to program files: (to be added by Technical Editor)
Developer’s repository link: https://github.com/cfel-cmi/cminject
Code Ocean capsule: (to be added by Technical Editor)
Licensing provisions:
GPLv3
Programming language:
Python 3
Supplementary material:
Code to reproduce and analyze simulation results, example input and output data,video files of trajectory movies
Nature of problem:
Well-defined, reproducible, and interchangeable simulation setups of experimental injectionpipelines for biological and artificial nanoparticles, in particular such pipelines that aim to advance the fieldof single-particle imaging.
Solution method:
The definition and implementation of an extensible
Python 3 framework to model andexecute such simulation setups based on object-oriented software design, making use of parallelization facilitiesand modern numerical integration routines.
Additional comments including restrictions and unusual features:
Supplementary executable scripts forquantitative and visual analyses of result data are also part of the framework.
1. INTRODUCTION
Single-particle imaging (SPI) with x-ray beams is a rel-atively new technique [1, 2] for the imaging of small parti-cles down to the size of single macromolecules, promisingto image nanometer-sized particles without the need forcrystallization. In this context a “particle” can be anythingfrom a small molecule to an entire protein or an artificialnanoparticle. In SPI, a beam of x-rays illuminates singleparticles in flight, with each particle hit by the x-ray pulseproducing a diffraction pattern. From a collection of such ∗ patterns gathered from many identical particles, the par-ticle 3D structure can be approximated. Substantial ad-vances were made on the capabilities of x-ray free-electronlasers (XFELs) in recent years [3, 4], offering brilliant andcollimated ultra-short pulsed x-ray beams that can out-run radiation damage to the sample [1, 5] and allow fortime-resolved imaging on femtosecond timescales [6, 7].There are multiple factors to consider for collecting andreconstructing electron densities and molecular structureswith high resolution: Incident x-ray intensity, experimen-tal repetition rate, and particle density in the interactionregion. They all affect the quality of the reconstructedstructure: increasing the incident intensity results in moresignal in each diffraction pattern, and increasing the rep-etition rate or particle density results in more diffraction a r X i v : . [ phy s i c s . c o m p - ph ] F e b patterns being collected in the same timespan. It wassuggested that incident laser intensity is not the limitingfactor [8], which was corroborated by showing that thelevel of signal contained in collected patterns can be re-duced drastically while maintaining good reconstructionquality [9]. However, a large number of good hits, i. e.,diffraction patterns of single particles inside the focus ofthe x-ray pulse, need to be collected in any case. It waspreviously noted in the literature that “different injectionstrategies to extend XFEL imaging to smaller targets,such as single proteins” are needed [10], and that “im-provements could be made through optimized focusing forthe targeted size distribution or cryogenic injection sys-tems that additionally allow conformational selection” [11].Therefore, there is an urgent need for novel optimizedparticle injection systems.To recover the 3D structure of the imaged particlesfrom their 2D diffraction patterns, sophisticated computeralgorithms are used [9, 11–13]. These algorithms usediffraction patterns from structurally identical particles.Thus, it is important to understand how the variation inparticles’ sizes/shapes and structural conformations willaffect their trajectories in the injection system. Thesetrajectories are also dependent on several experimentalparameters, e. g., the geometry of the injection system,the temperature and pressure of the guiding aerosols,and the initial phase space distribution of the injectedparticles [14, 15]. Accordingly, selecting specific particlespecies, e. g., through the use of inhomogeneous electricfields [16], are an advanced topic for creating a high-quality particle beam.A simulation framework provides a quick and efficienttool for searching the experimental parameters’ space andto produce optimized molecular/nanoparticle beams. Fur-thermore, the feedback loop between simulation and ex-periment offers a road to progress in both theoretical andexperimental physics. Simulations are repeatedly used asa basis, supplementary, guiding, or verification method inSPI research. Examples for this are (1) optimization ofexperimentally verified aerodynamical injector designs fora variety of specific particle sizes and materials [15, 17–21], (2) exploration of the effects of experimental injectionparameters [22] and types of injectors [23] on diffractionpatterns, and (3) control of shock frozen isolated particlesof both biological and artificial origin [14]. Progress inall of these areas was the foundation of recent significantimprovements of the amount of data that can be collectedin a given timeframe in SPI experiments [11].Here, we introduce and describe CMInject , a computa-tional framework that aims to be an extensible basis forsuch simulations. Figure 1 depicts examples of simulationresults, indicating that recent developments, as well asfuture ideas, are supported by our framework.
FIG. 1. Example trajectory plots of experiments simulatedwith
CMInject : (a)
2D trajectories from a simulated focusingexperiment using an axisymmetric aerodynamic lens stack(ALS) to focus d = 27 nm gold nanoparticles [21]. The simu-lations include (black) or disregard (pink) Brownian motion.The background shows the fluid’s velocity in x direction. (b)
3D trajectories of a focusing experiment [14], where a cooledbuffer gas cell (BGC) focuses d = 490 nm polystyrene nanopar-ticles by a flowing carrier gas at a cryogenic temperature(4 K). The used force model is a new theoretical developmentfor particles moving in the molecular flow regime and at lowtemperatures, see Section 3.3.4 [24]. (c) A qualitative repro-duction of an optical trapping and levitation experiment [25],showing the interplay of photophoretic forces [26], gravity, andair resistance. Particles with different masses settle into anequilibrium position over time.
2. PROBLEM DESCRIPTION
Creating high-quality nanoparticle beams poses diversetechnical and scientific challenges [14, 15, 23, 27]. Thedevelopment of improved or sample-adjusted injectionpipelines [15] needs to be supported by a flexible andextensible simulation package, which enables quantitativepredictions of arbitrary nanoparticle injection pipelines.Possibilities to easily implement additional virtual detec-tors, particle types, and force fields are crucial for theusability in a wider scientific context. Capabilities forthe subsequent visualization and analysis of simulationresults, on their own or in comparison with experimentaldata, are also important.Reasonable assumptions within the set of possible sim-ulated experiments were made when designing the initialcomputational framework presented here: (1) particlesdo not interact with each other, nor do they affect thesurrounding environment. (2) experiments have a desig-nated, finite, spatial dimension that the particle beamtravels along.Further points of interest for nanoparticle injectionare the separation of species, e. g., by quantum state,conformation, or enantiomer [16, 28], the alignment ororientation in space [29–33], or the preservation of nativebiological structures [14, 34, 35]. These are not yet im-plemented in
CMInject and will not be discussed furtherin this paper, but we designed our framework foreseeingcorresponding as well as unforeseen extensions.Furthermore, the framework must be usable by theo-rists and experimentalists alike in order to evaluate andexchange ideas and experiments for nanoparticle injection.The framework should strike a balance between expres-siveness and processing requirements: a long proceduralscript, written with optimized functions, might run simu-lations very quickly, but is likely incomprehensible to mostpotential developers and users. A very general framework,while intuitively usable by users and developers, might inturn require so much dynamicism in its implementationthat simulations become unsuitably slow.
3. FRAMEWORK DESCRIPTION
CMInject enables theorists and experimentalists towork together toward inventing or optimizing nanoparticleinjection pipelines [36].
CMInject is written in Python 3and its design follows an object-oriented paradigm. Mostobjects in this framework represent real-world counter-parts that are present in actual experiments. For example,a user might create a
Setup instance, passing along oneor more
Source instances that generate particles, and oneor more
Device instances that affect particles throughouttheir simulated trajectories by simulating physical forces.The user can run() a concrete
Experiment constructedby the
Setup and observe the returned results: a listof
Particle instances that have been updated and, ifdesired, tracked along each particle’s trajectory.
CMInject does not impose many explicit constraintson how specific objects need to behave, it only requiresthat all parts of an
Experiment work with each otherin a well-defined way. For example, while all currentlyimplemented sub-types of
Particle are spherical objects,
CMInject is in principle agnostic to the particle shape.If someone wished to, for example, simulate ellipticalarticles in a fluid flow, they could do so by (i) defining a
Particle subclass
EllipticalParticle with additionalshape parameters, e. g., r x , r y , r z for an ellipsoid and (ii)deriving an implementation of the FluidFlowField classto be able to handle these new particles by an appropriateforce model.Going further, one could even implement the manipu-lation of molecules by electric fields using the quantum-mechanical Stark effect [16, 37], something we are fore-seeing for the near future.
CMInject ’s framework structure consists of: 1. a set of abstract definitions corresponding to real-world experimental objects, with a prescribed wayof constructing a virtual experiment out of theseobjects.2. a parallelized routine that uses numerical integrationto generate particle trajectories through a virtualexperiment.3. supplementary executable scripts, mostly for theanalysis of result data.4. implementations of the abstract definitions for theconcrete physical models listed in Section 3.3.
The following list provides the base classes [38]of
CMInject implemented in the cminject.base and cminject.experiment modules, including brief versionsof their documentation. The full documentation is at-tached in the supplementary materials and updated ver-sions are available at https://cminject.readthedocs.org . cminject.base :• Particle : A particle whose trajectory we want tosimulate. First and foremost a simple data con-tainer.•
Field : An acceleration field acting on
Particle s.•
Action : Updates the properties of a
Particle aftereach integration step. Useful for changes over timethat are not described by the ordinary differentialequations in Section 3.3.1.•
Boundary : A spatial boundary, evaluates if a
Particle is inside its spatial extend.•
Device : A combination of
Field s, Action s, anda
Boundary , modeling real-world experimental de-vices. Applies the effects of its
Field s and
Action sonly if a particle is inside of its
Boundary ; otherwisedoes not affect the particle in any way.•
Detector : Evaluates if and where a
Particle in-teracted with it.•
ResultStorage : Stores experiment results to disk,and offers convenience methods to read them backinto memory later.•
Setup : Akin to a laboratory experimental setupwith changeable pieces and parameters. Exposes aset of parameters that can be changed by the user,and constructs an
Experiment instance from themthat can then be simulated. cminject.experiment : •
Experiment : Akin to a real-world experiment whichhas a fixed set of sources, devices, detectors, andexperimental parameters. Contains one or moreinstances of all of the classes from cminject.base listed above (except for
Setup , which constructs
Experiment instances). Constitutes the entry pointfor simulation, and returns the results.
To numerically solve the particle trajectories for anyvirtual experiment, we used the numerical integrationroutine LSODA [39] as offered by the scipy.ode mod-ule [40]. This routine was chosen for its automatic methodswitching for stiff and non-stiff problems [39], which isvery useful in our generic multiphysics framework wherevarious forces make up an ODE system that can exhibitdifferent degrees of stiffness at different positions in spaceof the same experiment.These integration calculations are, as well as most othercalculations in
CMInject , heavily based on
NumPy ar-rays [41]. We wrote a parallel implementation based onthe multiprocessing module offered by the Python 3core library, letting simulated particles be processed inparallel by a pool of ω ∈ N worker processes, where by de-fault ω is the number of available CPU cores. We use theautomatic optimization library Numba [42] as well as thecompiled language
Cython [43], for automatic and manualoptimization of the calculation functions, respectively.
CMInject is supported by a collection of executablescripts. The main program, cminject , simulatesa specified setup, passing along mandatory and op-tional parameters and providing documentation forthem if needed, and writes the results to a speci-fied output (HDF5) file. cminject_visualize and cminject_analyze-asymmetry support the user’s anal-ysis of the result files: They provide visualization andmetrics of beam profile asymmetry, respectively. Docu-mentation for all utility programs is provided with thesoftware.
To provide a foundation for further discussion of thegenerality and possible improvements, we provide a de-scription of the general program flow of a
CMInject simu-lation. A listing of the steps involved in the current im-plementation is given in Algorithm 1. To clarify the shortdescriptions given there, we note the following: A particleis considered “done” if it is outside of all
Boundary objects,or if its current time is outside of the simulation time-window. Whether integration is successful is determined by the integrator. When a
Detector detects a given par-ticle, it stores an detection event on the
Particle , so thisevent is stored in the result list.
Action s can change aparticle’s phase space position, and if this happens, it istaken into account for the integration routine by resettingthe integrator accordingly.
Algorithm 1
Program flow of a
CMInject simulation.
1. Get particles from all
Source s, merge into one list2. Initialize an empty result list3. For each particle, parallelized via multiprocessing.Pool :(a) Initialize integrator: t = t , x = x (b) If particle “not done” and integration successful:• Update particle phase space position from integrator• Update done-ness of particle using every Boundary • Let each
Action update the particle• If particle position changed, reset the integrator• Let each
Detector try to detect the particle• Update t , by incrementing it by the time step dt • Run the integrator until t . At each evaluated point: – Consult each
Device ’s applicable
Field s – Sum all accelerations• Go to (b)(c) Store fully simulated particle in the result list4. Store the result list as an HDF5 file
Figure 2 simplifies the description given in the step-by-step listing, Algorithm 1 to a higher-level form and omitsimplementation details in favor of general concept. Weanticipate that the community will discuss and optimize,or even replace, the concrete implementation further,while keeping the conceptual program flow as illustratedin Figure 2 fairly consistent across future versions of
CMInject . This first release of
CMInject provides several physicalmodels that are briefly described in the following.
We treat particle trajectories as a collection of incre-mental numerical solutions to the initial value problem: φ ( t ) = f ( t, φ ( t )) φ ( t ) := ( x, y, z, v x , v y , v z ) T ( t ) φ (0) := φ = ( x , y , z , v x, , v y, , v z, ) T f ( t, φ ( t )) := ( v x , v y , v z , a x , a y , a z ) T ( t ) (1) φ is a time-dependent vector in (2 n ) -dimensional phase-space, with n = 3 in the general case or n = 2 for axiallysymmetrical simulations. v i are the velocities and a i the accelerations corresponding to spatial dimension i . ~a = ~F /m p , with the total force ~F exerted on a particlehaving mass m p . We use Stokes’ model for the drag force of an isolatedspherical particle embedded in a flowing medium [44] forvery small Reynolds numbers Re (cid:28) , which is essentialto our simulations of aerodynamical focusing. It is formu-lated in terms of the fluid dynamic viscosity µ , particleradius r , particle mass m , difference in velocity betweenfluid and particle ∆ v , and a Cunningham slip-correctionfactor C c [45]. ~F Stokes = 6 πµr ~ ∆ vC c (2) Field BoundaryDeviceDetectorSource ResultStorage done? ✓✗ generateaffect position check positionaffectpropertiestrytodetect store Action A FIG. 2. Conceptual program flow of a particle simulation with
CMInject , following a single particle through a collection of ob-jects instantiated from the classes provided by the framework.Solid arrows follow the particle’s path; their grey annotationsshow the effect each object can have on the particle. Theshaded background indicates the integration loop, which isrepeated until the particle’s simulation is considered “done”.Classes displayed as a stack of layered rectangles, like
Source ,imply that a simulation can contain more than one object ofsuch a class. The stack simply labeled “A” and the dashed ar-row to the
Action stack indicate that each
Device can contain
Action s, which only affect particles inside that
Device . Since we model nanoparticle injection, Brownianmotion becomes non-negligible, especially for smallernanoparticles. The model for Brownian motion usedis that of a Gaussian white-noise random process with aspectral intensity S taken from Li and Ahmadi [46]. ~a Brown = ~ N (0 , , k ) r πS ∆ t (3) S = 216 µk B Tπ (2 r ) ρ C c ~ N (0 , , k ) denotes a vector of k entries, each being inde-pendently and randomly drawn from a zero mean unitvariance normal distribution. ∆ t is the duration of thetime-interval over the force should be calculated, which isthe time increment of each integration step. r, m, µ and C c are the same quantities as defined in Section 3.3.2. k B is the Boltzmann constant, T is the temperature of thefluid, and ρ is the density of the particle material. For the simulation of nanoparticles moving throughfluids with a wide range of pressures, velocities, and tem-peratures, Stokes’ drag force is often not well applicable.Thus, a new drag force model based on the kinetic theoryof gases was developed [24]. The original formulation [47]of this model was extended to broad sets of conditionsencountered in novel nanoparticle injection experiments,for instance, temperatures as low as 4 K [14]. This forceis defined as a combination of
10 % specular reflectionsand
90 % diffuse reflections and takes into account thetime-dependent temperature difference between the in-jected particles and the fluid. An accompanying modelfor Brownian motion was also provided [24].
Furthermore, a model of the photophoretic force, i. e.,the force of the surrounding gas exerted on an anisotropi-cally radiatively-heated particle. This has found variousapplications in the physical and biological sciences [48]and has also been exploited for controlling and focusingparticle beams [25, 49–52]. A full theoretical descriptionis not available [26] and we have implemented an approxi-mate force model described and benchmarked before [26].It assumes a Laguerre-Gaussian laser beam of order 1, anduses a phenomenological constant κ to model the axialand transverse components separately. A description ofhow we implemented this model, which closely follows thepublication by Desyatnikov, is given in the supplementaryinformation. z distance from ALS exit (mm)020406080100 t hp e r ce n t il e o f x p o s i t i o n s ( µ m ) SimulationExperiment
FIG. 3. Focus curves determined by experiment (orange) andsimulation (blue) for 27nm gold particles, moving through anALS [21]. We measure the x positions of all particles relative tothe origin, and take the 70% quantile of these positions as ourmeasure of focus size. The results agree well on the minimumfocus size and position, i. e., a µm focus at z = 3 mm afterthe ALS exit, and also agree on the defocusing behavior afterthis minimum.
4. SIMULATION RESULTS AND COMPARISONWITH EXPERIMENT
To verify baseline correctness of our framework, webenchmarked it against particle distributions from ex-periment [21]. There, d = 27 nm gold spheres wereinjected into vacuum in an electrospray-ionization setup,passed through a differential pumping stage to removebackground gas, and then guided into an optimized aero-dynamic lens stack (ALS) [15, 21]. The 1D positiondistributions, an arbitrary cross-section of the true 2Ddistribution assuming axisymmetry around the z axis,was measured at various distances from the exit of theALS along the propagation axis z .To simulate this experiment we used the models for thedrag force and Brownian motion described in Section 3.3.We modeled the ALS using its known geometry and exper-imentally recorded pressures at fixed points in the system.We then solved for a laminar flow through this geometryusing a finite-element solver [53] and exported a regulargrid of the quantities flow velocity ~v and gas pressure p throughout the ALS. We defined one FluidFlowDevice and nine
SimpleZDetector s at the distances from theALS exit where the experimental measurements weremade. Then we let
CMInject read in the flow field andrun a simulation for gold spheres with d = 27 nm.The code to reproduce these results is provided in thesupplementary materials.To get a comparable measure for the quality of theparticle beam’s focus that does not depend on fittingany particular beam shape, we calculated the distancefrom the origin in X to which 70 % of the particles weredetected, both for the simulated and the measured data.The results are shown in Figure 3. One can see that thereis good agreement regarding the minimum focus size, ∼ µm at z = 3 mm and the defocusing behavior after z = − . t (ms) − v x (m/s) z = − . − z = − . − x (mm)02040 z = − . -4 -2 0 2 4 x (mm) − Particle count b e f o r e l e n s a f t e r l e n s FIG. 4. Phase-space histograms of simulated particles,at four detectors in an ALS. Two detectors are positionedbefore the aerodynamic lens (top), and two after (bottom).The left column shows the t/x distribution evolving, the rightone the v x /x distribution. In the left column, one can seethat particles with a larger initial x deviation take longerto arrive at the lens: the slowest particles arrive more than ∼
30 ms later at the lens than the fastest ones (see 2nd row).The right column shows the evolving, initially Gaussian, v x /x distribution: it is strongly focused just before and slightlydefocused just after the lens (2nd and 3rd row), and finallyturns into a more focused, collimated particle beam (4th row). z = 3 mm. The focusing at z < mm is in fair agreement,but deviations are clearly visible and tentatively ascribedto the neglect of gas-particle interactions in the initialspace outside the ALS. Nevertheless, the position andsize of the minimum focus are the most important resultsfor an injection pipeline used for single-particle X-rayimaging, which our simulations model very well.To better understand the focusing and defocusing be-havior, we visually examined the results. For instance,Figure 4 shows 2D histograms of useful quantity pairs atdifferent z positions in the experiment described above.This allows for a visual, somewhat intuitive, disentanglingof the evolving ensemble of particles. Such plots can be Number of particles10 E l a p s e d t i m e ( s ) Clock time Number of particles10 M e m o r y ( b y t e ) Max. memory usage
FIG. 5. Scaling behavior of clock time and memory usage forthe simulation described in Section 5. “32” and “16” refer toa Intel Xeon E5-2698 (32 cores) and a Intel Xeon E5-2640CPU (16 cores), respectively. “B” indicates that Brownianmotion was enabled, whereas it wasn’t otherwise. Note thatthe variance in memory usage is very low for a fixed numberof particles and all curves look like one. Besides initial setupoverhead, linear scaling of both clock time and memory isclearly visible. generated with the provided cminject_visualize toolusing the -H option. Alternatively, a qualitative visualanalysis can be obtained by plotting and inspecting par-ticle trajectories as lines, using the -T option, as shownfor this and other experiments in Figure 1. Less con-gested visualizations are obtained by animated trajectoryevolutions, using the -M option, where time-dependentsnapshots of the trajectories provide a visualization of theparticles positions and velocities. Examples are providedas video files in the supplementary materials.
5. PROGRAM PERFORMANCE
The achievable simulation performance was bench-marked on modern multicore computers, specifically nodesof the Maxwell compute cluster at DESY. The nodes weused are equipped with “Intel(R) Xeon(R) CPU E5-2698v3” or “Intel(R) Xeon(R) E5-2640” CPUs, offering 32/64and 16/32 cores/hyperthreads, respectively.We note that performance may improve or degradesubstantially compared to what is shown here when dif-ferent force models, experiment sizes, or time steps areused. Here, we benchmarked the fluid dynamics simula-tion described in Section 4, involving only Stokes’ dragforce and Brownian motion at a time-step of µs andan experiment length of ∼ cm.Figure 5 shows runtime and memory requirements forthis simulation when varying the number of particles, anddemonstrates that both scale linearly with the numberof particles—as expected from a Monte Carlo simulationwith no particle-particle interactions, which is triviallyparallel.In Figure 6, we analyze multiple performance metricsas functions of the number of parallel computation pro-cesses. The optimal runtime is reached when we useexactly as many processes as there are physical CPU
16 32 48 64Number of processes0%20%40%60%80%100%
Performance on Xeon E5-2698
Clock timeUser timeKernel timeMax. memoryVol. ctx. sw.Invol. ctx. sw.Minor page faults
FIG. 6. Performance measurements made on an Intel XeonE5-2698 CPU with 32 physical cores for the same simulationwith different numbers of threads. The maximum value foreach measurement is set to be 100 %, and the other valuesdisplayed in relation to it. “Vol.”/“Invol.” are shorthand for“voluntary”/“involuntary”, and “ctx. sw.” is shorthand for“context switches”. cores. When we use more processes, runtime performancedegrades significantly, together with several other perfor-mance metrics. This is observed even though the CPUoffers up to 64 available hyperthreads, which points toour current implementation not being well-suited to gainperformance from hyperthreading. In line with previousliterature on this topic, we assume the reason to be thathyperthreading increases competition for resources in thememory hierarchy [54]. If this is indeed the reason, itcould mean that our current implementation performs asignificant number of memory accesses that under-utilizecaches.Graphics-processing units (GPUs) are particularly well-suited to trivially parallelizable calculations that largelyconsist of repeated, similar floating-point operations.They offer much higher internal bandwidths in their mem-ory hierarchy than the bandwidths between CPU andmain memory [55], and as such should have less troublemaintaining reasonable performance even when faced withmany cache misses. Therefore, they should exhibit sig-nificantly better runtime-performance scaling at a muchlarger number of parallel threads. We had also discussedother reasons why GPUs could offer significant speedupsfor our calculations [36, ch. 7]. With recent developmentsin the automatic optimization library
Numba [42] makingGPU calculations in Python more accessible, GPUs couldbe effectively utilized in future versions of our object-oriented framework.
6. SUMMARY AND OUTLOOK
We introduced, described, and benchmarked a newPython framework for the simulation of nanoparticle-injection pipelines. We hope that it will not only improvethe sample delivery in single-particle x-ray imaging [11],but also other isolated-nanoparticle experiments [56, 57].The force models already implemented in
CMInject enable simulation-based development and exchange ofimproved and novel injector designs, help to understandthe effects of Brownian motion and how to control itbetter, and facilitate scientific development for inject-ing single, noncrystalline proteins, e. g., for single parti-cle/molecule imaging experiments. Improvements directlyrelevant to scientific applications could be made throughthe systematic derivation and implementation as well asexperimental comparison of models for novel techniques,e. g., acoustic [58] or photophoretic [25, 52] focusing. Thiswould open up possibilities to explore these new and excit-ing pathways toward higher-quality particle beams with
CMInject , pushing the limits of the imaging of chemicaland biochemical processes with atomic resolution.From a software perspective, development effort shouldbe well-invested to make MPI bindings and GPUs avail-able for users of
CMInject , e. g., by use of the mpi4pylibrary [59] or the CUDA bindings in the automatic opti-mization library
Numba [42], which should significantlyimprove simulation runtimes [36] and is foreseen for futureversions of
CMInject .To facilitate fast availability of improvements as wellas community contributions to the development, theframework has been published at https://github.com/cfel-cmi/cminject under a modified GPLv3 license re-quiring attribution, e. g., through referencing of this pub-lication. Up to date documentation is available at https://cminject.readthedocs.org . Additional forces andexperiments will be modeled and open problems thatwere discussed here and elsewhere [36] will be resolved,in close exchange with the user community.
DECLARATION OF INTERESTS
The authors declare that they have no known competingfinancial interests or personal relationships that could have appeared to influence the work reported in this paper.
CREDIT AUTHORSHIP CONTRIBUTIONSTATEMENT
Simon Welker:
Methodology, Software, Valida-tion, Formal analysis, Investigation, Visualization, Writ-ing - Original draft, Writing - Review & Editing;
Muhamed Amin:
Conceptualization, Writing - Review& Editing, Supervision;
Jochen Küpper:
Conceptual-ization, Resources, Writing - Review & Editing, Supervi-sion, Project administration
ACKNOWLEDGMENTS
We gratefully acknowledge useful discussions with An-drei Rode on photophoretic forces. We thank Lena Worbsfor many useful comments and the CMI COMOTIONteam for tests and feedback of the software package.This work has been supported by the European Re-search Council under the European Union’s SeventhFramework Programme (FP7/2007-2013) through theConsolidator Grant COMOTION (ERC-CoG 614507)and by the Deutsche Forschungsgemeinschaft throughthe Cluster of Excellence “Advanced Imaging of Matter”(AIM, EXC 2056, ID 390715994).This research was supported in part through theMaxwell computational resources operated at DeutschesElektronen-Synchrotron DESY, Hamburg, Germany. [1] R. Neutze, R. Wouts, D. van der Spoel, E. Weckert,and J. Hajdu, Potential for biomolecular imaging withfemtosecond x-ray pulses, Nature , 752 (2000).[2] J. C. H. Spence and H. N. Chapman, The birth of a newfield, Phil. Trans. R. Soc. B , 20130309 (2014).[3] P. Emma, R. Akre, J. Arthur, R. Bionta, C. Bostedt,J. Bozek, A. Brachmann, P. Bucksbaum, R. Coffee, F. J.Decker, Y. Ding, D. Dowell, S. Edstrom, A. Fisher,J. Frisch, S. Gilevich, J. Hastings, G. Hays, P. Hering,Z. Huang, R. Iverson, H. Loos, M. Messerschmidt, A. Mi-ahnahri, S. Moeller, H. D. Nuhn, G. Pile, D. Ratner,J. Rzepiela, D. Schultz, T. Smith, P. Stefan, H. Tompkins,J. Turner, J. Welch, W. White, J. Wu, G. Yocky, andJ. Galayda, First lasing and operation of an angstrom-wavelength free-electron laser, Nat. Photon. , 641 (2010).[4] W. Decking, S. Abeghyan, P. Abramian, A. Abramsky,A. Aguirre, C. Albrecht, P. Alou, M. Altarelli, P. Alt-mann, K. Amyan, V. Anashin, E. Apostolov, K. Ap-pel, D. Auguste, V. Ayvazyan, S. Baark, F. Babies, N. Baboi, P. Bak, V. Balandin, R. Baldinger, B. Barana-sic, S. Barbanotti, O. Belikov, V. Belokurov, L. Belova,V. Belyakov, S. Berry, M. Bertucci, B. Beutner, A. Block,M. Blöcher, T. Böckmann, C. Bohm, M. Böhnert, V. Bon-dar, E. Bondarchuk, M. Bonezzi, P. Borowiec, C. Bösch,U. Bösenberg, A. Bosotti, R. Böspflug, M. Bousonville,E. Boyd, Y. Bozhko, A. Brand, J. Branlard, S. Briechle,F. Brinker, S. Brinker, R. Brinkmann, S. Brockhauser,O. Brovko, H. Brück, A. Brüdgam, L. Butkowski, T. Büt-tner, J. Calero, E. Castro-Carballo, G. Cattalanotto,J. Charrier, J. Chen, A. Cherepenko, V. Cheskidov,M. Chiodini, A. Chong, S. Choroba, M. Chorowski,D. Churanov, W. Cichalewski, M. Clausen, W. Clement,C. Cloué, J. A. Cobos, N. Coppola, S. Cunis, K. Czuba,M. Czwalinna, B. D’Almagne, J. Dammann, H. Danared,A. de Zubiaurre Wagner, A. Delfs, T. Delfs, F. Diet-rich, T. Dietrich, M. Dohlus, M. Dommach, A. Donat,X. Dong, N. Doynikov, M. Dressel, M. Duda, P. Duda,H. Eckoldt, W. Ehsan, J. Eidam, F. Eints, C. En- gling, U. Englisch, A. Ermakov, K. Escherich, J. Eschke,E. Saldin, M. Faesing, A. Fallou, M. Felber, M. Fen-ner, B. Fernandes, J. M. Fernández, S. Feuker, K. Fil-ippakopoulos, K. Floettmann, V. Fogel, M. Fontaine,A. Francés, I. F. Martin, W. Freund, T. Freyermuth,M. Friedland, L. Fröhlich, M. Fusetti, J. Fydrych, A. Gal-las, O. García, L. Garcia-Tabares, G. Geloni, N. Gerasi-mova, C. Gerth, P. Geßler, V. Gharibyan, M. Gloor,J. Głowinkowski, A. Goessel, Z. Gołębiewski, N. Golubeva,W. Grabowski, W. Graeff, A. Grebentsov, M. Grecki,T. Grevsmuehl, M. Gross, U. Grosse-Wortmann, J. Grün-ert, S. Grunewald, P. Grzegory, G. Feng, H. Guler, G. Gu-sev, J. L. Gutierrez, L. Hagge, M. Hamberg, R. Hanneken,E. Harms, I. Hartl, A. Hauberg, S. Hauf, J. Hauschildt,J. Hauser, J. Havlicek, A. Hedqvist, N. Heidbrook, F. Hell-berg, D. Henning, O. Hensler, T. Hermann, A. Hid-végi, M. Hierholzer, H. Hintz, F. Hoffmann, M. Hoff-mann, M. Hoffmann, Y. Holler, M. Hüning, A. Ignatenko,M. Ilchen, A. Iluk, J. Iversen, M. Izquierdo, L. Jachmann,N. Jardon, U. Jastrow, K. Jensch, J. Jensen, M. Jeżabek,M. Jidda, H. Jin, N. Johansson, R. Jonas, W. Kaabi,D. Kaefer, R. Kammering, H. Kapitza, S. Karabekyan,S. Karstensen, K. Kasprzak, V. Katalev, D. Keese, B. Keil,M. Kholopov, M. Killenberger, B. Kitaev, Y. Klim-chenko, R. Klos, L. Knebel, A. Koch, M. Koepke, S. Köh-ler, W. Köhler, N. Kohlstrunk, Z. Konopkova, A. Kon-stantinov, W. Kook, W. Koprek, M. Körfer, O. Korth,A. Kosarev, K. Kosiński, D. Kostin, Y. Kot, A. Ko-tarba, T. Kozak, V. Kozak, R. Kramert, M. Krasil-nikov, A. Krasnov, B. Krause, L. Kravchuk, O. Krebs,R. Kretschmer, J. Kreutzkamp, O. Kröplin, K. Krzysik,G. Kube, H. Kuehn, N. Kujala, V. Kulikov, V. Kuzminych,D. La Civita, M. Lacroix, T. Lamb, A. Lancetov, M. Lars-son, D. Le Pinvidic, S. Lederer, T. Lensch, D. Lenz,A. Leuschner, F. Levenhagen, Y. Li, J. Liebing, L. Lilje,T. Limberg, D. Lipka, B. List, J. Liu, S. Liu, B. Lorbeer,J. Lorkiewicz, H. H. Lu, F. Ludwig, K. Machau, W. Ma-ciocha, C. Madec, C. Magueur, C. Maiano, I. Maksimova,K. Malcher, T. Maltezopoulos, E. Mamoshkina, B. Man-schwetus, F. Marcellini, G. Marinkovic, T. Martinez,H. Martirosyan, W. Maschmann, M. Maslov, A. Math-eisen, U. Mavric, J. Meißner, K. Meissner, M. Messer-schmidt, N. Meyners, G. Michalski, P. Michelato, N. Mild-ner, M. Moe, F. Moglia, C. Mohr, S. Mohr, W. Möller,M. Mommerz, L. Monaco, C. Montiel, M. Moretti, I. Mo-rozov, P. Morozov, and D. Mross, A MHz-repetition-ratehard x-ray free-electron laser driven by a superconductinglinear accelerator, Nat. Photon. , 391 (2020).[5] U. Lorenz, N. M. Kabachnik, E. Weckert, and I. A. Var-tanyants, Impact of ultrafast electronic damage in single-particle x-ray imaging experiments, Phys. Rev. E ,051911 (2012), arXiv:1206.6960 [physics].[6] A. Barty, J. Küpper, and H. N. Chapman, Molecularimaging using x-ray free-electron lasers, Annu. Rev. Phys.Chem. , 415 (2013).[7] K. Pande, C. D. M. Hutchison, G. Groenhof, A. Aquila,J. S. Robinson, J. Tenboer, S. Basu, S. Boutet, D. P. De-Ponte, M. Liang, T. A. White, N. A. Zatsepin, O. Yefanov,D. Morozov, D. Oberthuer, C. Gati, G. Subramanian,D. James, Y. Zhao, J. Koralek, J. Brayshaw, C. Kupitz,C. Conrad, S. Roy-Chowdhury, J. D. Coe, M. Metz,P. L. Xavier, T. D. Grant, J. E. Koglin, G. Ketawala,R. Fromme, V. Šrajer, R. Henning, J. C. H. Spence,A. Ourmazd, P. Schwander, U. Weierstall, M. Frank, P. Fromme, A. Barty, H. N. Chapman, K. Moffat, J. J.van Thor, and M. Schmidt, Femtosecond structural dy-namics drives the trans/cis isomerization in photoactiveyellow protein, Science , 725 (2016).[8] A. Ourmazd, Cryo-EM, XFELs and the structure conun-drum in structural biology, Nat. Meth. , 941 (2019).[9] K. Ayyer, A. J. Morgan, A. Aquila, H. DeMirci, B. G.Hogue, R. A. Kirian, P. L. Xavier, C. H. Yoon, H. N.Chapman, and A. Barty, Low-signal limit of x-ray singleparticle diffractive imaging, Opt. Exp. , 37816 (2019).[10] M. F. Hantke, J. Bielecki, O. Kulyk, D. Westphal, D. S. D.Larsson, M. Svenda, H. K. N. Reddy, R. A. Kirian, J. An-dreasson, J. Hajdu, and F. R. N. C. Maia, Rayleigh-scattering microscopy for tracking and sizing nanoparti-cles in focused aerosol beams, IUCrJ , 673 (2018).[11] K. Ayyer, P. L. Xavier, J. Bielecki, Z. Shen, B. J.Daurer, A. K. Samanta, S. Awel, R. Bean, A. Barty,M. Bergemann, T. Ekeberg, A. D. Estillore, H. Fan-gohr, K. Giewekemeyer, M. S. Hunter, M. Karnevskiy,R. A. Kirian, H. Kirkwood, Y. Kim, J. Koliyadu,H. Lange, R. Letrun, J. Lübke, T. Michelat, A. J. Mor-gan, N. Roth, T. Sato, M. Sikorski, F. Schulz, J. C. H.Spence, P. Vagovic, T. Wollweber, L. Worbs, O. Yefanov,Y. Zhuang, F. R. N. C. Maia, D. A. Horke, J. Küpper,N. D. Loh, A. P. Mancuso, and H. N. Chapman, 3Ddiffractive imaging of nanoparticle ensembles using an x-ray laser, Optica , 15 (2021), arXiv:2007.13597 [physics].[12] R. Fung, V. Shneerson, D. Saldin, and A. Ourmazd, Struc-ture from fleeting illumination of faint spinning objectsin flight, Nat. Phys. , 64 (2009).[13] G. Bortel and G. Faigel, Classification of continuousdiffraction patterns: a numerical study, J. Struct. Biol. , 10 (2007).[14] A. K. Samanta, M. Amin, A. D. Estillore, N. Roth,L. Worbs, D. A. Horke, and J. Küpper, Controlled beamsof shockfrozen, isolated, biological and artificial nanopar-ticles, Struct. Dyn. , 024304 (2020), arXiv:1910.12606[physics].[15] N. Roth, S. Awel, D. A. Horke, and J. Küpper, Optimizingaerodynamic lenses for single-particle imaging, J. Aerosol.Sci. , 17 (2018), arXiv:1712.01795 [physics].[16] Y.-P. Chang, D. A. Horke, S. Trippel, and J. Küp-per, Spatially-controlled complex molecules and theirapplications, Int. Rev. Phys. Chem. , 557 (2015),arXiv:1505.05632 [physics].[17] P. Liu, P. J. Ziemann, D. B. Kittelson, and P. H. McMurry,Generating particle beams of controlled dimensions anddivergence: I. theory of particle motion in aerodynamiclenses and nozzle expansions, Aerosol Sci. Techn. , 293(1995).[18] X. Wang and P. H. McMurry, An experimental studyof nanoparticle focusing with aerodynamic lenses, Int. J.Mass Spectrom. , 30 (2006).[19] X. Wang, A. Gidwani, S. L. Girshick, and P. H. McMurry,Aerodynamic focusing of nanoparticles: II. numericalsimulation of particle motion through aerodynamic lenses,Aerosol Sci. Techn. , 624 (2005).[20] X. Wang and P. H. McMurry, A design tool for aerody-namic lens systems, Aerosol Sci. Technol. , 320 (2006).[21] L. Worbs, N. Roth, J. Lübke, A. Estillore, P. L. Xavier,A. K. Samanta, and J. Küpper, Optimizing the geometryof nanoparticle injectors (2020), in preparation.[22] E. Sobolev, S. Zolotarev, K. Giewekemeyer, J. Bielecki,K. Okamoto, H. K. N. Reddy, J. Andreasson, K. Ayyer, I. Barak, S. Bari, A. Barty, R. Bean, S. Bobkov, H. N.Chapman, G. Chojnowski, B. J. Daurer, K. Dörner,T. Ekeberg, L. Flückiger, O. Galzitskaya, L. Gelisio,S. Hauf, B. G. Hogue, D. A. Horke, A. Hosseinizadeh,V. Ilyin, C. Jung, C. Kim, Y. Kim, R. A. Kirian, H. Kirk-wood, O. Kulyk, R. Letrun, D. Loh, M. Messerschmidt,K. Mühlig, A. Ourmazd, N. Raab, A. V. Rode, M. Rose,A. Round, T. Sato, R. Schubert, P. Schwander, J. A. Sell-berg, M. Sikorski, A. Silenzi, C. Song, J. C. H. Spence,S. Stern, J. Sztuk-Dambietz, A. Teslyuk, N. Timneanu,M. Trebbin, C. Uetrecht, B. Weinhausen, G. J. Williams,P. L. Xavier, C. Xu, I. Vartanyants, V. Lamzin, A. Man-cuso, and F. R. N. C. Maia, Megahertz single-particleimaging at the European XFEL, Comm. Phys , 97 (2020),arXiv:1912.10796 [physics].[23] J. Bielecki, M. F. Hantke, B. J. Daurer, H. K. N. Reddy,D. Hasse, D. S. D. Larsson, L. H. Gunn, M. Svenda,A. Munke, J. A. Sellberg, L. Flueckiger, A. Pietrini,C. Nettelblad, I. Lundholm, G. Carlsson, K. Okamoto,N. Timneanu, D. Westphal, O. Kulyk, A. Higashiura,G. van der Schot, N.-T. D. Loh, T. E. Wysong, C. Bostedt,T. Gorkhover, B. Iwan, M. M. Seibert, T. Osipov, P. Wal-ter, P. Hart, M. Bucher, A. Ulmer, D. Ray, G. Carini,K. R. Ferguson, I. Andersson, J. Andreasson, J. Hajdu,and F. R. N. C. Maia, Electrospray sample injection forsingle-particle imaging with x-ray lasers, Science Advances , eaav8801 (2019).[24] N. Roth, M. Amin, A. K. Samanta, and J. Küpper, Mi-croscopic force for aerosol transport, arXiv:2006.10652[physics] (2020), in preparation.[25] N. Eckerskorn, R. Bowman, R. A. Kirian, S. Awel,M. Wiedorn, J. Küpper, M. J. Padgett, H. N. Chap-man, and A. V. Rode, Optically induced forces imposedin an optical funnel on a stream of particles in air orvacuum, Phys. Rev. Appl. , 064001 (2015).[26] A. S. Desyatnikov, V. G. Shvedov, A. V. Rode, W. Kro-likowski, and Y. S. Kivshar, Photophoretic manipulationof absorbing aerosol particles with vortex beams: theoryversus experiment, Opt. Exp. , 8201 (2009).[27] B. J. Daurer, K. Okamoto, J. Bielecki, F. R. N. C. Maia,K. Mühlig, M. M. Seibert, M. F. Hantke, C. Nettelblad,W. H. Benner, M. Svenda, N. Timneanu, T. Ekeberg,N. D. Loh, A. Pietrini, A. Zani, A. D. Rath, D. West-phal, R. A. Kirian, S. Awel, M. O. Wiedorn, G. van derSchot, G. H. Carlsson, D. Hasse, J. A. Sellberg, A. Barty,J. Andreasson, S. Boutet, G. Williams, J. Koglin, I. An-dersson, J. Hajdu, and D. S. D. Larsson, Experimentalstrategies for imaging bioparticles with femtosecond hardx-ray pulses, IUCrJ , 251 (2017).[28] A. Yachmenev, J. Onvlee, E. Zak, A. Owens, and J. Küp-per, Field-induced diastereomers for chiral separation,Phys. Rev. Lett. , 243202 (2019), arXiv:1905.07166[physics].[29] H. Stapelfeldt and T. Seideman, Colloquium: Aligningmolecules with strong laser pulses, Rev. Mod. Phys. ,543 (2003).[30] J. C. H. Spence and R. B. Doak, Single molecule diffrac-tion, Phys. Rev. Lett. , 198102 (2004).[31] L. Holmegaard, J. H. Nielsen, I. Nevo, H. Stapelfeldt,F. Filsinger, J. Küpper, and G. Meijer, Laser-inducedalignment and orientation of quantum-state-selectedlarge molecules, Phys. Rev. Lett. , 023001 (2009),arXiv:0810.2307 [physics]. [32] J. Küpper, S. Stern, L. Holmegaard, F. Filsinger,A. Rouzée, A. Rudenko, P. Johnsson, A. V. Martin,M. Adolph, A. Aquila, S. Bajt, A. Barty, C. Bost-edt, J. Bozek, C. Caleman, R. Coffee, N. Coppola,T. Delmas, S. Epp, B. Erk, L. Foucar, T. Gorkhover,L. Gumprecht, A. Hartmann, R. Hartmann, G. Hauser,P. Holl, A. Hömke, N. Kimmel, F. Krasniqi, K.-U. Kühnel,J. Maurer, M. Messerschmidt, R. Moshammer, C. Re-ich, B. Rudek, R. Santra, I. Schlichting, C. Schmidt,S. Schorb, J. Schulz, H. Soltau, J. C. H. Spence, D. Staro-dub, L. Strüder, J. Thøgersen, M. J. J. Vrakking, G. Wei-denspointner, T. A. White, C. Wunderer, G. Meijer, J. Ull-rich, H. Stapelfeldt, D. Rolles, and H. N. Chapman, X-raydiffraction from isolated and strongly aligned gas-phasemolecules with a free-electron laser, Phys. Rev. Lett. ,083002 (2014), arXiv:1307.4577 [physics].[33] E. T. Karamatskos, S. Raabe, T. Mullins, A. Trabattoni,P. Stammer, G. Goldsztejn, R. R. Johansen, K. Dłu-gołęcki, H. Stapelfeldt, M. J. J. Vrakking, S. Trippel,A. Rouzée, and J. Küpper, Molecular movie of ultrafastcoherent rotational dynamics of OCS, Nat. Commun. ,3364 (2019), arXiv:1807.01034 [physics].[34] J. Miao, T. Ishikawa, Q. Shen, and T. Earnest, Extend-ing x-ray crystallography to allow the imaging of non-crystalline materials, cells, and single protein complexes,Annu. Rev. Phys. Chem. , 387 (2007).[35] J. Miao, P. Charalambous, J. Kirz, and D. Sayre, Extend-ing the methodology of x-ray crystallography to allowimaging of micrometre-sized non-crystalline specimens,Nature , 342 (1999).[36] S. Welker, Simulation of artificial and biological nanopar-ticles’ trajectories in hybrid force-fields , Bachelor thesis,Universität Hamburg (2019).[37] F. Filsinger, J. Küpper, G. Meijer, L. Holmegaard, J. H.Nielsen, I. Nevo, J. L. Hansen, and H. Stapelfeldt,Quantum-state selection, alignment, and orientation oflarge molecules using static electric and laser fields,J. Chem. Phys. , 064309 (2009), arXiv:0903.5413[physics].[38] G. van Rossum and Talin, PEP 3119: Introducing abstractbase classes, Website, URL: (2007), accessed on 2019-10-04.[39] L. Petzold, Automatic selection of methods for solvingstiff and nonstiff systems of ordinary differential equations,SIAM J. Sci. & Stat. Comp. , 136 (1983).[40] P. Virtanen, R. Gommers, T. E. Oliphant, M. Haber-land, T. Reddy, D. Cournapeau, E. Burovski, P. Peterson,W. Weckesser, J. Bright, S. J. van der Walt, M. Brett,J. Wilson, K. Jarrod Millman, N. Mayorov, A. R. J.Nelson, E. Jones, R. Kern, E. Larson, C. Carey, İ. Po-lat, Y. Feng, E. W. Moore, J. VanderPlas, D. Laxalde,J. Perktold, R. Cimrman, I. Henriksen, E. A. Quintero,C. R. Harris, A. M. Archibald, A. H. Ribeiro, F. Pe-dregosa, P. van Mulbregt, and SciPy 1.0 Contributors,SciPy 1.0: fundamental algorithms for scientific comput-ing in Python, Nat. Meth. , 261 (2020).[41] S. van der Walt, S. C. Colbert, and G. Varoquaux, TheNumPy array: A structure for efficient numerical compu-tation, Comp. in Sci. & Eng. , 22 (2011).[42] S. K. Lam, A. Pitrou, and S. Seibert, Numba: A LLVM-based Python JIT compiler, in Proceedings of the SecondWorkshop on the LLVM Compiler Infrastructure in HPC ,LLVM ’15 (Association for Computing Machinery, NewYork, NY, USA, 2015). [43] S. Behnel, R. Bradshaw, C. Citro, L. Dalcin, D. S. Sel-jebotn, and K. Smith, Cython: The best of both worlds,Comp. Sci. & Eng. , 31 (2011).[44] G. G. Stokes, On the effect of the internal friction of fluidson the motion of pendulums, Trans. Cambridge Phil. Soc. , 8 (1851).[45] E. Cunningham and J. Larmor, On the velocity of steadyfall of spherical particles through fluid medium, Proc.Royal Soc. London A , 357 (1910).[46] A. Li and G. Ahmadi, Dispersion and deposition of spher-ical particles from point sources in a turbulent channelflow, Aerosol Sci. Techn. , 209 (1992).[47] P. S. Epstein, On the resistance experienced by spheresin their motion through gases, Phys. Rev. , 710 (1924).[48] R. W. Bowman and M. J. Padgett, Optical trapping andbinding, Rep. Prog. Phys. , 026401 (2013).[49] N. O. Eckerskorn, Trapping and guiding microscopic par-ticles with light-induced forces , Dissertation, College ofPhysical & Mathematical Sciences, Research School ofPhysics and Engineering, Laser Physics Centre, Australia(2016).[50] V. G. Shvedov, A. S. Desyatnikov, A. V. Rode, W. Kro-likowski, and Y. S. Kivshar, Optical guiding of absorbingnanoclusters in air, Opt. Exp. , 5743 (2009).[51] V. G. Shvedov, C. Hnatovsky, A. V. Rode, and W. Kro-likowski, Robust trapping and manipulation of airborneparticles with a bottle beam, Opt. Exp. , 17350 (2011).[52] S. Awel, S. Lavin-Varela, N. Roth, D. A. Horke, A. V.Rode, R. A. Kirian, J. Küpper, and H. N. Chapman,Optical funnel to guide and focus virus particles for x-raylaser imaging (2020), submitted. [53] COMSOL Multiphysics v. 5.5. .COMSOL AB, Stockholm, Sweden.[54] S. Saini, H. Jin, R. Hood, D. Barker, P. Mehrotra, andR. Biswas, The impact of hyper-threading on processorresource utilization in production applications, in (2011) pp. 1–10.[55] NVIDIA Corporation, CUDA C++ best practices guide(2020), accessed on 2020-12-09.[56] L. Seiffert, Q. Liu, S. Zherebtsov, A. Trabattoni, P. Rupp,M. C. Castrovilli, M. Galli, F. Submann, K. Winter-sperger, J. Stierle, G. Sansone, L. Poletto, F. Frassetto,I. Halfpap, V. Mondes, C. Graf, E. Rühl, F. Krausz,M. Nisoli, T. Fennel, F. Calegari, and M. F. Kling, At-tosecond chronoscopy of electron scattering in dielectricnanoparticles, Nat. Phys. , 766 (2017).[57] A. Aquila, A. Barty, C. Bostedt, S. Boutet, G. Carini,D. DePonte, P. Drell, S. Doniach, K. H. Downing,T. Earnest, H. Elmlund, V. Elser, M. Gühr, J. Hajdu,J. Hastings, S. P. Hau-Riege, Z. Huang, E. E. Lattman,F. R. N. C. Maia, S. Marchesini, A. Ourmazd, C. Pelle-grini, R. Santra, I. Schlichting, C. Schroer, J. C. H. Spence,I. A. Vartanyants, S. Wakatsuki, W. I. Weis, and G. J.Williams, The linac coherent light source single particleimaging road map, Struct. Dyn. , 041701 (2015).[58] Z. Li, L. Shi, L. Cao, Z. Liu, and J. Küpper, Acousticfunnel and buncher for nanoparticle injection, Phys. Rev.Appl. , 064036 (2019), arXiv:1803.07472 [physics].[59] L. Dalcín, R. Paz, and M. Storti, MPI for Python, J.Parallel Distr. Comp. , 1108 (2005). upplementary information: CMInject : Python framework for the numericalsimulation of nanoparticle injection pipelines
Simon Welker, Muhamed Amin,
1, 2, 3 and Jochen Küpper
1, 4, 5, * Center for Free-Electron Laser Science, Deutsches Elektronen-Synchrotron DESY, Notkestraße 85, 22607 Hamburg, Germany Department of Sciences, University College Groningen, University of Groningen,Hoendiepskade 23/24, 9718 BG Groningen, Netherlands Groningen Biomolecular Sciences and Biotechnology Institute,University of Groningen, Nijenborgh 4, 9747 AG Groningen, Netherlands Center for Ultrafast Imaging, Universität Hamburg, Luruper Chaussee 149, 22761 Hamburg, Germany Department of Physics, Universität Hamburg, Luruper Chaussee 149, 22761 Hamburg, Germany (Dated: 2021-02-12)
I. EXAMPLE DEFINITION OF A SETUP IN CMINJECT
The code in Listing 1 is an example definition of a CMInject setup, i. e., it defines a subclass of the abstract baseclass cminject.base.Setup . This setup can be simulated as a concrete virtual experiment with the cminject commandprovided in Listing 2. The required file “ examples/example_field.h5 ” is provided in the supplementary materials,and is also included in the CMInject Python package. * a r X i v : . [ phy s i c s . c o m p - ph ] F e b experiment.add_detector(SimpleZDetector(z))return experiment@staticmethoddef get_parser() -> SetupArgumentParser:parser = SetupArgumentParser()parser.add_argument('-f', '--filename', help='The filename of the flow field (HDF5).', type=str)parser.add_argument('--rho', help='The density of the particle material [kg/m^3].', type=float, default=1050.0)parser.add_argument('--pos', help='The position distributions in x/z space [m]', type=distribution_description,nargs=2, default=[GaussianDistribution(0, 1e-3), constant(0.0)])return parser Listing 1. Python script ( example_setup.py ) that defines a simple example setup. See alsolib/cminject/setups/example.py in the code repository. ` ` \-s example_setup.ExampleSetup \ ` ` \-f example_field.h5 \ ` ` \-n 100 \ ` ` \-o example_output.h5 \ ` ` \-T Listing 2. Example CMInject simulation shell script ( example_simulation.sh ) II. CODE FOR THE ALS SIMULATION, ANALYSIS, AND COMPARISON TO EXPERIMENT
Listing 3 and Listing 4 provide code that serves to reproduce Figure 3 from the paper, i.e. the comparison figurebetween simulation and experiment. Listing 3 shows the command-line command to run the corresponding simulationfor particles and store the detected particle positions at virtual detectors positioned at the same spots whereexperimental measurements were made. Listing 4 shows the Python code to do the same result data analysis andplotting procedure that generated Figure 3 in the paper. ` ` cminject -f "als_field.h5"\ ` ` \-rho 19320\ ` ` \-D 2\ ` ` \-p G[0,0.002] -0.128\ ` ` \-v G[0,1] G[1,0.1]\ ` ` \-r G[1.35e-8,1.91e-9]\ ` ` \-t 0 1\ ` ` \-ts 1e-5\ ` ` \-d 0.001 0.00141 0.00181 0.00221 0.00261\0.00301 0.00341 0.00381 0.00421 0.00461\ ` ` \-n 100\ ` ` \-o als_output.h5\ ` ` \ -B Listing 3. Shell script ( als_simulation.sh ) for the simulation that produced the focus curve shown in the paper.
Listing 4. Python script ( als_analysis.py ) to produce the focus curve comparison plot (Figure 3 in the paper) fromthe results of the simulation given in Listing 3. z / z F z / P a / w = 0.3 a / w = 0.5 a / w = 0.75 a / w = 0.85 R / w F R / P a / w = 0.3 a / w = 0.5 a / w = 0.7 a / w = 1.1 a / w = 1.25 FIG. 1. The axial and transverse components of the photophoretic force model by Desyatnikov et al [1] as multiples of 𝜅𝑃 . 𝑎 is the particle radius, 𝑤 is the beam waist radius, 𝑅 is the magnitude of the radial offset relative to the beamaxis, and 𝑧 is the diffraction length of the Laguerre-Gaussian beam. III. PHOTOPHORETIC FORCE MODEL