Off-chain physics simulation engine for quantum systems, designed for the QuantumOS blockchain.
This library provides high-performance implementations of classical and quantum physics simulations that can be:
- Executed off-chain by miner nodes
- Verified using zero-knowledge proofs
- Recorded on the QuantumOS blockchain
- 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
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
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);cargo run --example basic_ising --release- Task Creation: On-chain task specifies simulation parameters
- Execution: Miner runs simulation using this library
- Upload: Results uploaded to IPFS, CID obtained
- Proof: Zero-knowledge proof generated (using separate ZK library)
- Submission: CID + proof submitted to blockchain via
pallet-verifier - Verification: On-chain verification and reward distribution
- 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
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)
Uses Metropolis-Hastings algorithm:
- Randomly select a spin
- Calculate energy change ΔE for spin flip
- Accept if ΔE < 0, otherwise accept with probability exp(-ΔE/T)
- Repeat L² times for one Monte Carlo sweep
- Heisenberg model (3D spin vectors)
- Quantum annealing simulations
- Wolff cluster algorithm
- Parallel tempering
- GPU acceleration
Unlicense - Public Domain
- 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"