{"id":17352377,"url":"https://github.com/maroba/numgrids","last_synced_at":"2025-06-11T07:32:00.065Z","repository":{"id":177477601,"uuid":"519236322","full_name":"maroba/numgrids","owner":"maroba","description":"Working with numerical grids made easy.","archived":false,"fork":false,"pushed_at":"2023-07-07T13:45:07.000Z","size":1236,"stargazers_count":10,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-14T21:32:28.525Z","etag":null,"topics":["numerical-methods","scientific-computing","spectral-methods"],"latest_commit_sha":null,"homepage":"","language":"Python","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/maroba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-07-29T14:03:14.000Z","updated_at":"2024-12-01T04:39:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"f9655ca5-de1a-4fe0-99a3-e04c767cb530","html_url":"https://github.com/maroba/numgrids","commit_stats":{"total_commits":96,"total_committers":2,"mean_commits":48.0,"dds":0.03125,"last_synced_commit":"13c525f73f0788f67eec38d8b23d263ed64f868c"},"previous_names":["maroba/numgrids"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maroba%2Fnumgrids","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maroba%2Fnumgrids/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maroba%2Fnumgrids/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maroba%2Fnumgrids/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maroba","download_url":"https://codeload.github.com/maroba/numgrids/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maroba%2Fnumgrids/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259221888,"owners_count":22823979,"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":["numerical-methods","scientific-computing","spectral-methods"],"created_at":"2024-10-15T17:13:38.579Z","updated_at":"2025-06-11T07:32:00.040Z","avatar_url":"https://github.com/maroba.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003enumgrids\u003c/h1\u003e\n\u003cp align=\"center\"\u003e Working with numerical grids made easy. \u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://badge.fury.io/py/numgrids\"\u003e \u003cimg src=\"https://badge.fury.io/py/numgrids.svg?branch=main\u0026kill_cache=1\" alt=\"PyPI version\"\u003e\u003c/a\u003e \u003ca href=\"\"\u003e \u003cimg src=\"https://github.com/maroba/numgrids/actions/workflows/checks.yml/badge.svg\" alt=\"build\"\u003e\u003c/a\u003e\u003ca href=\"https://codecov.io/gh/maroba/numgrids\"\u003e \u003cimg src=\"https://codecov.io/gh/maroba/numgrids/branch/main/graph/badge.svg?token=JNH9SP7BRG\" alt=\"\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n  \u003cdiv align=\"center\"\u003e\u003cimg src=\"docs/assets/torus.png\" width=\"25%\"\u003e  \u003cimg src=\"docs/assets/disk320.png\" width=\"25%\"\u003e \u003cimg src=\"docs/assets/cubic.png\" width=\"25%\"\u003e\u003c/div\u003e\n\n**Main Features**\n\n- Quickly define numerical grids for any rectangular or curvilinear coordinate system\n- Differentiation and integration\n- Interpolation\n- Easy manipulation of meshed functions\n- Using high precision spectral methods (FFT + Chebyshev) wherever possible\n- Includes multigrid functionality\n- Fully compatible with *numpy*\n\n## Installation\n\n```shell\npip install --upgrade numgrids\n```\n\n## Quick Start\n\nAs a quick example, here is how you define a grid on the unit disk using polar coordinates.\nAlong the azimuthal (angular) direction, choose an equidistant spacing with periodic boundary conditions:\n\n```python\nfrom numgrids import *\nfrom numpy import pi\n\naxis_phi = Axis(AxisType.EQUIDISTANT, 50, 0, 2*pi, periodic=True)\n```\n\n\u003cimg src=\"docs/assets/equi_periodic.png\" height=\"326\"\u003e\n\nAlong the radial axis, let's choose a non-equidistant spacing:\n\n```python\naxis_radial = Axis(AxisType.CHEBYSHEV, 20, 0, 1)\n```\n\n\u003cimg src=\"docs/assets/cheby.png\" height=\"91\"\u003e\n\nNow combine the axes to a **grid**:\n\n```python\ngrid = Grid(axis_radial, axis_phi)\n```\n\u003cimg src=\"docs/assets/disk320.png\"\u003e\n\n**Sample** a meshed function on this grid:\n\n```python\nfrom numpy import exp, sin\n\nR, Phi = grid.meshed_coords\nf = R**2 * sin(Phi)**2\n```\nDefine **partial derivatives** $\\partial/\\partial r$ and $\\partial/\\partial \\varphi$ and apply them:\n\n```python\n# second argument means derivative order, third argument means axis index:\nd_dr = Diff(grid, 1, 0) \nd_dphi = Diff(grid, 1, 1)\n\ndf_dr = d_dr(f)\ndf_dphi = d_dphi(f)\n```\n\nObtain the **matrix representation** of the differential operators:\n\n```python\nd_dr.as_matrix()\n\nOut: \u003c1000x1000 sparse matrix of type '\u003cclass 'numpy.float64'\u003e'\n\twith 20000 stored elements in COOrdinate format\u003e\n```\n\n\nDefine **integration operator**\n\n$$\n\\int \\dots dr d\\varphi\n$$\n\n```python\nI = Integral(grid)\n```\n\nCalculate the area integral\n\n$$\n\\int f(r, \\varphi) r dr d\\varphi\n$$\n\n(taking into account the appropriate integration measure  $r$  for polar coordinates):\n\n```python\nI(f * R)\n```\n\nSetting **boundary** values to zero\n\n```python\nf[grid.boundary] = 0  # grid.boundary is boolean mask selecting boundary grid points\n```\n\nor to something more complicated:\n\n```python\nf[grid.boundary] = exp(-R[grid.boundary])\n```\n\nCreate an **interpolation function**\n\n```python\ninter = Interpolator(grid, f)\n```\n\nInterpolate for a single point\n\n```python\npoint = (0.1, 0.5)\ninter(point)\n```\n\nor for many points at once, like for a parametrized curve:\n\n```python\nt = np.linspace(0, 1, 100)\npoints = zip(2*t, t**2)\ninter(points)\n```\n\n\n## Usage / Example Notebooks\n\nTo get an idea how *numgrids* can be used, have a look at the following example notebooks:\n\n- [How to define grids](examples/how-to-define-grids.ipynb)\n- [Partial derivatives in any dimension](examples/partial-derivatives.ipynb)\n- [Polar coordinates on unit disk](examples/polar-cooordinates-on-unit-disk.ipynb)\n- [Spherical Grid and the Spherical Laplacian](examples/spherical-grid.ipynb)\n- [Solving the Schrödinger equation for the quantum harmonic oscillator](examples/quantum-harmonic-oscillator.ipynb)\n\n## Development\n\n### Setting up the project\n\nClone the repository\n\n```\ngit clone https://github.com/maroba/numgrids.git\n```\n\nIn the project root directory, submit\n\n```\npython setup.py develop\n```\n\nto install the package in development mode.\n\nRun the tests:\n\n```\npython -m unittest discover tests\n```\n\n### Contributing\n\n1. Fork the repository\n2. Develop\n3. Write tests!\n4. Create an [issue](https://github.com/maroba/numgrids/issues)\n5. Create a pull request, when done\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaroba%2Fnumgrids","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaroba%2Fnumgrids","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaroba%2Fnumgrids/lists"}