ts-quantum
Version:
TypeScript library for quantum mechanics calculations and utilities
79 lines (78 loc) • 2.29 kB
TypeScript
/**
* SpinNetworkBuilder provides a fluent API for constructing spin networks -
* quantum graphs with SU(2) spins on edges and intertwiner vertices.
*/
import { QuantumGraph } from '../../qgraph/QuantumGraph';
export interface SpinNetworkOptions {
/**
* Number of vertices in the network
*/
nodes?: number;
/**
* Number of rows for grid/lattice layouts
*/
rows?: number;
/**
* Number of columns for grid/lattice layouts
*/
cols?: number;
/**
* Probability of edge creation for random graphs
*/
probability?: number;
/**
* Whether to create periodic boundary conditions
*/
periodic?: boolean;
/**
* Default spin value for edges (defaults to 1/2)
*/
defaultSpin?: number;
/**
* Whether to pre-compute and assign valid intertwiners (default true)
*/
computeIntertwiners?: boolean;
}
/**
* Builder class for creating spin network quantum graphs
*/
export declare class SpinNetworkBuilder {
private options;
private graph;
private constructor();
/**
* Create a new SpinNetworkBuilder instance
*/
static create(options?: SpinNetworkOptions): SpinNetworkBuilder;
/**
* Add a vertex with an intertwiner space based on incident edge spins
*/
addVertex(id: string, position?: {
x: number;
y: number;
}): SpinNetworkBuilder;
/**
* Add a quantum edge with specified spin between vertices
*/
addEdge(sourceId: string, targetId: string, spin?: number): SpinNetworkBuilder;
/**
* Update the intertwiner space for a vertex based on incident edge spins
*/
private updateIntertwiners;
/**
* Calculate the allowed intertwiner values for a set of spins
*/
private calculateAllowedIntertwiners;
/**
* Build and return the completed spin network
*/
build(): QuantumGraph;
/**
* Create a 2D lattice spin network
*/
static createLattice2D(options: Pick<SpinNetworkOptions, 'rows' | 'cols' | 'defaultSpin' | 'periodic'>): QuantumGraph;
/**
* Create a chain of spins with nearest-neighbor coupling
*/
static createChain(n: number, options: Pick<SpinNetworkOptions, 'defaultSpin' | 'periodic'>): QuantumGraph;
}