Skip to main content

Crate nvsim

Crate nvsim 

Source
Expand description

NV-diamond magnetometer pipeline simulator — deterministic, no hidden mocks.

§WebAssembly compatibility

nvsim is WASM-ready by construction: zero std::time, std::fs, std::env, std::process, std::thread, Mutex, or RwLock in the crate’s source. The shot-noise PRNG seeds from a caller-supplied u64 (no OS entropy), serialisation is via serde_json, hashing is via sha2 — all dependencies work on wasm32-unknown-unknown. To ship nvsim to a browser or Cloudflare Worker, build with cargo build -p nvsim --target wasm32-unknown-unknown --no-default-features (the wasm32 target needs rustup target add wasm32-unknown-unknown once on the developer machine).

nvsim is a standalone leaf crate. It models a forward-only magnetic sensing path — scene → source synthesis → material attenuation → NV ensemble → digitiser → binary frames + SHA-256 witness — using explicit physics approximations validated against published primary sources.

It is not a hardware-control stack, microscope simulator, full Hamiltonian solver, or claim of fT-level sensitivity. This crate does not control lasers, microwave sources, ADC hardware, or real NV sensors.

§Implementation plan

See docs/research/quantum-sensing/15-nvsim-implementation-plan.md for the six-pass build spec. This release ships Pass 1 only: crate scaffold, scene types, and the frame::MagFrame binary record.

§Pass 1 surface

Subsequent passes add source, propagation, sensor, digitiser, pipeline, and proof modules.

Re-exports§

pub use proof::Proof;
pub use digitiser::adc_dequantise;
pub use digitiser::adc_quantise;
pub use digitiser::DigitiserConfig;
pub use digitiser::Lockin;
pub use digitiser::LowPass;
pub use digitiser::ADC_BITS;
pub use digitiser::ADC_FULL_SCALE_T;
pub use digitiser::ADC_LSB_T;
pub use frame::MagFrame;
pub use frame::MAG_FRAME_MAGIC;
pub use frame::MAG_FRAME_VERSION;
pub use pipeline::Pipeline;
pub use pipeline::PipelineConfig;
pub use propagation::attenuate;
pub use propagation::material_is_heavy;
pub use propagation::material_loss_db_per_m;
pub use propagation::LosSegment;
pub use propagation::Material;
pub use propagation::Propagator;
pub use scene::CurrentLoop;
pub use scene::DipoleSource;
pub use scene::EddyCurrent;
pub use scene::FerrousObject;
pub use scene::Scene;
pub use sensor::nv_axes;
pub use sensor::NvReading;
pub use sensor::NvSensor;
pub use sensor::NvSensorConfig;
pub use source::current_loop_field;
pub use source::dipole_field;
pub use source::ferrous_field;
pub use source::scene_field_at;
pub use source::scene_field_at_sensors;
pub use source::R_MIN_M;

Modules§

digitiser
ADC quantisation, anti-alias filtering, and lockin demodulation — Pass 5a of the implementation plan.
frame
MagFrame — fixed-layout binary frame emitted per sensor per timestep.
pipeline
End-to-end NV-diamond simulator pipeline — Pass 5b of the implementation plan.
proof
Deterministic proof bundle — Pass 6 of the implementation plan.
propagation
Per-material magnetic-field attenuation along sensor–source line-of-sight segments — Pass 3 of the implementation plan.
scene
Scene types — ground-truth magnetic sources and ferrous-object distortion.
sensor
NV-ensemble sensor model — Pass 4 of the implementation plan.
source
Magnetic-field synthesis at sensor location(s) — Pass 2 of the implementation plan.

Enums§

NvsimError
Top-level simulator error type.

Constants§

D_GS
NV zero-field-splitting transition (Hz). Doherty 2013 §3.
GAMMA_E
NV electronic gyromagnetic ratio (Hz/T). Doherty 2013 §3.
MU_0
Permeability of free space (T·m/A). Jackson 3e §5.6.