Educational material and Python simulations on quantum sensing based on nitrogen-vacancy (NV) centers in diamond.
This repository was developed during my extracurricular internship at the Nanomaterials and Nanotechnology Research Center (CINN), Spain.
It combines a comprehensive introductory study manual with an interactive Python simulator focused on quantum sensing with nitrogen-vacancy (NV) centers in diamond.
The repository connects theoretical foundations with numerical simulation, allowing users to study the physical principles of NV centers and visualize how different experimental parameters modify Optically Detected Magnetic Resonance (ODMR) spectra.
The project was designed as an educational resource for students beginning in quantum sensing, condensed-matter physics, quantum technologies or experimental instrumentation.
- β Complete 75-page introductory study manual
- β Original educational figures and technical diagrams
- β Complete scientific bibliography and figure attribution
- β Interactive Python ODMR simulator
- β Effective spin-1 Hamiltonian implementation
- β Numerical Hamiltonian diagonalization
- β Zero-field splitting
- β Zeeman interaction
- β Arbitrary magnetic-field orientation
- β Four crystallographic NV orientations
- β Transverse perturbation caused by strain or electric fields
- β Temperature dependence of the zero-field splitting
- β Lorentzian ODMR spectra
- β Microwave-power broadening
- β Photon shot-noise simulation
- β Technical-noise simulation
- β Magnetic-field estimation from resonance splitting
- β Magnetic-sensitivity estimation
- β Automatic generation of ten scientific figures
- β Automatic generation of a structured TXT simulation report
- β Reproducible simulations using a fixed random seed
The repository includes a complete 75-page study manual introducing the physical principles of quantum sensing based on nitrogen-vacancy centers in diamond.
The manual was written during my internship at CINN as educational material for students beginning in this research field.
- Fundamentals of quantum sensing
- Physical quantities measured by quantum sensors
- Advantages and limitations of quantum sensors
- Diamond as a quantum material
- Nitrogen-vacancy centers
- NV charge states
- NV crystallographic orientations
- Spin states of the NV center
- Effective spin Hamiltonian
- Spin-1 matrix representation
- Zero-field splitting
- Zeeman interaction
- Electric-field and strain effects
- Ground- and excited-state level anticrossings
- Spin relaxation and coherence
- Optically Detected Magnetic Resonance
- ODMR spectrum interpretation
- Magnetic sensitivity
- Noise and signal-to-noise ratio
- Microwave spin control
- Microwave antennas and transmission structures
- Radiofrequency signal generators
- Spectrum analyzers
- Experimental instrumentation
The manual also contains:
- Original educational figures
- Technical diagrams
- Commented equations
- Figures adapted from scientific literature
- Complete bibliography
- Figure attribution and treatment table
- Author notes and methodological explanations
π Study Manual
Quantum_Sensing_Study_Manual.pdf
The repository includes an interactive Python simulator that reproduces ODMR spectra of nitrogen-vacancy centers in diamond.
The simulator numerically constructs and diagonalizes the effective spin Hamiltonian, calculates resonance frequencies under different experimental conditions and generates ideal and noisy ODMR spectra.
It also analyzes the effect of magnetic field, orientation, temperature, transverse perturbations, microwave power and photon detection rate.
- Interactive user input
- Automatic use of default values
- Single-axis NV model
- Four crystallographic NV orientations
- Zero-field ODMR simulation
- ODMR under an external magnetic field
- Magnetic-field vector decomposition
- Magnetic-field projection onto each NV orientation
- Resonance-frequency calculation
- Magnetic-field reconstruction from Zeeman splitting
- Temperature-dependent zero-field splitting
- Transverse perturbation simulation
- Microwave-power broadening
- Photon shot-noise simulation
- Technical Gaussian noise
- Magnetic-sensitivity estimation
- Minimum detectable magnetic-field estimation
- Automatic PNG export
- Automatic TXT report generation
The simulator includes the following physical model:
- Effective ground-state Hamiltonian for an NV center
- Electronic spin S=1
- Zero-field splitting D β 2.87 GHz
- Zeeman interaction
- Electron gyromagnetic ratio
- Arbitrary magnetic-field orientation
- Transverse perturbation parameter E
- Numerical Hamiltonian diagonalization
- Transition-frequency calculation
- Four crystallographic directions of the NV center
- Lorentzian ODMR line shapes
- Temperature dependence of D
- Microwave-power broadening
The effective Hamiltonian used in the simulation includes:
H = DΒ·Sz2 + EΒ·(Sx2 - Sy2) + Ξ³eΒ·(BxSx + BySy + BzSz)
where:
- D is the zero-field splitting parameter.
- E represents transverse strain or electric-field perturbations.
- Ξ³e is the electron gyromagnetic ratio.
- Bx, By and Bz are the magnetic-field components.
- Sx, Sy and Sz are the spin-1 matrices.
The program obtains the energy eigenvalues numerically and calculates the ODMR transition frequencies from the differences between the spin-energy levels.
Each execution automatically generates ten figures.
Shows the zero-field ODMR resonances and the splitting produced by the transverse perturbation parameter (E).
Shows the Zeeman splitting of the ODMR resonances under an applied magnetic field.
Represents the evolution of the two main resonance frequencies as the magnetic-field magnitude increases.
Shows how the ODMR resonance frequencies depend on the angle between the magnetic field and the NV axis.
Displays several ODMR spectra for different magnetic-field values.
Combines the transitions produced by the four crystallographic NV orientations in diamond.
Shows the displacement of the ODMR resonance frequencies caused by the temperature dependence of the zero-field splitting.
Illustrates microwave-power broadening while preserving the central resonance frequencies.
Shows the improvement in magnetic sensitivity as the detected photon rate increases.
Shows how strain or electric-field effects lift the degeneracy of the ms = Β±1 states even without an external magnetic field.
Each execution generates a structured report:
The report includes:
- Physical constants
- Selected simulation parameters
- Frequency sweep limits
- Magnetic-field components
- Energy eigenvalues
- ODMR resonance frequencies
- Zeeman splitting
- Longitudinal magnetic-field estimation
- Results for the four NV orientations
- Temperature dependence
- Photon and technical noise
- Microwave-power broadening
- Magnetic sensitivity
- Minimum detectable magnetic field
- Transverse perturbation results
- List of generated files
Quantum_Sensing_NV_Centers_in_Diamond/
β
βββ ODMR_Simulation.py
β
βββ Quantum_Sensing_Study_Manual.pdf
β
βββ results_odmr/
β βββ evolution_odmr_with_magnetic_field.png
β βββ frequencies_vs_angle.png
β βββ frequencies_vs_field.png
β βββ frequencies_vs_temperature.png
β βββ frequencies_vs_transverse_perturbation.png
β βββ magnetic_sensitivity_vs_photon_rate.png
β βββ odmr_four_nv_orientations.png
β βββ odmr_vs_microwave_power.png
β βββ odmr_without_magnetic_field.png
β βββ odmr_with_magnetic_field.png
β βββ results_ODMR.txt
β
βββ README.md
---
# π§ͺ Example Simulation Parameters
A representative set of input parameters is:
```text
Magnetic field: 3 mT
Angle relative to the NV axis: 20Β°
Polar angle in the crystal: 45Β°
Azimuthal angle: 20Β°
Transverse perturbation E: 1 MHz
Temperature: 25 Β°C
Temperature sweep: -50 to 150 Β°C
Relative microwave power: 4
Photon detection rate: 2,500,000 photons/s
Integration time: 0.01 s
Relative technical noise: 0.002
These values produce clearly separated ODMR resonances and illustrate the different physical effects implemented in the simulator.
Python 3.11 or later.
Required libraries:
- NumPy
- Matplotlib
Install the dependencies with:
pip install numpy matplotlibClone the repository:
git clone https://github.com/sofianunezda/Quantum-sensing.gitEnter the repository directory:
cd Quantum-sensingRun the simulator:
python ODMR_Simulation.pyThe program asks the user to introduce:
- Magnetic-field magnitude
- Angle relative to a single NV axis
- Polar angle of the magnetic field in the crystal
- Azimuthal angle of the magnetic field
- Transverse perturbation
- Selected temperature
- Temperature sweep limits
- Relative microwave power
- Photon detection rate
- Integration time
- Relative technical noise
Pressing Enter uses the default value shown between brackets.
All figures and the complete report are automatically saved in the results_odmr folder.
The main objective of this repository is to provide an accessible introduction to quantum sensing with NV centers in diamond.
The project combines:
- Theoretical background
- Scientific literature review
- Educational figures
- Numerical implementation
- Interactive simulations
- Automatic data visualization
- Structured result interpretation
The manual explains the physical principles, while the simulator allows users to explore how these principles affect observable ODMR spectra.
Together, both components form a self-contained educational resource connecting theory, computation and experimental concepts.
Possible extensions of the simulator include:
- Pulsed ODMR simulations
- Rabi oscillations
- Ramsey interferometry
- Hahn-echo sequences
- Spin-relaxation simulations
- T1 relaxation simulations
- T2 and T2* coherence analysis
- Hyperfine interaction
- Coupling to nuclear spins
- Multi-NV ensemble simulations
- Lorentzian fitting of simulated or experimental data
- Parameter estimation from experimental spectra
- Graphical user interface
- Comparison with laboratory measurements
The project is based on scientific literature studied during the internship at CINN.
Main references include:
- Barry, J. F. et al. (2020)
- Degen, C. L., Reinhard, F. & Cappellaro, P. (2017)
- Doherty, M. W. et al. (2013)
- DrΓ©au, A. et al. (2011)
- Rondin, L. et al. (2014)
Additional scientific references, books, theses, standards and technical documentation are included in the study manual.
This repository was developed during an extracurricular internship at the Nanomaterials and Nanotechnology Research Center (CINN).
The project began as a literature review on quantum sensing and progressively evolved into two complementary educational resources:
- A comprehensive study manual explaining the theoretical and experimental foundations of quantum sensing with NV centers.
- An interactive Python simulator implementing the principal physical effects involved in ODMR experiments.
The resulting repository reflects the full learning process: studying the scientific literature, organizing the theoretical foundations, creating educational illustrations, translating physical equations into code and interpreting the simulated results.
This project is distributed under the MIT License.
If you use the study manual, figures or simulation code for academic or educational purposes, citation of this repository is appreciated.
SofΓa NΓΊΓ±ez de AndrΓ©s
Physics Undergraduate Student University of Oviedo
Extracurricular Internship Nanomaterials and Nanotechnology Research Center (CINN)
π LinkedIn









