Skip to content
lukelowryPublic

About

WebGPU Power System Visualization

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

103 Commits

Folders and files

Repository files navigation

The ACTIVSg70k grid on a globe as one 765 kV line opens. Buses rise with their frequency, branches that pick up the line's power glow amber, and branches that lose flow 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 { Data, View, field, load } from 'latkit';

await load();
const grid = new Data('grid').set('Bus', [101, 102], { x: [0, 30], y: [0, 20], kv: [230, 115] });

const view = await View.create(document.querySelector('canvas')!, {
  space: 'plane',
  marks: [
    {
      vertices: grid.table('Bus'),
      position: ['$x', '$y'],
      radius: 6,
      color: field('kv').colormap('viridis'),
    },
  ],
});

grid.set('Bus', [102], { kv: [345] }); // drawn the next frame

A scene is plain data, with types from latkit's schema. JSON.stringify(scene) writes the JSON the command line reads.

On the command line

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

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": ["grid", "Bus"],
      "position": ["$x", "$y"],
      "radius": 6,
      "color": { "colormap": "viridis", "value": "$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. Machines near the fault are bright and swing hardest, and far ones are dark Great-circle routes between forty of the world's great cities on a globe, with comets flowing along them A microgrid controller as blocks in nested groups, with wires routed port to port 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 direction of each step

latkit drew every picture here. The examples show the code for each one.

Documentation

Guides, examples, and the reference are on Read the Docs, and 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