Skip to main content

Welcome to citrine 💎

citrine is a small Python library to calculate the joint-spectra of nonlinear crystals used in parametric downconversion sources.

About

Features

  • Calculate grating periods
  • Produce Δk matrices for different crystals and phase matching conditions
  • Pump envelope functions
  • Phase matching functions
  • Types for commonly used units
    • e.g. citrine.Wavelength
  • Library of crystal parameters
    • citrine.crystals sub-module

Requirements

  • numpy

Installation

python3 -m pip install citrine

Alternatively from Git

Install from git for the latest version

python3 -m pip install git+https://github.com/Peter-Barrow/citrine.git

Quick Examples

import citrine
import numpy as np
import matplotlib.pyplot as plt

# Define central wavelengths for pump, signal, and idler
lambda_p_central = citrine.Wavelength(775, Magnitude.nano)
lambda_s_central = citrine.Wavelength(1550, Magnitude.nano)
lambda_i_central = citrine.Wavelength(1550, Magnitude.nano)

# Define a range of wavelengths for signal and idler (in nm)
spectral_width = citrine.Wavelength(25, Magnitude.nano)
steps = 1024
lambda_s = citrine.spectral_window(lambda_s_central, spectral_width, steps)
lambda_i = citrine.spectral_window(lambda_i_central, spectral_width, steps)

# Define pump bandwidth (in nm and convert)
sigma_lambda_p = citrine.Wavelength(0.5, Magnitude.nano)
sigma_p = 2 * np.pi * citrine.bandwidth_conversion(sigma_lambda_p, lambda_p_central)

# Calculate grating period
grating_period = citrine.calculate_grating_period(
    lambda_p_central,
    lambda_s_central,
    lambda_i_central,
    citrine.crystals.ppKTP,
)

# Calculate Δk matrix
delta_k = citrine.delta_k_matrix(
    lambda_p_central,
    lambda_s,
    lambda_i,
    ppKTP,
)

# Calculate the phase matching function
phase_matching = citrine.phase_matching_function(delta_k, grating_period, 1e-2)

# Calculate the Gaussian pump envelope
pump_envelope = citrine.pump_envelope_gaussian(lambda_p_central, sigma_p, lambda_s, lambda_i)

# Calculate the Joint Spectral Amplitude (JSA)
JSA = pump_envelope * phase_matching

# Plotting
fig, axs = plt.subplots(
    2, 2, figsize=(8, 8), sharex=True, sharey=True, squeeze=True
)

# Plot Δk
axs[0, 0].pcolormesh(
    lambda_i.value, lambda_s.value, delta_k, cmap='viridis'
)
axs[0, 0].set_title(r'$\Delta k$')
axs[0, 0].set_xlabel(r'$\lambda_s$ (nm)')
axs[0, 0].set_ylabel(r'$\lambda_i$ (nm)')

# Plot the pump envelope
axs[0, 1].pcolormesh(
    lambda_i.value,
    lambda_s.value,
    pump_envelope,
    cmap='viridis',
)
axs[0, 1].set_title(r'$\alpha(\lambda_s, \lambda_i)$')
axs[0, 1].set_xlabel(r'$\lambda_s$ (nm)')
axs[0, 1].set_ylabel(r'$\lambda_i$ (nm)')

# Plot the phase matching function
axs[1, 0].pcolormesh(
    lambda_i.value,
    lambda_s.value,
    phase_matching,
    cmap='viridis',
)
axs[1, 0].set_title(r'$\phi(\lambda_s, \lambda_i)$')
axs[1, 0].set_xlabel(r'$\lambda_s$ (nm)')
axs[1, 0].set_ylabel(r'$\lambda_i$ (nm)')

# Plot the Joint Spectral Amplitude (JSA)
axs[1, 1].pcolormesh(lambda_i.value, lambda_s.value, JSA, cmap='viridis')
axs[1, 1].set_title(
    r'$\alpha(\lambda_s, \lambda_i) \phi(\lambda_s, \lambda_i)$'
)
axs[1, 1].set_xlabel(r'$\lambda_s$ (nm)')
axs[1, 1].set_ylabel(r'$\lambda_i$ (nm)')

# Add overall title
fig.suptitle(
    r'$\omega_p = {:.2f}\mathrm{{nm}}, \omega_s = {:.2f}\mathrm{{nm}}, \omega_i = {:.2f}\mathrm{{nm}}, \Lambda = {:.2f}\mathrm{{\mu m}}$'.format(
        lambda_p_central.value,
        lambda_s_central.value,
        lambda_i_central.value,
        grating_period * (1e6), # convert to microns for printing
    )
)

# Show plot
plt.tight_layout()
plt.show()

Metadata

Release files for citrineSPDC 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for citrineSPDC 0.2.0
File Size Uploaded
citrinespdc-0.2.0.tar.gz 62.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for citrineSPDC 0.2.0
File Interpreter ABI Platform
citrinespdc-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 115.9 kB

Release files / citrinespdc-0.2.0.tar.gz

Download URL citrinespdc-0.2.0.tar.gz
Size 62.7 kB
Tags Source
SHA-256 checksum
How to use checksums
40e173919e88341a284753605e782dfefc8619702373350093721242b2c29c29
BLAKE2b-256 checksum
How to use checksums
4f133a48c5f5cfc136285a2c059b31fe5a8047f626c0afe45f1005c289d5325c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2025.

Transparency log

Release files / citrinespdc-0.2.0-py3-none-any.whl

Download URL citrinespdc-0.2.0-py3-none-any.whl
Size 53.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14648048eba339cf9756e9b530a7bc44659b3645a0f9fc0a5129731aa32e9900
BLAKE2b-256 checksum
How to use checksums
0d18d6de6570b92915315ee10b5670b4cbcb51579d31cb38aa32bcd816eabea1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page