numerics
Loading...
Searching...
No Matches
main.cpp File Reference

2D Ising model – classic mode + nucleation with umbrella sampling More...

#include "numerics.hpp"
#include "stats/stats.hpp"
#include "analysis/roots.hpp"
#include "stochastic/markov.hpp"
#include "spatial/pbc_lattice.hpp"
#include "spatial/connected_components.hpp"
#include <raylib.h>
#include <cmath>
#include <random>
#include <vector>
#include <algorithm>
#include <cstring>

Go to the source code of this file.

Classes

struct  RingBuffer
 
struct  IsingLattice
 

Functions

int main ()
 

Detailed Description

2D Ising model – classic mode + nucleation with umbrella sampling

Absorbs ~/projects/IsingNucleation into the numerics project. Exact match to IsingNucleation parameters: n=300, J=1, beta=0.58 (T~=1.724), F=0.1 (nucleation), F=0 (classic) Random spin selection per sweep (n^2 picks with replacement) DeltaE = 2J*s*(Sigma nbrs) - 2F*s (same sign convention as mc_step_boltz.c)

Optimizations vs. the original C implementation:

  1. Boltzmann lookup table – DeltaE discrete -> precomputed exp() table, no runtime exp() in the sweep hot path
  2. Precomputed neighbor arrays – up/dn/lt/rt[NN] avoid repeated modulo arithmetic per spin selection
  3. Array-based BFS cluster detection – iterative, pre-allocated flat queue; no recursion stack risk, no heap allocations per call
  4. SparseMatrix adj retained for energy_per_spin() (SIMD sparse_matvec)

Two modes (TAB to switch): Classic – free Metropolis; magnetisation and E/N^2 graphs Nucleation – umbrella sampling; tracks largest spin-down cluster (nucleus)

Definition in file main.cpp.

Function Documentation

◆ main()