FluxCore Dynamics Documentation

Everything you need to master photonic design

DocumentationPython SDK

Python SDK

Full-featured Python library for scripting and automation

v2.1.0
12 min readLast updated: January 2025Python, SDK, Automation
Python 3.8+
Type Hints
Async Support

Installation

# Install from PyPI
pip install fluxcore

# Or with optional dependencies
pip install fluxcore[all]  # Includes visualization, notebooks support

# For development
pip install fluxcore[dev]  # Includes testing, linting tools

Core

Circuit design, simulation, API client

[viz]

Matplotlib, Plotly visualization

[notebook]

Jupyter notebook integration

Quick Start

Your First Circuit

import fluxcore as fc

# Initialize client with your API key
client = fc.Client(api_key="YOUR_API_KEY")

# Create a new circuit
circuit = client.circuits.create(
    name="Ring Resonator Filter",
    wavelength=1550e-9,
    material_system="silicon"
)

# Add components
ring = circuit.add_component(
    fc.components.RingResonator(
        radius=10.0,  # micrometers
        gap=0.2,
        width=0.45
    ),
    position=(100, 200)
)

input_wg = circuit.add_component(
    fc.components.Waveguide(
        length=50,
        width=0.45
    ),
    position=(0, 200)
)

output_wg = circuit.add_component(
    fc.components.Waveguide(
        length=50,
        width=0.45
    ),
    position=(200, 200)
)

# Connect components
circuit.connect(input_wg.ports.out, ring.ports.input)
circuit.connect(ring.ports.through, output_wg.ports.input)

# Run simulation
result = circuit.simulate(
    wavelength_range=(1500e-9, 1600e-9),
    resolution="high"
)

# Access results
print(f"Insertion loss: {result.insertion_loss:.2f} dB")
print(f"Q-factor: {result.q_factor:.0f}")

# Export to GDS
circuit.export_gds("ring_filter.gds")

Core Modules

fluxcore.circuits

Create, edit, and manage photonic circuit designs.

  • Circuit creation and editing
  • Component placement and routing
  • Parameter sweeps
  • Design rule validation

fluxcore.components

Pre-built photonic component library.

  • Waveguides and tapers
  • Couplers and splitters
  • Ring and disk resonators
  • Modulators and detectors

fluxcore.simulation

FDTD simulation and analysis tools.

  • Full FDTD simulation
  • S-parameter extraction
  • Mode analysis
  • Batch simulation jobs

fluxcore.ai

AI-powered design and optimization.

  • Sketch-to-circuit conversion
  • Performance prediction
  • Inverse design
  • Optimization algorithms

Advanced Examples

Parameter Sweep Optimization

import fluxcore as fc
import numpy as np

client = fc.Client()

# Load existing circuit
circuit = client.circuits.get("cir_abc123")

# Define parameter sweep
radii = np.linspace(8, 12, 10)  # 8 to 12 um
gaps = np.linspace(0.1, 0.3, 10)  # 100 to 300 nm

# Run parallel parameter sweep
sweep = fc.ParameterSweep(circuit)
results = sweep.run(
    parameters={
        "ring_1.radius": radii,
        "ring_1.gap": gaps
    },
    metrics=["insertion_loss", "bandwidth_3dB", "q_factor"],
    parallel=True,
    max_workers=8
)

# Find optimal configuration
best = results.optimize(
    objective="minimize",
    metric="insertion_loss",
    constraints={
        "bandwidth_3dB": {"min": 1e-9},  # At least 1nm bandwidth
        "q_factor": {"min": 10000}
    }
)

print(f"Optimal radius: {best.parameters['ring_1.radius']:.2f} um")
print(f"Optimal gap: {best.parameters['ring_1.gap']:.3f} um")
print(f"Insertion loss: {best.metrics['insertion_loss']:.2f} dB")

# Apply optimal parameters
circuit.update_parameters(best.parameters)
circuit.save()

Async Batch Processing

import fluxcore as fc
import asyncio

async def process_designs(design_files: list[str]):
    """Process multiple designs concurrently."""

    client = fc.AsyncClient()

    async def process_single(filepath: str):
        # Load design
        circuit = await client.circuits.import_gds(filepath)

        # Run simulation
        result = await circuit.simulate(
            wavelength_range=(1500e-9, 1600e-9),
            resolution="high"
        )

        # Generate report
        report = await result.generate_report(
            include_plots=True,
            format="pdf"
        )

        return {
            "file": filepath,
            "insertion_loss": result.insertion_loss,
            "report_url": report.url
        }

    # Process all designs concurrently
    tasks = [process_single(f) for f in design_files]
    results = await asyncio.gather(*tasks)

    return results

# Run batch processing
designs = ["design1.gds", "design2.gds", "design3.gds"]
results = asyncio.run(process_designs(designs))

for r in results:
    print(f"{r['file']}: {r['insertion_loss']:.2f} dB")

AI-Assisted Design

import fluxcore as fc
from fluxcore.ai import SketchToCircuit, InverseDesign

client = fc.Client()

# Convert sketch to circuit
sketch_ai = SketchToCircuit(client)
circuit = sketch_ai.from_image(
    "napkin_sketch.jpg",
    options={
        "wavelength": 1550e-9,
        "material": "silicon",
        "min_feature_size": 100e-9
    }
)

print(f"Recognized {len(circuit.components)} components")
for comp in circuit.components:
    print(f"  - {comp.type}: confidence {comp.confidence:.2%}")

# Use inverse design to optimize
inverse = InverseDesign(client)
optimized = inverse.optimize(
    circuit,
    targets={
        "insertion_loss": {"target": 0.3, "weight": 1.0},
        "bandwidth_3dB": {"target": 2e-9, "weight": 0.5},
        "footprint": {"target": "minimize", "weight": 0.3}
    },
    constraints={
        "min_feature_size": 100e-9,
        "max_iterations": 100
    }
)

print(f"Optimization complete!")
print(f"Insertion loss: {optimized.metrics['insertion_loss']:.2f} dB")
print(f"Improvement: {optimized.improvement:.1%}")

# Save optimized design
optimized.circuit.save()
optimized.circuit.export_gds("optimized_circuit.gds")

Best Practices

Performance Tips

  • Use async client for batch operations
  • Enable caching for repeated simulations
  • Use parameter sweeps instead of loops
  • Stream large result files

Code Quality

  • Use type hints for IDE support
  • Handle exceptions with try/except
  • Store API keys in environment variables
  • Use logging for debugging

Environment Setup

# .env file
FLUXCORE_API_KEY=your_api_key_here
FLUXCORE_WORKSPACE=your_workspace_id

# Python code
import os
import fluxcore as fc

client = fc.Client(
    api_key=os.environ["FLUXCORE_API_KEY"],
    workspace=os.environ.get("FLUXCORE_WORKSPACE")
)

Complete API Reference

Explore the full Python SDK documentation with detailed class references, method signatures, and interactive examples.

Next Steps

Related APIs

Tutorials