Solver

B-field solver tools.

Tools for solving the NV center hamiltonian

\frac{H}{\hbar} = D_{gs}\left(S_z^2 - \frac{1}{3}S(S+1)\right) + E(S_x^2 - S_y^2) + \gamma_{\text{NV}}\vec{B} \cdot \vec{S}

class nvtools.solver.BField(b_abs: list[float], theta: list[float], b_vec: Vector)[source]

B-field.

b_abs: list[float]
b_vec: Vector
property mean_field

Calculate mean absolute field value.

theta: list[float]
to_dict()[source]

Format to dict.

class nvtools.solver.Solver[source]

B-field Solver.

static field_from_resonances(fl, fu)[source]

Calculate absolute field value and angle to NV-axis.

\mathcal{B}^2 = \frac{1}{3} \left(f_{\text{u}}^2 + f_{\text{l}}^2 - f_{\text{u}}f_{\text{l}} - D^2 - 3E^2\right)

\cos^2\theta = \frac{2f_{\text{l}}^3-3f_{\text{l}}^2f_{\text{u}}-3f_{\text{l}}f_{\text{u}}^2+2f_{\text{u}}^3}{27(D-E/2)\mathcal{B}^2} + \frac{2D^3 - 18DE^2}{27(D-E/2)\mathcal{B}^2} + \frac{2D-3E}{6(D-E/2)}

Parameters:
  • fl – lower resonance frequency

  • fu – upper resonance frequency

field_from_spectrum(mw_frequency, odmr, p0_frequency=None)[source]

Calculate field from odmr spectrum.

Parameters:
  • mw_frequency – MW frequency

  • odmr – ODMR

  • p0_frequency (list | None) – estimates for resonance frequencies

static resonances_from_field(b_abs, theta, units=True)[source]

Calculate resonance frequencies.

p = -\left(\frac{1}{3}D^2 + E^2 + \mathcal{B}^2\right)

q =  - \frac{1}{2}D\mathcal{B}^2\cos(2\theta) - E\mathcal{B}^2\sin^2\theta - \frac{1}{6}D\mathcal{B}^2 + \frac{2}{27}D^3 - \frac{2}{3}DE^2

\lambda_k =  \frac{2}{\sqrt{3}}\sqrt{-p}\cos\left(\frac{1}{3}\arccos\left(\frac{3\sqrt{3}}{2}\frac{q}{\sqrt{-p^3}}\right)-k\frac{2\pi}{3}\right), \enspace k = 0,1,2

f_{\text{u}} = \lambda_2 - \lambda_0 \enspace \text{and} \enspace f_{\text{l}} = \lambda_1 - \lambda_0

Parameters:
  • b_abs – absolute B-field value

  • theta – angle between B-field and NV-axis

  • units – apply / ignore units

static vector_from_field(b_abs: list[float], theta: list[float], theta_var: None | list[float] = None) Vector[source]

Calculate B-field vector from angles to NV axes.

\vec{B} = B \frac{\sqrt{3}}{4} \begin{pmatrix} 1 & -1 & -1 & 1 \\ 1 & -1 & 1 & -1 \\ 1 & 1 & -1 & -1 \\ \end{pmatrix} \cdot \begin{pmatrix} \pm\cos\theta_1 \\ \pm\cos\theta_2 \\ \pm\cos\theta_3 \\ \pm\cos\theta_4 \\ \end{pmatrix}

Parameters:
  • b_abs – absolute B-field value

  • theta – angle between B-field and NV-axis

  • theta_var – variances of theta, if known