Skip to main content

GPU-accelerated physics simulation engine

Project description

Hyperstellar

Write math Equations in python

Buckle up, because this isn't just another preset physics engine. Hyperstellar gives you the mathematical language to define any dynamical system, then GPU accelerates it to thousands of frames per second. From orbital mechanics to fluid dynamics, if you can write the equation, you can simulate it.

Two-Body Orbital System

Installation

pip install hyperstellar

Platform Note: The current release (0.1.x) supports Windows 10/11 (64-bit). Linux support is in development - Linux users can build from source using the project files.

Quick Start

import hyperstellar as se
import math

sim = se.Simulation(headless=False, enable_grid=False)
while not sim.are_all_shaders_ready(): # A one time GPU initialization (required before simulation)
    sim.update_shader_loading()
while sim.object_count() > 0: # Remove default object
    sim.remove_object(0)

G, M_star, M_planet, sep = 1.0, 50.0, 1.0, 3.0
v_orbit = math.sqrt(G * (M_star + M_planet) / sep)

# Create star and planet
star = sim.add_object(x=0, y=0, vy=M_planet*v_orbit/(M_star+M_planet),
                      mass=M_star, skin=se.SkinType.CIRCLE, size=0.8)
planet = sim.add_object(x=sep, y=0, vy=-M_star*v_orbit/(M_star+M_planet),
                        mass=M_planet, skin=se.SkinType.CIRCLE, size=0.25)

# Gravitational force equations (ax, ay, angular, r, g, b, a)
sim.set_equation(star,
    f"{G}*{M_planet}*(p[1].x-x)/((p[1].x-x)^2+(p[1].y-y)^2)^1.5," # Newtonian gravity equation using object reference p[index]
    f"{G}*{M_planet}*(p[1].y-y)/((p[1].x-x)^2+(p[1].y-y)^2)^1.5,"
    "0, 1.0, 0.9, 0.3, 1.0"  # Yellow
)
sim.set_equation(planet,
    f"{G}*{M_star}*(p[0].x-x)/((p[0].x-x)^2+(p[0].y-y)^2)^1.5,"
    f"{G}*{M_star}*(p[0].y-y)/((p[0].x-x)^2+(p[0].y-y)^2)^1.5,"
    "0, 0.3, 0.6, 1.0, 1.0"  # Blue
)



while not sim.should_close():
    sim.update(0.016)
    sim.render()

See the full version in examples/orbit.py

What you can actually do with this

  • Write your own equations (real or complex) and run them directly on the GPU. <<<<<<< HEAD
  • Reference other objects inside equations — positions, velocities, even colors. p[i].value =======
  • Reference other objects inside equations — positions, velocities, even colors. "p[i].x, p[i].y, p[i].vx, etc."

b325bb0bccc24c98bd8827322c31e467fb14614a

  • Define derivatives and run them in the GPU. D(expression, variable, order)
  • Most Math functions are available in DSL. Full support for trig, exponentials, powers, statistics, and complex numbers
  • Run the engine with a window, or completely headless if you just want numbers.
  • Batch operations for crunching numbers and cpu to gpu uploads in mass.
  • Use color as part of the simulation state, not just rendering.
  • Lock things together with constraints instead of hardcoding relationships. -experimental
  • Run thousands of objects or many simulations at once without touching the CPU.

Examples

Documentation

Coming soon - for now see the examples folder and the code documentation in bindings.cpp.


Built to make physics equations visual and interactive.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hyperstellar-0.1.47.tar.gz (337.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hyperstellar-0.1.47-py3-none-any.whl (331.0 kB view details)

Uploaded Python 3

File details

Details for the file hyperstellar-0.1.47.tar.gz.

File metadata

  • Download URL: hyperstellar-0.1.47.tar.gz
  • Upload date:
  • Size: 337.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for hyperstellar-0.1.47.tar.gz
Algorithm Hash digest
SHA256 c0fcc04894866d88f1c19890373b2e00ebe561ef4c9a3faf9f8f555be89607e2
MD5 adc4b68cea2d4d3d8761c80d85cfbdca
BLAKE2b-256 3058453d2cb5d676f09f46c6a50e6296a40595a83d639cd0c57e5369bea2310b

See more details on using hashes here.

File details

Details for the file hyperstellar-0.1.47-py3-none-any.whl.

File metadata

  • Download URL: hyperstellar-0.1.47-py3-none-any.whl
  • Upload date:
  • Size: 331.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for hyperstellar-0.1.47-py3-none-any.whl
Algorithm Hash digest
SHA256 245f3c7a6e8dafb3232ec15d9b1de7f0f7ec789334b82e9b9bbe7fd0b729764d
MD5 da643939e583aade2a86df99f284b20e
BLAKE2b-256 dcb4bcf45aa896fd4a1bef1ee979794d613816d11a0363de47f9dc12621277f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page