Skip to content

Latest commit

 

History

History
114 lines (82 loc) · 3.1 KB

File metadata and controls

114 lines (82 loc) · 3.1 KB

QuantumOS Physics Engine

Off-chain physics simulation engine for quantum systems, designed for the QuantumOS blockchain.

Overview

This library provides high-performance implementations of classical and quantum physics simulations that can be:

  1. Executed off-chain by miner nodes
  2. Verified using zero-knowledge proofs
  3. Recorded on the QuantumOS blockchain

Features

  • 2D Ising Model: Classical spin system with Metropolis Monte Carlo
  • Observable Calculations: Energy, magnetization, specific heat, susceptibility
  • Statistical Analysis: Automated variance and error estimation
  • JSON Serialization: Results compatible with IPFS storage
  • Reproducible: Seedable RNG for deterministic simulations

Supported Models

Ising Model

A mathematical model of ferromagnetism with discrete spin variables (+1 or -1).

Parameters:

  • Lattice size (LxL grid)
  • Temperature (in units of J/k_B)
  • External magnetic field
  • Coupling constant
  • Monte Carlo steps

Outputs:

  • Energy and magnetization time series
  • Thermodynamic response functions
  • Final spin configuration

Usage

Basic Example

use physics_engine::{IsingModel, Simulation, SimulationParams};

// Configure simulation
let params = SimulationParams {
    lattice_size: 20,
    temperature: 2.0,
    steps: 10_000,
    equilibration_steps: 2_000,
    seed: Some(42),
    ..Default::default()
};

// Run simulation
let mut model = IsingModel::new(params);
let result = model.run();

println!("Average energy: {}", result.avg_energy);
println!("Specific heat: {}", result.specific_heat);

Running Examples

cargo run --example basic_ising --release

Integration with QuantumOS

  1. Task Creation: On-chain task specifies simulation parameters
  2. Execution: Miner runs simulation using this library
  3. Upload: Results uploaded to IPFS, CID obtained
  4. Proof: Zero-knowledge proof generated (using separate ZK library)
  5. Submission: CID + proof submitted to blockchain via pallet-verifier
  6. Verification: On-chain verification and reward distribution

Performance

  • 20x20 Ising model: ~200ms for 10,000 Monte Carlo sweeps
  • Scalability: O(L²) per sweep for L×L lattice
  • Memory: O(L²) for storing spin configuration

Physics Background

Critical Behavior

The 2D Ising model exhibits a phase transition at T_c ≈ 2.269:

  • T < T_c: Ordered phase (ferromagnetic)
  • T > T_c: Disordered phase (paramagnetic)

Monte Carlo Algorithm

Uses Metropolis-Hastings algorithm:

  1. Randomly select a spin
  2. Calculate energy change ΔE for spin flip
  3. Accept if ΔE < 0, otherwise accept with probability exp(-ΔE/T)
  4. Repeat L² times for one Monte Carlo sweep

Future Extensions

  • Heisenberg model (3D spin vectors)
  • Quantum annealing simulations
  • Wolff cluster algorithm
  • Parallel tempering
  • GPU acceleration

License

Unlicense - Public Domain

References

  • Onsager, L. (1944). "Crystal Statistics. I. A Two-Dimensional Model with an Order-Disorder Transition"
  • Newman, M.E.J. & Barkema, G.T. (1999). "Monte Carlo Methods in Statistical Physics"