{"id":34070848,"url":"https://github.com/jung235/pydiffuser","last_synced_at":"2026-03-12T06:01:41.072Z","repository":{"id":200006937,"uuid":"703392021","full_name":"jung235/pydiffuser","owner":"jung235","description":"A simulation framework for nonequilibrium statistical physics","archived":false,"fork":false,"pushed_at":"2024-07-30T12:19:40.000Z","size":428,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-15T11:17:49.589Z","etag":null,"topics":["active-matter","continuous-time-random-walk","jax","langevin-dynamics","simulation","statistical-physics","stochastic-differential-equations"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jung235.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-10-11T06:49:53.000Z","updated_at":"2026-01-23T21:36:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e704c32-9093-403b-8d45-022da7257a1e","html_url":"https://github.com/jung235/pydiffuser","commit_stats":null,"previous_names":["jung235/pydiffuser"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jung235/pydiffuser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jung235%2Fpydiffuser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jung235%2Fpydiffuser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jung235%2Fpydiffuser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jung235%2Fpydiffuser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jung235","download_url":"https://codeload.github.com/jung235/pydiffuser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jung235%2Fpydiffuser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30416729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T04:41:02.746Z","status":"ssl_error","status_checked_at":"2026-03-12T04:40:12.571Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["active-matter","continuous-time-random-walk","jax","langevin-dynamics","simulation","statistical-physics","stochastic-differential-equations"],"created_at":"2025-12-14T07:36:10.876Z","updated_at":"2026-03-12T06:01:40.818Z","avatar_url":"https://github.com/jung235.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=https://github.com/jung235/pydiffuser/assets/96967431/a9f54ef6-d1d4-4fcf-88bf-8c336dd671c0 width=\"30%\"\u003e\n    \u003ch1 align=\"center\"\u003ePydiffuser\u003c/h1\u003e\n\u003c/p\u003e\n\n[![pypi](https://img.shields.io/badge/pypi-v0.0.3-blue)](https://pypi.org/project/pydiffuser/)\n[![python](https://img.shields.io/badge/python-3.10_|_3.11_|_3.12-blue)](https://pypi.org/project/pydiffuser/)\n[![doi](https://zenodo.org/badge/703392021.svg)](https://zenodo.org/doi/10.5281/zenodo.10017027)\n[![codecov](https://codecov.io/gh/jung235/pydiffuser/graph/badge.svg?token=UAT5VEBK0O)](https://codecov.io/gh/jung235/pydiffuser)\n[![ci](https://github.com/jung235/pydiffuser/actions/workflows/ci.yml/badge.svg)](https://github.com/jung235/pydiffuser/actions/workflows/ci.yml)\n[![docs](https://img.shields.io/badge/docs-dev-black)](https://github.com/jung235/pydiffuser/blob/main/README.md)\n[![status](https://img.shields.io/badge/status-alpha-blueviolet)](https://github.com/jung235/pydiffuser)\n\nPydiffuser is a numerical simulation framework for nonequilibrium statistical physics based on [JAX](https://github.com/google/jax).\n\nThis package mainly aims:\n- to share code to implement a numerical simulation on physical models written in various forms of [stochastic differential equations](https://en.wikipedia.org/wiki/Stochastic_differential_equation).\n- to revisit recent research highlights in nonequilibrium statistical physics.\n- to reduce the repeated code on time-series data analysis, e.g., statistical analysis of [single-particle trajectory](https://en.wikipedia.org/wiki/Single-particle_trajectory) for [SPT](https://en.wikipedia.org/wiki/Single-particle_tracking) experiments.\n- to provide the skeleton of stochastic modeling for anyone interested in stochastic processes.\n\n## Installation\n\n### Requirements\n\nPython 3.10+, [`jax\u003e=0.4.18`](https://pypi.org/project/jax/), and [`jaxlib\u003e=0.4.18`](https://pypi.org/project/jaxlib/).\n\n### From [PyPI](https://pypi.org/project/pydiffuser/)\n\n```console\n$ pip install pydiffuser\n```\n\nIf properly installed, you can run:\n\n```console\n$ pydiffuser --version\npydiffuser, version 0.0.3\n```\n\n## Quickstart\n\nPydiffuser provides various stochastic models that implement a numerical simulation based on the [Monte Carlo method](https://en.wikipedia.org/wiki/Monte_Carlo_method).\nAll Pydiffuser's models inherit an abstract class `pydiffuser.models.BaseDiffusion` and initiate the simulation after a method `generate` is called.\nFor the simplest case, you can produce a non-interacting [Brownian motion](https://en.wikipedia.org/wiki/Brownian_motion) at low Reynolds numbers as follows:\n\n```python\nfrom pydiffuser.models import BrownianMotion\nfrom pydiffuser.tracer import Ensemble, Trajectory\n\n\nmodel = BrownianMotion()\nensemble: Ensemble = model.generate()\ntracer: Trajectory = ensemble[0]  # the 0th particle\n```\n\nRelevant stochastic observables, such as [mean-squared displacement](https://en.wikipedia.org/wiki/Mean_squared_displacement) and normalized [velocity autocorrelation function](https://en.wikipedia.org/wiki/Autocorrelation), can be calculated through the [methods](#observables) of `Trajectory` and `Ensemble`.\n\n```python\ntamsd = tracer.get_mean_squared_displacement(lagtime=1, rolling=True)\neamsd = ensemble.get_mean_squared_displacement(lagtime=1, rolling=False)\neatamsd = ensemble.get_mean_squared_displacement(lagtime=1, rolling=True)\n```\n\nYou can visualize the trajectory using [matplotlib](https://github.com/matplotlib/matplotlib):\n\n\u003cp align=\"center\" width=\"100%\"\u003e\n    \u003cimg width=\"25%\" src=https://github.com/jung235/pydiffuser/assets/96967431/544f3d2f-1b51-46f6-8036-ee7f296fddad\u003e\n\u003c/p\u003e\n\nIt is obtained by `matplotlib.pyplot.plot(tracer.position_x1, tracer.position_x2)`.\n\n## CLI\n\nList all stochastic models supported by Pydiffuser.\n\n```console\n$ pydiffuser model list\nNAME            MODEL                           CONFIG                          DIMENSION       \nabp             ActiveBrownianParticle          ActiveBrownianParticleConfig    2d              \naoup            ActiveOUParticle                ActiveOUParticleConfig          1d, 2d, 3d      \nbm              BrownianMotion                  BrownianMotionConfig            1d, 2d, 3d      \nlevy            LevyWalk                        LevyWalkConfig                  1d, 2d, 3d      \nmips            PhaseSeparation                 PhaseSeparationConfig           1d, 2d, 3d      \nrtp             RunAndTumbleParticle            RunAndTumbleParticleConfig      1d, 2d, 3d      \nsmoluchowski    SmoluchowskiEquation            SmoluchowskiEquationConfig      1d, 2d          \nvicsek          VicsekModel                     VicsekModelConfig               2d              \n```\n\n## Features\n\n### How fast is it?\n\nWhen generating $N$ realizations consisting of $L$ footprints, we have:\n\n```julia\n═════════════════════════════════════════════════════════════════════════════════════════════════\nModel               Method              Running time [s] for N x L =                             \n                                        10² x 10⁵          10³ x 10⁴          10⁴ x 10³          \n─────────────────────────────────────────────────────────────────────────────────────────────────\n`loop` [*]                              3.62 (0.19)        3.45 (0.23)        3.37 (0.21)        \n─────────────────────────────────────────────────────────────────────────────────────────────────\n`abp`               `generate`          1.95 (0.14)        1.74 (0.12)        1.59 (0.11)        \n`aoup`              `generate`          1.61 (0.08)        1.61 (0.15)        1.55 (0.09)        \n`bm`                `generate`          1.45 (0.11)        1.46 (0.13)        1.46 (0.14)        \n`smoluchowski`      `generate`          1.71 (0.12)        1.67 (0.15)        1.64 (0.13)        \n─────────────────────────────────────────────────────────────────────────────────────────────────\n`bm`                `create`            1440.72 (158.16)   964.90 (83.06)     1195.41 (94.28)    \n═════════════════════════════════════════════════════════════════════════════════════════════════\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e[*]\u003c/summary\u003e\n\n```python\ndef loop(N: int, L: int) -\u003e float:\n    \"\"\"Even the most straightforward loop requires over 3 [s] for all (N, L) conditions.\n    \"\"\"\n\n    t1 = time.time()\n\n    xes = []\n    for _ in range(N):\n        x = []\n        for _ in range(1, L):\n            x.append([])\n        xes.append(x)\n\n    t2 = time.time()\n    return t2 - t1\n```\n\u003c/details\u003e\n\nThe represented running time is a mean $\\mu$ (standard deviation $\\sigma$) of five trials.\n\n### Observables\n\n*class* `pydiffuser.tracer.Trajectory` ∈ *class* `pydiffuser.tracer.Ensemble`\n\n- `get_increments`\n- `get_displacement_moment`\n- `get_mean_squared_displacement`\n- `get_cosine_moment`\n- `get_velocity_autocorrelation`\n- `get_real_time`\n\nThe above methods are defined in both `Trajectory` and `Ensemble` to enhance transparency.\nUsing `Trajectory`, the statistical analysis of [single-particle trajectory](https://en.wikipedia.org/wiki/Single-particle_trajectory) can be accelerated.\n\n### Configuration\n\nWe introduce a configuration to deal with extensive parameter manipulation.\nFor instance, see [`config.json`](https://github.com/jung235/pydiffuser/blob/main/docs/features/configs/config.json), which contains all parameters demanded to instantiate `pydiffuser.ActiveBrownianParticle`.\nEvery JSON of the configurations listed in [CLI](#cli) can be obtained as follows:\n\n```python\nimport pydiffuser as pyd\nfrom pydiffuser.models import ActiveBrownianParticle, ActiveBrownianParticleConfig\n\n\nconfig = ActiveBrownianParticleConfig()\nconfig.to_json(json_path=\u003cJSON_PATH\u003e)\n```\n\nWe suggest a research pipeline:\n\n```python\n┌────┐     ┌─────────────────────┐     ┌───────────────┐     ┌──────────┐     ┌────────────┐\n│JSON├──\u003e──┤`BaseDiffusionConfig`├──\u003e──┤`BaseDiffusion`├──\u003e──┤`Ensemble`├──\u003e──┤NPY | PICKLE│\n└────┘ [1] └─────────────────────┘ [2] └───────────────┘ [3] └──────────┘ [4] └────────────┘\n```\n\nIt can be automized as follows:\n\n```python\nconfig = ActiveBrownianParticleConfig.from_json(json_path=\u003cJSON_PATH\u003e)  # [1]\nmodel = ActiveBrownianParticle.from_config(config=config)  # [2]\nensemble = model.generate()  # [3]\nensemble.to_npy(npy_path=\u003cNPY_PATH\u003e)  # [4]\n```\n\nYou can save and load any picklable object through `pydiffuser.save` and `pydiffuser.load`.\n\n```python\nMODEL_PATH = \"model.pickle\"\n\n\npyd.save(obj=model, pickle_path=MODEL_PATH)  # Here, \u003cPICKLE_PATH\u003e = MODEL_PATH\nmodel = pyd.load(pickle_path=MODEL_PATH)\n```\n\n## Related Works\n\n[Hyperdiffusion of Poissonian run-and-tumble particles in two dimensions](https://arxiv.org/abs/2308.00554)\n\n## License\n\n[Apache License 2.0](https://github.com/jung235/pydiffuser/blob/main/LICENSE)\n\n## Citation\n\n```bibtex\n@misc{jung2023pydiffuser,\n  title = {Pydiffuser: a simulation framework for nonequilibrium statistical physics},\n  author = {Jung, Yurim},\n  year = {2023},\n  note = {doi: 10.5281/zenodo.10017027},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjung235%2Fpydiffuser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjung235%2Fpydiffuser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjung235%2Fpydiffuser/lists"}