{"id":23919590,"url":"https://github.com/martinjrobins/diffsol_python_benchmark","last_synced_at":"2025-10-15T03:27:26.971Z","repository":{"id":267923393,"uuid":"902028489","full_name":"martinjrobins/diffsol_python_benchmark","owner":"martinjrobins","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-13T08:37:12.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-12T18:29:05.893Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/martinjrobins.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2024-12-11T19:08:01.000Z","updated_at":"2024-12-13T08:37:16.000Z","dependencies_parsed_at":"2024-12-13T09:29:18.182Z","dependency_job_id":null,"html_url":"https://github.com/martinjrobins/diffsol_python_benchmark","commit_stats":null,"previous_names":["martinjrobins/diffsol_python_benchmark"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/martinjrobins/diffsol_python_benchmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinjrobins%2Fdiffsol_python_benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinjrobins%2Fdiffsol_python_benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinjrobins%2Fdiffsol_python_benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinjrobins%2Fdiffsol_python_benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/martinjrobins","download_url":"https://codeload.github.com/martinjrobins/diffsol_python_benchmark/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/martinjrobins%2Fdiffsol_python_benchmark/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279042706,"owners_count":26091310,"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-10-15T02:00:07.814Z","response_time":56,"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":[],"created_at":"2025-01-05T14:53:45.999Z","updated_at":"2025-10-15T03:27:26.941Z","avatar_url":"https://github.com/martinjrobins.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DiffSol Python Benchmark\n\nThis package provides a set of benchmarks to compare the performance of different solvers in Python against the [DiffSol](https://github.com/martinjrobins/diffsol) solver.\n\n## Installation\n\nTo install the package from PyPI, run the following command:\n\n```bash\npip install diffsol_python_benchmark\n```\n\n## Usage\n\n### Casadi\n\nTODO\n\n### Scipy\n\nTODO\n\n### Diffrax\n\nTODO\n\n### PyBaMM\n\nThis is a demonstration of how to use [DiffSol](https://github.com/martinjrobins/diffsol) to solve a [PyBaMM](https://github.com/pybamm-team/PyBaMM/) model.\n\nUse the following code to solve an PyBaMM SPM model using DiffSol and PyBaMM and compare the timings. You can change the outputs and inputs to any other parameters/variables in the model.\n\nNote that this is only a demonstration and is only tested with the SPM model. It may not work with other models.\n\n```python\nfrom pybamm_diffsol import PybammDiffsol, Pybamm2Diffsl\nimport numpy as np\nimport timeit\nimport pybamm\n\noutputs = [\"Voltage [V]\"]\ninputs = [\"Current function [A]\"]\n\n# read model from spm.ds file to a string\nmodel_str = Pybamm2Diffsl(pybamm.lithium_ion.SPM()).to_str(inputs, outputs)\nmodel = PybammDiffsol(model_str)\nt_eval = np.array([0.0, 3600.0])\nt_interp = np.linspace(0.0, 3600.0, 100)\nparams = np.array([1.0])\nn = 1000\n\n\ndef diffsol_bench():\n    model.solve(params, t_interp, t_eval)\n\n\ndiffsol_time = timeit.timeit(diffsol_bench, number=n) / n\nprint(\"Diffsol time: \", diffsol_time)\n\n# solver pybamm spm model\nspm = pybamm.lithium_ion.SPM()\nt_eval = np.array([0.0, 3600.0])\nt_interp = np.linspace(0.0, 3600.0, 100)\nparams = spm.default_parameter_values\nfor inpt in inputs:\n    params[inpt] = \"[input]\"\ngeometry = spm.default_geometry\n\nparams.process_model(spm)\nparams.process_geometry(geometry)\nmesh = pybamm.Mesh(geometry, spm.default_submesh_types, spm.default_var_pts)\ndisc = pybamm.Discretisation(mesh, spm.default_spatial_methods)\ndisc.process_model(spm)\nsolver = pybamm.IDAKLUSolver()\ninputs = {inpt: 1.0 for inpt in inputs}\nsolver.solve(spm, t_eval=t_eval, inputs=inputs)\n\n\ndef pybamm_bench():\n    sol = solver.solve(spm, t_eval=t_eval, inputs=inputs)\n    # force evalulation of the outputs\n    for output in outputs:\n        sol[output].data[0]\n\n\npybamm_time = timeit.timeit(pybamm_bench, number=n) / n\nprint(\"Pybamm time: \", pybamm_time)\nprint(\"Speedup: \", pybamm_time / diffsol_time)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinjrobins%2Fdiffsol_python_benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartinjrobins%2Fdiffsol_python_benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartinjrobins%2Fdiffsol_python_benchmark/lists"}