orbit

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Rendered for darwin/amd64

Overview

Package orbit is celestial/orbit's stepping as a kernel on the gpu: every star at once, each on its own thread, in 32-bit floats, by the same kick, drift, kick. Its reference is celestial/orbit, and its tests measure how closely the two agree.

The tests hold the kernel to the reference on passes from a tenth of a kiloparsec out, and on a circle a parsec from the centre.

A plunge from kiloparsecs to parsecs, the regime a search for stars thrown from the centre is after, wants steps planned for its nearest pass and a galactic potential, and is not tested yet.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RanAway

func RanAway(err error) ([]int, bool)

RanAway is the stars that ran away when a refusal is a Runaway, and whether it is one.

Types

type Field

type Field struct {
	// contains filtered or unexported fields
}

Field is a potential as the kernel wants it: its pull in the Metal shading language, the numbers that pull reads, and the same potential in Go, for the kernel to be held to.

func Kepler

func Kepler(body grav.Body) Field

Kepler is the pull of a body at the centre.

func MilkyWay

func MilkyWay(galaxy orbit.MilkyWay) Field

MilkyWay is the galaxy's pull as orbit has it, in Metal: the bulge by the regularised lower incomplete gamma function summed in 32 bits, the disc, the halo with its small-distance series, and the hole, each as orbit's reference defines them, with the galaxy as the reference.

func NewField

func NewField(source string, numbers []float32,
	reference orbit.Potential,
) Field

NewField is a field from its pull in Metal, which defines

static inline float3 pull(float3 at, constant float *field)

as the acceleration at a place in kiloparsecs, in kilometres per second over one unit of time; the numbers that pull reads as field; and the same potential in Go.

func (Field) Reference

func (field Field) Reference() orbit.Potential

Reference is the potential in Go.

type Runaway

type Runaway struct {
	// contains filtered or unexported fields
}

Runaway is the refusal of a batch in which stars ran away: through the centre or past what a float holds, so that a place or a motion is not a number. It names the stars by their places in the batch, in order.

func NewRunaway

func NewRunaway(stars []int) Runaway

NewRunaway is the refusal naming the stars given, as a solver that stands in for this one makes it; RanAway reads the stars back.

func (Runaway) Error

func (away Runaway) Error() string

Error says which stars ran away.

type Solver

type Solver struct {
	// contains filtered or unexported fields
}

Solver is the kernel open on a device over one field, with room for so many stars at once.

func Open

func Open(device gpu.Device, field Field, most int) (*Solver, error)

Open compiles the kernel over a field on a device, with room for so many stars at once. It refuses room for none, and a field whose pull does not compile.

func (*Solver) Back

func (solver *Solver) Back(stars []orbit.State, span measure.Duration,
	steps int,
) ([]orbit.Pass, []orbit.State, error)

Back runs every star's orbit back over a span, in so many steps, and reports each one's nearest pass to the centre over them and its state at the start of the span.

It refuses a span that is not positive, no steps, more stars than it has room for, and a star whose orbit ran away, through the centre or past what a float holds.

func (*Solver) Close

func (solver *Solver) Close()

Close lets the kernel and its buffers go. Closing twice is harmless.

func (*Solver) Field

func (solver *Solver) Field() Field

Field is the field the solver was opened over.

func (*Solver) GPUTime

func (solver *Solver) GPUTime() time.Duration

GPUTime is how long the gpu has spent on the solver's runs.

func (*Solver) Pulls

func (solver *Solver) Pulls(places []orbit.Place) ([]orbit.Pull, error)

Pulls is the field's pull at each place by the solver's kernel, for as many places as it has room for stars: a way to hold the kernel's pull to the reference's, and to ask the field. It borrows the solver's buffers, so a run's results are gone after it.

It refuses a closed solver and more places than it has room for.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL