{"id":22215724,"url":"https://github.com/jobovy/wendy","last_synced_at":"2025-09-06T19:32:09.301Z","repository":{"id":42789527,"uuid":"89278023","full_name":"jobovy/wendy","owner":"jobovy","description":"A one-dimensional gravitational N-body code","archived":false,"fork":false,"pushed_at":"2024-02-05T18:19:45.000Z","size":21478,"stargazers_count":19,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-30T04:52:52.793Z","etag":null,"topics":["astrophysics","binder","c","n-body","n-body-simulator","physics","python"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jobovy.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-24T19:15:51.000Z","updated_at":"2024-06-03T16:01:20.000Z","dependencies_parsed_at":"2023-01-29T22:30:34.052Z","dependency_job_id":null,"html_url":"https://github.com/jobovy/wendy","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jobovy%2Fwendy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jobovy%2Fwendy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jobovy%2Fwendy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jobovy%2Fwendy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jobovy","download_url":"https://codeload.github.com/jobovy/wendy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232140230,"owners_count":18478222,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["astrophysics","binder","c","n-body","n-body-simulator","physics","python"],"created_at":"2024-12-02T21:42:34.594Z","updated_at":"2025-01-02T00:55:51.889Z","avatar_url":"https://github.com/jobovy.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wendy\n\nA one-dimensional gravitational N-body code. \n\n[![Build Status](https://github.com/jobovy/wendy/workflows/build/badge.svg)](https://github.com/jobovy/wendy/actions?query=workflow%3Abuild)\n[![Coverage Status](https://codecov.io/gh/jobovy/wendy/branch/main/graph/badge.svg)](https://codecov.io/gh/jobovy/wendy)\n[![image](http://img.shields.io/pypi/v/wendy.svg)](https://pypi.python.org/pypi/wendy/)\n[![Binder](http://mybinder.org/badge.svg)](http://beta.mybinder.org/repo/jobovy/wendy)\n\n## Overview\n\n``wendy`` solves the one-dimensional gravitational N-body problem to machine precision with an efficient algorithm [O(log N) / particle-collision]. Alternatively, it can solve the problem with approximate integration, but with exact forces.\n\n## Author\n\nJo Bovy (University of Toronto): bovy - at - astro - dot - utoronto - dot - ca\n\n## Installation\n\nInstall the latest release using\n```\npip install wendy\n```\nor clone/fork/download the repository and install using\n```\nsudo python setup.py install\n```\nor locally using\n```\npython setup.py install --user\n```\n\nThe behavior of the parallel sorting algorithm used when setting ``sort='parallel'`` in the approximate version of the N-body code (``approx=True``) is controlled by a few compilation-time variables: ``PARALLEL_SERIAL_SORT_SWITCH``, which sets the length of an array below which the serial sort is used, ``PARALLEL_SERIAL_MERGE_SWITCH``, which sets the length of an array below which a serial merge is used (as part of the ``mergesort`` sorting algorithm used), and ``PARALLEL_SORT_NUM_THREADS``, the number of threads used in the parallel sorting algorithm. By default, these are set to ``PARALLEL_SERIAL_MERGE_SWITCH=10000``, ``PARALLEL_SERIAL_MERGE_SWITCH=50000``, and ``PARALLEL_SORT_NUM_THREADS=32``, which appear to work well. Significant speed-ups can be obtained by optimizing these for your system and specific problem. They can be set to different values by running, e.g.,\n```\nexport CFLAGS=\"$CFLAGS -D PARALLEL_SERIAL_SORT_SWITCH=10 -D PARALLEL_SERIAL_MERGE_SWITCH=10 -D PARALLEL_SORT_NUM_THREADS=2\"\n```\nbefore compiling the code (if you are trying to change them, make sure to force a re-compilation by removing the ``build/`` directory).\n\n## Usage\n\nUse ``wendy.nbody`` to initialize a generator object for initial *(x,v)* with masses *m*. The generator then returns the state of the system at equally-spaced time intervals:\n```\ng= wendy.nbody(x,v,m,0.05) # delta t = 0.05\nnext_x, next_v= next(g) # at t=0.05\nnext_x, next_v= next(g) # at t=0.10\n...\n```\nThe generator initialization with ``wendy.nbody`` has options to (a) solve the problem exactly or not using ``approx=``, (b) include an external harmonic oscillator potential ``omega^2 x^2 / 2`` with ``omega=`` (both for exact and approximate solutions), and (c) include an arbitrary external force ``F(x,t)`` (using ``ext_force=``, only for the approximate solution).\n\n## Examples\n\nYou can run these *without* installing ``wendy`` by clicking on [![Binder](http://mybinder.org/badge.svg)](http://beta.mybinder.org/repo/jobovy/wendy) and navigating to the ``examples/`` directory. Note that some of the movies might fail to be rendered on the binder webpage, so you might want to skip those when running the notebooks (or changing the ``subsamp`` input for them).\n\n* Phase mixing and violent relaxation in one dimension: [example notebook](examples/PhaseMixingViolentRelaxation.ipynb) (run locally to see movies, or view on [nbviewer](http://nbviewer.jupyter.org/github/jobovy/wendy/blob/main/examples/PhaseMixingViolentRelaxation.ipynb?flush_cache=true))\n\n\u003cimg src=\"https://cloud.githubusercontent.com/assets/1044876/26030657/e29c9efe-3826-11e7-8419-7bf96d565569.gif\" width=\"400\"\u003e\u003cimg src=\"https://cloud.githubusercontent.com/assets/1044876/26030672/1fafa9bc-3827-11e7-9167-16f10bb40b59.gif\" width=\"400\"\u003e\n\n* A self-gravitating, sech\u003csup\u003e2\u003c/sup\u003e disk: [example notebook](examples/SelfGravitatingSech2Disk.ipynb) (run locally to see movies, or view on [nbviewer](http://nbviewer.jupyter.org/github/jobovy/wendy/blob/main/examples/SelfGravitatingSech2Disk.ipynb?flush_cache=true))\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1044876/26942002-7dce9644-4c4e-11e7-90d0-43beddfd0dd9.gif\" width=\"400\"\u003e\u003cimg src=\"https://cloud.githubusercontent.com/assets/1044876/26089414/850dd7a2-39cb-11e7-9beb-73dbce2c6c4b.gif\" width=\"400\"\u003e\n\n* The _Gaia_ phase-space spiral: [example notebook](examples/GaiaPhaseSpaceSpiral.ipynb) (run locally to see movies, or view on [nbviewer](http://nbviewer.jupyter.org/github/jobovy/wendy/blob/main/examples/GaiaPhaseSpaceSpiral.ipynb?flush_cache=true))\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1044876/63739608-d5705a00-c85b-11e9-9e75-fbe106294331.gif\" width=\"400\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/1044876/63739620-e28d4900-c85b-11e9-88d9-ee284bd7ad83.gif\" width=\"400\"\u003e\n\n* Adiabatic contraction: [example notebook](examples/AdiabaticContraction.ipynb) (run locally to see movies, or view on [nbviewer](http://nbviewer.jupyter.org/github/jobovy/wendy/blob/main/examples/AdiabaticContraction.ipynb?flush_cache=true))\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1044876/26941638-2b4eed8e-4c4d-11e7-9804-a63b681b86e6.gif\" width=\"400\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/1044876/26941809-d7393b22-4c4d-11e7-97dd-cd3b259aefa7.gif\" width=\"400\"\u003e\n\n* Adiabatic vs. non-adiabatic energy injection for an exponential disk: [example notebook](examples/AdiabaticVsNonAdiabatic.ipynb) (run locally to see movies, or view on [nbviewer](http://nbviewer.jupyter.org/github/jobovy/wendy/blob/main/examples/AdiabaticVsNonAdiabatic.ipynb?flush_cache=true))\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1044876/27014815-3d5fe2de-4ece-11e7-953f-ced11d4993d2.gif\" width=\"400\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/1044876/27014825-648498f0-4ece-11e7-8360-cf1f04e13cba.gif\" width=\"400\"\u003e\n\n* ``wendy`` scaling with particle number: [example notebook](examples/WendyScaling.ipynb) (view on [nbviewer](http://nbviewer.jupyter.org/github/jobovy/wendy/blob/main/examples/WendyScaling.ipynb?flush_cache=true))\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjobovy%2Fwendy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjobovy%2Fwendy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjobovy%2Fwendy/lists"}