{"id":18427199,"url":"https://github.com/fjebaker/zigularity","last_synced_at":"2025-06-29T13:02:11.980Z","repository":{"id":124945947,"uuid":"538284810","full_name":"fjebaker/zigularity","owner":"fjebaker","description":"Itsy-bitsy-teeny-weeny-black-hole-visualisation-machiney.","archived":false,"fork":false,"pushed_at":"2022-09-19T16:22:25.000Z","size":979,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-25T00:59:31.418Z","etag":null,"topics":["black-holes","general-relativity","ray-tracing","relativity","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/fjebaker.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":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-09-19T00:58:00.000Z","updated_at":"2024-05-29T09:00:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"9f36a62f-3350-4e7f-b59e-2f3cf657a5f4","html_url":"https://github.com/fjebaker/zigularity","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fjebaker/zigularity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjebaker%2Fzigularity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjebaker%2Fzigularity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjebaker%2Fzigularity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjebaker%2Fzigularity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fjebaker","download_url":"https://codeload.github.com/fjebaker/zigularity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fjebaker%2Fzigularity/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262598137,"owners_count":23334665,"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":["black-holes","general-relativity","ray-tracing","relativity","zig"],"created_at":"2024-11-06T05:09:54.101Z","updated_at":"2025-06-29T13:02:11.851Z","avatar_url":"https://github.com/fjebaker.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zigularity\n\n\u003cp align=\"center\"\u003e\n    \u003ci\u003eItsy-bitsy-teeny-weeny-black-hole-visualisation-machiney\u003c/i\u003e\n\u003c/p\u003e\n\nA little long weekend project: relativistic ray tracing in Zig, visualizing thin accretion discs around a Kerr black hole with a handful of configurable parameters:\n\n- observer position\n- disc inner and outer radius\n- black hole mass and spin\n\n```bash\ngit clone https://github.com/fjebaker/zigularity\ncd zigularity\nzigmod fetch\nzig build -Drelease-fast\n```\n\nDefault is to try and calculate the coordinate-time of each traced photon (pixel) -- darker colours indicate things further away to give a slight semblance of three-dimensionality. The program should output something similar to this:\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./assets/thin-disc-example.png\" alt=\"thin-disc-example\" style=\"max-height:300px;\"\u003e\n\u003c/p\u003e\n\nThe program will write the output to a plain-text file `\"disc.data\"`, which may be plotted with your plotting package of choice. As an example, here is a little bit of Python:\n\n```py\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nwith open(\"disc.data\") as f:\n    data = f.read()\n\nimage = []\nfor line in data.split(\"\\n\"):\n    row = line.split(\",\")[:-1]\n    if row:\n        image.append(row)\n\nimg = np.array(image, dtype=float)\n\nplt.imshow(\n    img.transpose(), \n    # only want to color close to the black hole\n    vmin = 900, \n    vmax = 1100,\n    cmap = \"Greys\"\n)\nplt.show()\n```\n\nIt can also be used to calculate the so-called _shadow_ of a black hole, which traces the apparent shape of the event horizon:\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./assets/kerr-shadow.png\" alt=\"shadow-spinning\" height=\"300\"\u003e\n\u003c/p\u003e\n\nOr for a non-spinning black hole:\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./assets/schwarzschild-shadow.png\" alt=\"shadow-non-spinning\" height=\"300\"\u003e\n\u003c/p\u003e\n\n\n## Todo\n\n- [ ] fix bad pixels bugs\n- [ ] _severely_ clean and refactor the code\n- [ ] interpolate on integrator callback to smoothen the disc\n- [ ] ~~(stretch) multi-threading cus it's a wee bit slow~~ Not available on self-hosted Zig compiler yet.\n\n## Dependencies\n\nRequires [nektro/zigmod](https://github.com/nektro/zigmod) to install dependencies:\n\n- [fjebaker/zigode](https://github.com/fjebaker/zigode)\n\n\n## About\n\nI write relativistic ray tracing codes as part of my research, feel free to [take a look](https://github.com/astro-group-bristol/Gradus.jl) (~:\n\nRelativistic ray-tracing is similar to regular ray-tracing, except that the trajectory of light may be altered due to the locally curved spacetime under strong gravity (see [gravitional lensing](https://en.wikipedia.org/wiki/Gravitational_lens)). The trajectories may be traced by solving the [geodesic equation](https://en.wikipedia.org/wiki/Solving_the_geodesic_equations) -- a 2nd order ODE system which can be quite stiff -- however certain formulations of curved space permit a 1st order set of equations.\n\nOne such spacetime is the spacetime of the [Kerr metric](https://en.wikipedia.org/wiki/Kerr_metric), describing a black hole with angular momentum. This metric is parameterised by a black hole mass $M$ and spin $a$, and is axis-symmetric about the spin axis and unchanging with time.\n\nThis code implements equations from [Bardeen et al. (1972)](https://ui.adsabs.harvard.edu/link_gateway/1972ApJ...178..347B/ARTICLE) and [Fanton et al. (1997)](https://www.researchgate.net/publication/234370864_Detecting_Accretion_Disks_in_Active_Galactic_Nuclei) to construct the 1st order equations, and integrates them using a simple adaptive Runge-Kutta algorithm.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjebaker%2Fzigularity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffjebaker%2Fzigularity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffjebaker%2Fzigularity/lists"}