{"id":34170887,"url":"https://github.com/analysiscenter/pydens","last_synced_at":"2025-12-15T11:03:18.097Z","repository":{"id":35079568,"uuid":"197198102","full_name":"analysiscenter/pydens","owner":"analysiscenter","description":"PyDEns is a framework for solving Ordinary and Partial Differential Equations (ODEs \u0026 PDEs) using neural networks","archived":false,"fork":false,"pushed_at":"2024-02-09T09:55:29.000Z","size":24992,"stargazers_count":312,"open_issues_count":13,"forks_count":67,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-11-14T07:22:21.391Z","etag":null,"topics":["deep-learning","differential-equations","neural-networks","numerical-methods","ode","ode-solver","partial-differential-equations","pde-solver","solving-pdes"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/analysiscenter.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}},"created_at":"2019-07-16T13:20:34.000Z","updated_at":"2025-11-11T15:23:42.000Z","dependencies_parsed_at":"2022-07-21T15:03:09.204Z","dependency_job_id":null,"html_url":"https://github.com/analysiscenter/pydens","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/analysiscenter/pydens","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analysiscenter%2Fpydens","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analysiscenter%2Fpydens/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analysiscenter%2Fpydens/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analysiscenter%2Fpydens/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/analysiscenter","download_url":"https://codeload.github.com/analysiscenter/pydens/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/analysiscenter%2Fpydens/sbom","scorecard":{"id":191067,"data":{"date":"2025-08-11","repo":{"name":"github.com/analysiscenter/pydens","commit":"748175c4e77d407a5dc593d2f104ce6edddc3126"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/8 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/status.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/analysiscenter/pydens/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/status.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/analysiscenter/pydens/status.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/status.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/analysiscenter/pydens/status.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/status.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/analysiscenter/pydens/status.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/release.yml:24","Warn: pipCommand not pinned by hash: .github/workflows/status.yml:19","Warn: pipCommand not pinned by hash: .github/workflows/status.yml:22","Warn: pipCommand not pinned by hash: .github/workflows/status.yml:25","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   4 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T20:41:03.200Z","repository_id":35079568,"created_at":"2025-08-16T20:41:03.200Z","updated_at":"2025-08-16T20:41:03.200Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27749823,"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","status":"online","status_checked_at":"2025-12-15T02:00:09.782Z","response_time":96,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["deep-learning","differential-equations","neural-networks","numerical-methods","ode","ode-solver","partial-differential-equations","pde-solver","solving-pdes"],"created_at":"2025-12-15T11:03:17.043Z","updated_at":"2025-12-15T11:03:18.089Z","avatar_url":"https://github.com/analysiscenter.png","language":"Jupyter Notebook","readme":"[![License](https://img.shields.io/github/license/analysiscenter/pydens.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n[![Python](https://img.shields.io/badge/python-3.8-blue.svg)](https://python.org)\n[![PyTorch](https://img.shields.io/badge/PyTorch-1.7-orange.svg)](https://pytorch.org)\n\n\n# PyDEns\n\n**PyDEns** is a framework for solving Ordinary and Partial Differential Equations (ODEs \u0026 PDEs) using neural networks. With **PyDEns** one can solve\n - PDEs \u0026 ODEs from a large family including [heat-equation](https://en.wikipedia.org/wiki/Heat_equation), [poisson equation](https://en.wikipedia.org/wiki/Poisson%27s_equation) and [wave-equation](https://en.wikipedia.org/wiki/Wave_equation)\n - parametric families of PDEs\n - PDEs with trainable coefficients.\n\nThis page outlines main capabilities of **PyDEns**. To get an in-depth understanding we suggest you to also read [the tutorial](https://github.com/analysiscenter/pydens/blob/master/tutorials/1.%20Solving%20PDEs.ipynb).\n\n## Getting started with **PyDEns**: solving common PDEs\nLet's solve poisson equation\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/analysiscenter/pydens/master/imgs/poisson_eq.png?invert_in_darkmode\" align=middle width=621.3306pt height=38.973825pt/\u003e\n\u003c/p\u003e\n\n\nusing simple feed-forward neural network. Let's start by importing `Solver`-class along with other needed libraries:\n\n```python\nfrom pydens import Solver, NumpySampler\nimport numpy as np\nimport torch\n\n```\n\nYou can now set up a **PyDEns**-model for solving the task at hand. For this you need to supply the equation into a `Solver`-instance. Note the use of differentiation token `D`:\n\n```python\n# Define the equation as a callable.\ndef pde(f, x, y):\n    return D(D(f, x), x) + D(D(f, y), y) - 5 * torch.sin(np.pi * (x + y))\n\n# Supply the equation, initial condition, the number of variables (`ndims`)\n# and the configration of neural network in Solver-instance.\nsolver = Solver(equation=pde, ndims=2, boundary_condition=1,\n                layout='fa fa fa f', activation='Tanh', units=[10, 12, 15, 1])\n\n```\n\nNote that we defined the architecture of the neural network by supplying `layout`, `activation` and `units` parameters. Here `layout` configures the sequence of layers: `fa fa fa f` stands for `f`ully connected architecture with four layers and three `a`ctivations. In its turn, `units` and `activation` cotrol the number of units in dense layers and activation-function. When defining neural network this way use [`ConvBlock`](https://analysiscenter.github.io/batchflow/api/batchflow.models.torch.layers.html?highlight=baseconvblock#batchflow.models.torch.layers.BaseConvBlock) from [`BatchFlow`](https://github.com/analysiscenter/batchflow).\n\nIt's time to run the optimization procedure\n\n```python\nsolver.fit(batch_size=100, niters=1500)\n```\nin a fraction of second we've got a mesh-free approximation of the solution on **[0, 1]X[0, 1]**-square:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/analysiscenter/pydens/master/imgs/poisson_sol.png?invert_in_darkmode\" align=middle height=350.973825pt/\u003e\n\u003c/p\u003e\n\n## Going deeper into **PyDEns**-capabilities\n**PyDEns** allows to do much more than just solve common PDEs: it also deals with (i) parametric families of PDEs and (ii) PDEs with trainable coefficients.\n\n### Solving parametric families of PDEs\nConsider a *family* of ordinary differential equations\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/analysiscenter/pydens/master/imgs/sinus_eq.png?invert_in_darkmode\" align=middle height=40.973825pt/\u003e\n\u003c/p\u003e\n\nClearly, the solution is a **sin** wave with a phase parametrized by ϵ:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/analysiscenter/pydens/master/imgs/sinus_sol_expr.png?invert_in_darkmode\" align=middle height=18.973825pt/\u003e\n\u003c/p\u003e\n\nSolving this problem is just as easy as solving common PDEs. You only need to introduce parameter `e` in the equation and supply the number of parameters (`nparams`) into a `Solver`-instance:\n\n```python\ndef odeparam(f, x, e):\n    return D(f, x) - e * np.pi * torch.cos(e * np.pi * x)\n\n# One for argument, one for parameter\ns = NumpySampler('uniform') \u0026 NumpySampler('uniform', low=1, high=5)\n\nsolver = Solver(equation=odeparam, ndims=1, nparams=1, initial_condition=1)\nsolver.fit(batch_size=1000, sampler=s, niters=5000, lr=0.01)\n# solving the whole family takes no more than a couple of seconds!\n```\n\nCheck out the result:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/analysiscenter/pydens/master/imgs/sinus_parametric.gif?invert_in_darkmode\" align=middle height=250.973825pt/\u003e\n\u003c/p\u003e\n\n### Solving PDEs with trainable coefficients\n\nWith **PyDEns** things can get even more interesting! Assume that the *initial state of the system is unknown and yet to be determined*:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/analysiscenter/pydens/master/imgs/sinus_eq_trainable.png?invert_in_darkmode\" align=middle height=40.973825pt/\u003e\n\u003c/p\u003e\n\nOf course, without additional information, [the problem is undefined](https://en.wikipedia.org/wiki/Initial_value_problem). To make things better, let's fix the state of the system at some other point:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/analysiscenter/pydens/master/imgs/sinus_eq_middle_fix.png?invert_in_darkmode\" align=middle height=18.973825pt/\u003e\n\u003c/p\u003e\n\nSetting this problem requires a [slightly more complex configuring](https://github.com/analysiscenter/pydens/blob/master/tutorials/PDE_solving.ipynb). Note the use of `V`-token, that stands for trainable variable, in the initial condition of the problem. Also pay attention to the additional constraint supplied into the `Solver` instance. This constraint binds the final solution to zero at `t=0.5`:\n\n```python\ndef odevar(u, t):\n    return D(u, t) - 2 * np.pi * torch.cos(2 * np.pi * t)\ndef initial(*args):\n    return V('init', data=torch.Tensor([3.0]))\n\nsolver = Solver(odevar, ndims=1, initial_condition=initial,\n                constraints=lambda u, t: u(torch.tensor([0.5])))\n```\nWhen tackling this problem, `pydens` will not only solve the equation, but also adjust the variable (initial condition) to satisfy the additional constraint.\nHence, model-fitting comes in two parts now: (i) solving the equation and (ii) adjusting initial condition to satisfy the additional constraint. Inbetween\nthe steps we need to freeze layers of the network to adjust only the adjustable variable:\n\n```python\nsolver.fit(batch_size=150, niters=100, lr=0.05)\nsolver.model.freeze_layers(['fc1', 'fc2', 'fc3'], ['log_scale'])\nsolver.fit(batch_size=150, niters=100, lr=0.05)\n```\n\nCheck out the results:\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/analysiscenter/pydens/master/imgs/converging_sol.gif?invert_in_darkmode\" align=middle height=250.973825pt/\u003e\n\u003c/p\u003e\n\n## Installation\n\nFirst of all, you have to manually install [pytorch](https://pytorch.org/get-started/locally/),\nas you might need a certain version or a specific build for CPU / GPU.\n\n### Stable python package\n\nWith modern [pipenv](https://docs.pipenv.org/)\n```\npipenv install pydens\n```\n\nWith old-fashioned [pip](https://pip.pypa.io/en/stable/)\n```\npip3 install pydens\n```\n\n### Development version\n\n```\npipenv install git+https://github.com/analysiscenter/pydens.git\n```\n\n```\npip3 install git+https://github.com/analysiscenter/pydens.git\n```\n\n### Installation as a project repository:\n\nDo not forget to use the flag ``--recursive`` to make sure that ``BatchFlow`` submodule is also cloned.\n\n```\ngit clone --recursive https://github.com/analysiscenter/pydens.git\n```\n\nIn this case you need to manually install the dependencies.\n\n\n## Citing PyDEns\n\nPlease cite **PyDEns** if it helps your research.\n\n```\nRoman Khudorozhkov, Sergey Tsimfer, Alexander Koryagin. PyDEns framework for solving differential equations with deep learning. 2019.\n```\n\n```\n@misc{pydens_2019,\n  author       = {Khudorozhkov R. and Tsimfer S. and Koryagin. A.},\n  title        = {PyDEns framework for solving differential equations with deep learning},\n  year         = 2019\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanalysiscenter%2Fpydens","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanalysiscenter%2Fpydens","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanalysiscenter%2Fpydens/lists"}