• Stars
    star
    21
  • Rank 1,047,072 (Top 22 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ODE system solver made simple. For IVPs (initial value problems).

Go Report Card go.dev reference codecov Awesome

godesim

Simulate complex systems with a simple API.

Wrangle non-linear differential equations while writing maintainable, simple code.

Note: gonum/exp is still in early development but offers a more flexible and lightweight alternative to godesim's full fledged simulator.

Why Godesim?

ODE solvers seem to fill the niche of simple system solvers in your numerical packages such as scipy's odeint/solve_ivp.

Among these integrators there seems to be room for a solver that offers simulation interactivity such as modifying the differential equations during simulation based on events such as a rocket stage separation.

Installation

Requires Go.

go get github.com/soypat/godesim

Progress

Godesim is in early development and will naturally change as it is used more. The chart below shows some features that are planned or already part of godesim.

Status legend Planned Started Prototype Stable Mature
Legend symbol โœ–๏ธ ๐Ÿ—๏ธ ๐Ÿž๏ธ ๐Ÿšฆ๏ธ โœ…๏ธ
Features Status Notes
Non-linear solvers ๐Ÿšฆ๏ธ Suite of ODE solvers available.
Non-autonomous support ๐Ÿšฆ๏ธ U vector which need not a defined differential equation like X does.
Event driver ๐Ÿšฆ๏ธ Eventer interface implemented.
Stiff solver ๐Ÿšฆ๏ธ Newton-Raphson algorithm implemented and tested.
Algorithms available and benchmarks
Algorithm Time/Operation Memory/Op Allocations/Op
RK4 1575 ns/op 516 B/op 12 allocs/op
RK5 2351 ns/op 692 B/op 21 allocs/op
RKF45 3229 ns/op 780 B/op 25 allocs/op
Newton-Raphson 8616 ns/op 4292 B/op 92 allocs/op
Dormand-Prince 4365 ns/op 926 B/op 32 allocs/op

Quadratic Solution

// Declare your rate-of-change functions using state-space symbols
Dtheta := func(s state.State) float64 {
	return s.X("theta-dot")
}

DDtheta := func(s state.State) float64 {
    return 1
}
// Set the Simulation's differential equations and initial values and hit Begin!
sim := godesim.New() // Configurable with Simulation.SetConfig(godesim.Config{...})
sim.SetDiffFromMap(map[state.Symbol]state.Diff {
    "theta":  Dtheta,
    "theta-dot": DDtheta,
})
sim.SetX0FromMap(map[state.Symbol]float64{
    "theta":  0,
    "theta-dot": 0,
})
sim.SetTimespan(0.0, 1.0, 10) // One second simulated
sim.Begin()

The above code solves the following system:

for 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

How to obtain results

// one can then obtain simulation results as float slices 
t := sim.Results("time")
theta := sim.Results("theta")

Other examples

To run an example, navigate to it's directory (under examples) then type go run . in console.

There are three simple examples which have been cooked up and left in _examples directory. I've been having problems running Pixel on my machine so the simulation animations are still under work.

Final notes

Future 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.

Contributing

Pull requests welcome!

This is my first library written for any programming language ever. I'll try to be fast on replying to pull-requests and issues.

More Repositories

1

gopherlings

๐Ÿ“˜๏ธ Learn Go by fixing tiny incorrect programs
Go
632
star
2

mu8

Genetic algorithm for unsupervised machine learning in Go.
Go
109
star
3

sdf

A Go library for signed distance function shape generation. Read as 3D printing shape design.
Go
88
star
4

gitaligned

Find out where you fall on the Open-Source Character Alignment Chart
Go
74
star
5

cyw43439

Driver for the Wifi+bluetooth integrated circuit on the pico.
Go
74
star
6

natiu-mqtt

A dead-simple, extensible MQTT implementation well suited for embedded systems.
Go
58
star
7

go-maquina

Small finite-state machine library for Go
Go
41
star
8

peasocket

little websocket implementation
Go
34
star
9

go-presentx

golang's present tool but with code syntax highlighting
CSS
33
star
10

rebed

Recreates directory and files from embedded filesystem using Go 1.16 embed.FS type.
Go
23
star
11

exif

Dead simple exchangeable image file format tools for Go optimized for large image files using lazy loading.
Go
18
star
12

tiny-ahrsim

TinyGo attitude estimation simulation applet.
Go
17
star
13

threejs-golang-example

THREE.js example of rotating cube using gopherjs bindings. 160 lines of Go code.
JavaScript
14
star
14

sdf3ui

Browser based 3D model visualizer for use with soypat/sdf package.
Go
12
star
15

glgl

OpenGL bindings for Go that are in the goldilocks level of abstraction zone.
Go
12
star
16

three

syscall/js bindings for three.js in-browser 3D graphics.
Go
10
star
17

neurus

Neural network minimal working example in Go fit for teaching.
Go
10
star
18

ether-swtch

Low level Ethernet stack marshaller/unmarshaller for use in tiny places.
Go
8
star
19

natiu-wsocket

MQTT websocket implementation using natiu-mqtt.
Go
6
star
20

lap

linear algebra package. like gonum/mat, but small. lets say gonum-lite
Go
5
star
21

goldmark-latex

A LaTeX renderer for Goldmark. Produce .tex files from markdown.
Go
5
star
22

go-play3d

3D math playground for Go.
Go
4
star
23

sv

idiomatic go http server
Go
3
star
24

ieeeztreme14

IEEExtreme 14.0 solved problems for team finally_cflat
Go
3
star
25

gwasm

Common utilities I find myself rewriting too often across Go WASM projects.
Go
3
star
26

peamodbus

Fault tolerant, TCP modbus implementation in Go that just works. Apt for embedded systems.
Go
3
star
27

mdc

Material Design Components for use with Vecty in the most minimalistic fashion.
Go
2
star
28

decimate

csv file decimator/downsampler for reducing number of points of a curve or signal.
Go
2
star
29

plot3

3D line plots in pure Go
Go
2
star
30

tinygo-arduino-examples

Compilation of LCD screen, ADC, and output examples.
Go
2
star
31

go-canard

Go port of libcanard. WIP.
Go
2
star
32

whittileaks

Hardcore class notes for mechanical engineering.
TeX
2
star
33

manigold

3D Mesh creation, manipulation and optimization library.
Go
2
star
34

go-mod-tricks

go.mod file and `go mod` command tricks to make using modules a breeze.
2
star
35

piaa

Industrial extension board for Raspberry Pi Pico (W). RS485, EMI insulated digital input/output pins.
1
star
36

decaffeinator

An effort to relieve the establishment of caffeine.
Go
1
star
37

so

MWE tutorial of .so dynamic linking in C and Go.
C
1
star
38

vecty-examples

Basic usage of Vecty framework examples.
Go
1
star
39

tiny-sproto

A simple Point-to-Point Protocol implementation written in Go.
Go
1
star
40

wchart

syscall/js bindings for Chart.js
Go
1
star
41

novatex

Guรญa del LaTeX para principiantes
TeX
1
star
42

go-fem

Go packages for finite element analysis/methods.
Go
1
star
43

net

Temporary repo for minimal net package from go std lib for use with tinygo until v0.18.0 released
Go
1
star
44

fea-two

Elementos Finitos II @ ITBA
MATLAB
1
star
45

combinatrix

Combinar horarios para ITBA """dinamicamente"""
Go
1
star
46

go-qap

CERN's quality assurance plan (QAP) to solve the document naming convention problem.
Go
1
star
47

shaders

Wai- wha? Shaders? Like GPU stuff? Yeah, gpu stuff.
Go
1
star
48

go-proy

Proyectos para practicar golang
Go
1
star
49

seqs

seqs: the hottest, most idiomatic TCP implementation on the internet.
Go
1
star