Skip to content
lukelowryPublic

About

WebGPU Power System Visualization

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

98 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The ACTIVSg70k grid on the globe as one 765 kV line opens: buses raised by their frequency, branches that pick up its power glow amber, those it leaves glow cyan

latkit

A GPU-accelerated visualization library for large networks, such as power grids:
interactive views in the browser with WebGPU, and images and video from the command line.

CI npm crates.io docs.rs Guides Rust version MIT license

Install

npm install latkit          # in the browser
cargo install latkit-cli    # on the command line: pictures and video
cargo add latkit            # in Rust

In the browser

import { loadLatkit, Patch, field, type Scene } from 'latkit';

const { Data, Gpu } = await loadLatkit();
const data = new Data('grid').apply(
  new Patch().replace('Bus', [101, 102], { x: [0, 30], y: [0, 20], kv: [230, 115] }),
);
const scene: Scene = {
  space: 'plane',
  marks: [
    {
      vertices: {
        of: ['grid', 'Bus'],
        position: ['x', 'y'],
        radius: 6,
        color: field('kv').colormap('viridis'),
      },
    },
  ],
};

const gpu = await Gpu.create();
const view = gpu.view(scene);
gpu.canvas(document.querySelector('canvas')!).show([view]);
view.setData(data);
view.fit();

Scenes, expressions, and patches are plain data, typed from latkit's schema: latkit/core builds them without loading WebAssembly, in a worker or on a server.

On the command line

The same scene and data, as JSON, render to a picture, or with --frames to video:

latkit render scene.json --data grid.json --output grid.png
latkit render scene.json --data grid.json --frames frames.jsonl --fps 60 --output grid.mp4
scene.json and grid.json

scene.json

{
  "space": "plane",
  "marks": [
    {
      "vertices": {
        "of": ["grid", "Bus"],
        "position": ["x", "y"],
        "radius": 6,
        "color": { "colormap": "viridis", "value": { "field": "kv" } }
      }
    }
  ]
}

grid.json

{
  "name": "grid",
  "patch": [
    {
      "replace": {
        "table": "Bus",
        "ids": [101, 102],
        "fields": { "x": [0, 30], "y": [0, 20], "kv": [230, 115] }
      }
    }
  ]
}

Gallery

Two thousand buses of a synthetic Texas grid: generators as amber discs sized by output, comets along its highest-voltage lines The speed of 1,456 machines over ten seconds after a fault, near ones bright and swinging hardest, far ones dark Routes between forty of the world's great cities, along great circles on a globe, comets flowing on them A microgrid controller as blocks in nested groups, wired port to port with routed wires and a feedback loop Sixty-four filaments in cyan, amber, and coral, twisting around a three-dimensional torus knot A Clifford strange attractor of 260,000 translucent points, colored by the way each step turns

Every picture is drawn by latkit; the examples hold them all with the code that draws them.

Documentation

Guides, examples, and the reference are on Read the Docs; the Rust API is on docs.rs. Contributing covers the repository and how to build it.

Created by Luke Lowery. MIT License.

About

WebGPU Power System Visualization

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages