{"id":13413744,"url":"https://github.com/soypat/godesim","last_synced_at":"2025-03-23T08:31:53.903Z","repository":{"id":57559610,"uuid":"321829472","full_name":"soypat/godesim","owner":"soypat","description":"ODE system solver made simple. For IVPs (initial value problems).","archived":false,"fork":false,"pushed_at":"2022-06-04T04:01:34.000Z","size":297,"stargazers_count":23,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T19:04:38.504Z","etag":null,"topics":["differential-equations","dormand-prince","golang","initial-value-problem","ivp","newton-raphson-multivariable","ode","ode-solver","runge-kutta","runge-kutta-fehlberg","simulation"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soypat.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":"2020-12-16T01:02:26.000Z","updated_at":"2024-01-05T15:41:16.000Z","dependencies_parsed_at":"2022-08-28T14:10:53.284Z","dependency_job_id":null,"html_url":"https://github.com/soypat/godesim","commit_stats":null,"previous_names":["go-sim/simulation","soypat/simulation"],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soypat%2Fgodesim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soypat%2Fgodesim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soypat%2Fgodesim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soypat%2Fgodesim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soypat","download_url":"https://codeload.github.com/soypat/godesim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245078067,"owners_count":20557274,"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":["differential-equations","dormand-prince","golang","initial-value-problem","ivp","newton-raphson-multivariable","ode","ode-solver","runge-kutta","runge-kutta-fehlberg","simulation"],"created_at":"2024-07-30T20:01:47.959Z","updated_at":"2025-03-23T08:31:53.515Z","avatar_url":"https://github.com/soypat.png","language":"Go","readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/soypat/godesim)](https://goreportcard.com/report/github.com/soypat/godesim)\n[![go.dev reference](https://pkg.go.dev/badge/github.com/soypat/godesim)](https://pkg.go.dev/github.com/soypat/godesim)\n[![codecov](https://codecov.io/gh/soypat/godesim/branch/main/graph/badge.svg)](https://codecov.io/gh/soypat/godesim/branch/main)\n[![Awesome](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go/blob/master/README.md#science-and-data-analysis)\n\n# godesim\n\nSimulate complex systems with a simple API.\n---\n\nWrangle non-linear differential equations while writing maintainable, simple code.\n\nNote: [gonum/exp](https://github.com/gonum/exp) is still in early development but offers a more flexible and lightweight alternative to `godesim`'s full fledged simulator.\n\n## Why Godesim?\n\nODE solvers seem to fill the niche of simple system solvers in\nyour numerical packages such as scipy's odeint/solve_ivp. \n\nAmong these integrators there seems to be room for a solver that offers simulation interactivity such as modifying\nthe differential equations during simulation based on events such as a rocket stage separation.\n\n## Installation\n\nRequires Go.\n\n```console\ngo get github.com/soypat/godesim\n```\n\n## Progress\n\nGodesim is in early development and will naturally change as it is used more.\n The chart below shows some features that are planned or already part of godesim.\n\n| Status legend | Planned | Started | Prototype | Stable | Mature |\n| ------------- |:-------:|:-------:|:---------:|:------:|:------:|\n| Legend symbol |    ✖️    |    🏗️   |     🐞️    |   🚦️   |   ✅️   |\n\n| Features | Status | Notes |\n| -------- |:------:| ----- |\n| Non-linear solvers | 🚦️ | Suite of ODE solvers available. |\n| Non-autonomous support | 🚦️ | `U` vector which need not a defined differential equation like `X` does.|\n| Event driver | 🚦️ | Eventer interface implemented. |\n| Stiff solver | 🚦️ | Newton-Raphson algorithm implemented and tested. |\n\n\u003cdetails\u003e\u003csummary\u003eAlgorithms available and benchmarks\u003c/summary\u003e\n\n| Algorithm         |   Time/Operation| Memory/Op     | Allocations/Op    |\n|-------------------|-----------------|---------------|-------------------|\n|RK4             \t|    1575 ns/op\t  |   516 B/op\t  |    12 allocs/op   |\n|RK5             \t|    2351 ns/op\t  |   692 B/op\t  |    21 allocs/op   |\n|RKF45          \t|    3229 ns/op\t  |   780 B/op\t  |    25 allocs/op   |\n|Newton-Raphson     |    8616 ns/op\t  |  4292 B/op\t  |    92 allocs/op   |\n|Dormand-Prince   \t|    4365 ns/op\t  |   926 B/op\t  |    32 allocs/op   |\n\n\u003c/details\u003e\n\n## [Examples](./_examples)\n\n### Quadratic Solution\n\n```go\n// Declare your rate-of-change functions using state-space symbols\nDtheta := func(s state.State) float64 {\n\treturn s.X(\"theta-dot\")\n}\n\nDDtheta := func(s state.State) float64 {\n    return 1\n}\n// Set the Simulation's differential equations and initial values and hit Begin!\nsim := godesim.New() // Configurable with Simulation.SetConfig(godesim.Config{...})\nsim.SetDiffFromMap(map[state.Symbol]state.Diff {\n    \"theta\":  Dtheta,\n    \"theta-dot\": DDtheta,\n})\nsim.SetX0FromMap(map[state.Symbol]float64{\n    \"theta\":  0,\n    \"theta-dot\": 0,\n})\nsim.SetTimespan(0.0, 1.0, 10) // One second simulated\nsim.Begin()\n```\n\nThe above code solves the following system:\n\n![](_assets/quadratic_eq.png)\n\nfor the domain `t=0` to `t=1.0` in 10 steps where `theta` and `theta-dot` are the `X` variables. The resulting curve is quadratic as the solution for this equation (for theta and theta-dot equal to zero) is\n\n![](_assets/quadratic_eq_sol.png)\n\n### How to obtain results\n```go\n// one can then obtain simulation results as float slices \nt := sim.Results(\"time\")\ntheta := sim.Results(\"theta\")\n```\n\n\n### Other examples\n\nTo run an example, navigate to it's directory (under [`examples`](./_examples)) then type `go run .` in console.\n\nThere are three simple examples which have been cooked up and left in `_examples` directory.\nI've been having problems running Pixel on my machine so the simulation animations are still under work.\n\n* [Simple pendulum](./_examples/simplePendulum)\n* [Double pendulum exhibiting chaotic motion](./_examples/doublePendulum)\n* [N-Body simulation](./_examples/n-body)\n\n### Final notes\nFuture versions of gonum will have an ODE solver too. Ideally godesim would base it's algorithms on `gonum`'s implementation. See https://github.com/gonum/exp `ode` package.\n\n\n## Contributing\n\nPull requests welcome!\n\nThis is my first library written for any programming language ever. I'll try to be fast on replying to pull-requests and issues. \n\n","funding_links":[],"categories":["Science and Data Analysis","Relational Databases","科学与数据分析"],"sub_categories":["HTTP Clients","HTTP客户端"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoypat%2Fgodesim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoypat%2Fgodesim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoypat%2Fgodesim/lists"}