{"id":49357222,"url":"https://github.com/gdsfactory/circulax","last_synced_at":"2026-04-27T14:01:06.446Z","repository":{"id":339201173,"uuid":"1160760152","full_name":"gdsfactory/circulax","owner":"gdsfactory","description":"Circulax is a differentiable circuit simulation framework built on JAX, Optimistix and Diffrax","archived":false,"fork":false,"pushed_at":"2026-04-27T12:24:34.000Z","size":30916,"stargazers_count":14,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-27T13:21:24.324Z","etag":null,"topics":["circuit","jax","photonics-circuits"],"latest_commit_sha":null,"homepage":"https://gdsfactory.github.io/circulax/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gdsfactory.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-18T10:40:27.000Z","updated_at":"2026-04-27T11:49:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/gdsfactory/circulax","commit_stats":null,"previous_names":["cdaunt/circulus","cdaunt/circulax","gdsfactory/circulax"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/gdsfactory/circulax","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fcirculax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fcirculax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fcirculax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fcirculax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gdsfactory","download_url":"https://codeload.github.com/gdsfactory/circulax/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gdsfactory%2Fcirculax/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32339290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["circuit","jax","photonics-circuits"],"created_at":"2026-04-27T14:00:37.782Z","updated_at":"2026-04-27T14:01:06.440Z","avatar_url":"https://github.com/gdsfactory.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Circulax\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"docs/images/logo-white.svg\"\u003e\n  \u003cimg src=\"docs/images/logo.svg\" alt=\"logo\" width=\"300\"\u003e\n\u003c/picture\u003e\n\n**A differentiable circuit simulator built on JAX.**\nDefine netlists, run transient / DC / AC / harmonic-balance analysis, and differentiate through the solver for gradient-based optimization and inverse design. Circulax aims to be flexible multi-diciplined circuit simulator offering a similar interface to the linear s-parameter solver [SAX](https://github.com/flaport/sax).\n\n**[Read the Documentation here](https://gdsfactory.github.io/circulax/)**\n\n## Installation\n```sh\npip install circulax\n```\n\n## Quickstart\n\nSimulate an underdamped LCR circuit in the time domain:\n\n![LCR transient animation](docs/images/lcr_animation.gif)\n\n```python\nimport diffrax, jax, jax.numpy as jnp\nfrom circulax import compile_circuit\nfrom circulax.components.electronic import Capacitor, Inductor, Resistor, VoltageSource\nfrom circulax.solvers import setup_transient\n\njax.config.update(\"jax_enable_x64\", True)\n\nnet_dict = {\n    \"instances\": {\n        \"GND\": {\"component\": \"ground\"},\n        \"V1\":  {\"component\": \"source_voltage\", \"settings\": {\"V\": 1.0, \"delay\": 0.25e-9}},\n        \"R1\":  {\"component\": \"resistor\",        \"settings\": {\"R\": 10.0}},\n        \"C1\":  {\"component\": \"capacitor\",       \"settings\": {\"C\": 1e-11}},\n        \"L1\":  {\"component\": \"inductor\",        \"settings\": {\"L\": 5e-9}},\n    },\n    \"connections\": {\n        \"GND,p1\": (\"V1,p2\", \"C1,p2\"),\n        \"V1,p1\": \"R1,p1\",  \"R1,p2\": \"L1,p1\",  \"L1,p2\": \"C1,p1\",\n    },\n}\n\nmodels = {\n    \"resistor\": Resistor, \"capacitor\": Capacitor,\n    \"inductor\": Inductor, \"source_voltage\": VoltageSource, \"ground\": lambda: 0,\n}\n\ncircuit = compile_circuit(net_dict, models)\ny_op    = circuit()\nsim     = setup_transient(groups=circuit.groups, linear_strategy=circuit.solver)\n\nsol = sim(\n    t0=0.0, t1=3e-9, dt0=3e-12, y0=y_op,\n    saveat=diffrax.SaveAt(ts=jnp.linspace(0, 3e-9, 500)),\n    max_steps=100_000,\n)\n\nv_cap = circuit.get_port_field(sol.ys, \"C1,p1\")  # capacitor voltage over time\n```\n\n## Defining Components\n\nComponents are plain Python functions — no boilerplate, no subclassing:\n\n```python\nfrom circulax.components.base_component import component, Signals, States\n\n@component(ports=(\"p1\", \"p2\"))\ndef Resistor(signals: Signals, s: States, R: float = 1e3):\n    i = (signals.p1 - signals.p2) / R\n    return {\"p1\": i, \"p2\": -i}, {}          # (currents, charges)\n\n@component(ports=(\"p1\", \"p2\"))\ndef Capacitor(signals: Signals, s: States, C: float = 1e-12):\n    q = C * (signals.p1 - signals.p2)\n    return {}, {\"p1\": q, \"p2\": -q}          # dq/dt becomes current automatically\n```\n\nNon-linear opto-electronic components are just as simple — the Jacobian is computed automatically via [Automatic Differentiation](https://docs.jax.dev/en/latest/automatic-differentiation.html):\n\n```python\n@component(ports=(\"optical_in\", \"anode\", \"cathode\"))\ndef Photodetector(signals: Signals, s: States,\n                  responsivity: float = 0.8, dark_current: float = 1e-9):\n    optical_power = jnp.abs(signals.optical_in) ** 2           # non-linear\n    i_photo = responsivity * optical_power + dark_current\n    i_reflect = -0.01 * signals.optical_in                     # small back-reflection\n    return {\"optical_in\": i_reflect, \"anode\": i_photo, \"cathode\": -i_photo}, {}\n```\n\nExisting [SAX](https://flaport.github.io/sax/) models plug in directly — reuse your photonic PDK as-is:\n\n```python\nimport sax\nfrom circulax.s_transforms import sax_component\n\nStraight = sax_component(sax.models.straight)   # that's it — ready to simulate\n```\n\n## Features\n\n- **Transient** — implicit ODE stepping via [Diffrax](https://docs.kidger.site/diffrax/); handles stiff circuits.\n- **DC operating point** — Newton-Raphson root-finding via [Optimistix](https://github.com/patrick-kidger/optimistix).\n- **Harmonic Balance** — periodic steady state directly in the frequency domain.\n- **AC sweep** — linearise at DC op-point, sweep frequency, return S-parameters.\n- **Automatic differentiation** — differentiate through the solver for gradient-based inverse design.\n- **Hardware-agnostic** — CPU, GPU, or TPU with no code changes.\n- **Mixed-domain** — electronic and photonic circuits in a single netlist.\n\n## Comparison to SPICE\n\nCirculax is a SPICE-like simulator but built with modern tooling so users can easily create their own models in a language they know.\n\n| | SPICE | circulax |\n|---|---|---|\n| Model definition | Verilog-A / hardcoded C++ | Python functions |\n| Derivatives | Hardcoded or compiler-generated | Automatic differentiation |\n| Solver | Fixed/heuristic stepping | Adaptive ODE (Diffrax) |\n| Hardware | CPU-only | CPU / GPU / TPU |\n\n## Inverse Design via Back-propagation\n\nBecause the entire solver is written in JAX, gradients flow end-to-end from a loss function back through the simulation and into component parameters. Use `jax.grad` and standard optimizers to automatically tune circuit designs — the cost is one forward + one backward pass regardless of parameter count.\n\nSee the [Inverse Design guide](docs/inverse_design.md) for a comparison with finite differences and worked examples.\n\n---\n\nCopyright © 2026 Chris Daunt — [Apache-2.0](https://github.com/gdsfactory/circulax/blob/HEAD/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdsfactory%2Fcirculax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgdsfactory%2Fcirculax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgdsfactory%2Fcirculax/lists"}