Package: pydiffuser
PydiffuserPydiffuser is a numerical simulation framework for nonequilibrium statistical physics based onJAX.This package mainly aims:to share code to implement a numerical simulation on physical models written in various forms ofstochastic differential equations.to revisit recent research highlights in nonequilibrium statistical physics.to reduce the repeated code on time-series data analysis, e.g., statistical analysis ofsingle-particle trajectoryforSPTexperiments.to provide the skeleton of stochastic modeling for anyone interested in stochastic processes.InstallationRequirementsPython 3.10+,jax>=0.4.18, andjaxlib>=0.4.18.FromPyPI$pipinstallpydiffuserIf properly installed, you can run:$pydiffuser--versionpydiffuser, version 0.0.2QuickstartPydiffuser provides various stochastic models that implement a numerical simulation based on theMonte Carlo method.
All Pydiffuser's models inherit an abstract classpydiffuser.models.BaseDiffusionand initiate the simulation after a methodgenerateis called.
For the simplest case, you can produce a non-interactingBrownian motionat low Reynolds numbers as follows:frompydiffuser.modelsimportBrownianMotionfrompydiffuser.tracerimportEnsemble,Trajectorymodel=BrownianMotion()ensemble:Ensemble=model.generate()tracer:Trajectory=ensemble[0]# the 0th particleRelevant stochastic observables, such asmean-squared displacementand normalizedvelocity autocorrelation function, can be calculated through themethodsofTrajectoryandEnsemble.tamsd=tracer.get_mean_squared_displacement(lagtime=1,rolling=True)eamsd=ensemble.get_mean_squared_displacement(lagtime=1,rolling=False)eatamsd=ensemble.get_mean_squared_displacement(lagtime=1,rolling=True)You can visualize the trajectory usingmatplotlib:It is obtained bymatplotlib.pyplot.plot(tracer.position_x1, tracer.position_x2).CLIList all stochastic models supported by Pydiffuser.$pydiffusermodellistNAME            MODEL                           CONFIG                          DIMENSIONabp             ActiveBrownianParticle          ActiveBrownianParticleConfig    2daoup            ActiveOUParticle                ActiveOUParticleConfig          1d, 2d, 3dbm              BrownianMotion                  BrownianMotionConfig            1d, 2d, 3dlevy            LevyWalk                        LevyWalkConfig                  1d, 2d, 3drtp             RunAndTumbleParticle            RunAndTumbleParticleConfig      1d, 2d, 3dsmoluchowski    SmoluchowskiEquation            SmoluchowskiEquationConfig      1d, 2dFeaturesObservablesclasspydiffuser.tracer.Trajectory∈classpydiffuser.tracer.Ensembleget_incrementsget_displacement_momentget_mean_squared_displacementget_cosine_momentget_velocity_autocorrelationget_real_timeThe above methods are defined in bothTrajectoryandEnsembleto enhance transparency.
UsingTrajectory, the statistical analysis ofsingle-particle trajectorycan be accelerated.ConfigurationWe introduce a configuration to deal with extensive parameter manipulation.
For instance, seeconfig.json, which contains all parameters demanded to instantiatepydiffuser.ActiveBrownianParticle.
Every JSON of the configurations listed inCLIcan be obtained as follows:importpydiffuseraspydfrompydiffuser.modelsimportActiveBrownianParticle,ActiveBrownianParticleConfigconfig=ActiveBrownianParticleConfig()config.to_json(json_path=<JSON_PATH>)We suggest a research pipeline:┌────┐┌─────────────────────┐┌───────────────┐┌──────────┐┌────────────┐│JSON├──>──┤`BaseDiffusionConfig`├──>──┤`BaseDiffusion`├──>──┤`Ensemble`├──>──┤NPY|PICKLE│└────┘[1]└─────────────────────┘[2]└───────────────┘[3]└──────────┘[4]└────────────┘It can be automized as follows:config=ActiveBrownianParticleConfig.from_json(json_path=<JSON_PATH>)# [1]model=ActiveBrownianParticle.from_config(config=config)# [2]ensemble=model.generate()# [3]ensemble.to_npy(npy_path=<NPY_PATH>)# [4]You can save and load any picklable object throughpydiffuser.saveandpydiffuser.load.MODEL_PATH="model.pickle"pyd.save(obj=model,pickle_path=MODEL_PATH)# Here, <PICKLE_PATH> = MODEL_PATHmodel=pyd.load(pickle_path=MODEL_PATH)Related WorksHyperdiffusion of Poissonian run-and-tumble particles in two dimensionsLicenseApache License 2.0Citation@misc{jung2023pydiffuser,title={Pydiffuser: a simulation framework for nonequilibrium statistical physics},author={Jung, Yurim},year={2023},note={doi: 10.5281/zenodo.10017027},}