|
1 | 1 | # AxPhotonicsPreview |
2 | 2 |
|
3 | | -An MCP server for designing, and simulating Photonic Integrated Circuits (PICs) using the Axiomatic AI platform. |
| 3 | +An MCP server for designing, optimizing, and simulating Photonic Integrated Circuits (PICs) using the Axiomatic AI platform. |
4 | 4 |
|
5 | 5 | ## Overview |
6 | 6 |
|
7 | | -The AxPhotonicsPreview Server enables AI assistants to create photonic integrated circuit designs using natural language descriptions. It leverages the Axiomatic AI platform to generate GDSFactory-compatible Python code for photonic components and circuits, and provides tools to simulate them. |
| 7 | +The AxPhotonicsPreview Server enables AI assistants to create photonic integrated circuit designs using natural language descriptions. It leverages the Axiomatic AI platform to generate GDSFactory-compatible Python code for photonic components and circuits, and provides tools to simulate and optimize them. |
8 | 8 |
|
9 | 9 | ## Tools Available |
10 | 10 |
|
@@ -47,6 +47,101 @@ Simulates a previously generated circuit and returns both the wavelength range ( |
47 | 47 |
|
48 | 48 | --- |
49 | 49 |
|
| 50 | +### `optimize_circuit` |
| 51 | + |
| 52 | +Optimizes a photonic circuit by refining the generated code using its formalized statements. |
| 53 | + |
| 54 | +**Parameters:** |
| 55 | + |
| 56 | +- `code_path` (Path, required): Path to the Python file containing the circuit code. |
| 57 | +- `statements_path` (Path, required): Path to the JSON file containing the circuit statements. |
| 58 | + |
| 59 | +**Outputs:** |
| 60 | + |
| 61 | +- **Optimized Python code (`*_optimized.py`)**: Refined version of the input circuit code. |
| 62 | +- **Structured Output**: Returns the optimized file path and the optimized code. |
| 63 | + |
| 64 | +**Example Usage:** |
| 65 | + |
| 66 | +Suppose you have the following circuit in `circuit.py`: |
| 67 | + |
| 68 | +```python |
| 69 | +import gdsfactory as gf |
| 70 | +import cspdk.si220.cband |
| 71 | + |
| 72 | +pdk = cspdk.si220.cband.get_pdk() |
| 73 | +pdk.activate() |
| 74 | + |
| 75 | +c = gf.Component() |
| 76 | + |
| 77 | +# Add MZI component |
| 78 | +mzi = c << pdk.get_component("mzi", delta_length=10, cross_section="strip") |
| 79 | +mzi.move((-34.55, 2.14)) |
| 80 | +mzi.name = "mzi" |
| 81 | + |
| 82 | +# Add ports |
| 83 | +c.add_port("in0", port=mzi.ports["o1"]) |
| 84 | +c.add_port("in1", port=mzi.ports["o2"]) |
| 85 | +c.add_port("out0", port=mzi.ports["o3"]) |
| 86 | +c.add_port("out1", port=mzi.ports["o4"]) |
| 87 | + |
| 88 | +c |
| 89 | +``` |
| 90 | + |
| 91 | +And the following `statements.json`: |
| 92 | + |
| 93 | +```json |
| 94 | +{ |
| 95 | + "statements": [ |
| 96 | + { |
| 97 | + "type": "PARAMETER_CONSTRAINT", |
| 98 | + "text": "The circuit has one input port named 'in0' (corresponding to 'o1') and one output port named 'out0' (corresponding to 'o2').", |
| 99 | + "formalization": { |
| 100 | + "code": "n_ports == 2", |
| 101 | + "default_tolerance": 0.05, |
| 102 | + "mapping": { |
| 103 | + "n_ports": { |
| 104 | + "name": "number_of_ports", |
| 105 | + "arguments": { "port_type": "all", "component": "netlist" } |
| 106 | + } |
| 107 | + } |
| 108 | + }, |
| 109 | + "validation": null |
| 110 | + }, |
| 111 | + { |
| 112 | + "type": "PARAMETER_CONSTRAINT", |
| 113 | + "text": "The circuit has exactly one input port.", |
| 114 | + "formalization": { |
| 115 | + "code": "n_ports_in == 1", |
| 116 | + "default_tolerance": 0.05, |
| 117 | + "mapping": { |
| 118 | + "n_ports_in": { |
| 119 | + "name": "number_of_ports", |
| 120 | + "arguments": { "port_type": "in", "component": "netlist" } |
| 121 | + } |
| 122 | + } |
| 123 | + }, |
| 124 | + "validation": null |
| 125 | + } |
| 126 | + ] |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +Running `optimize_circuit` with these inputs will produce a new file: |
| 131 | + |
| 132 | +- `circuit_optimized.py` – optimized code satisfying the given constraints. |
| 133 | + |
| 134 | +**Sample Output (structured):** |
| 135 | + |
| 136 | +```json |
| 137 | +{ |
| 138 | + "optimized_file_path": "/path/to/circuit_optimized.py", |
| 139 | + "optimized_code": "import gdsfactory as gf ..." |
| 140 | +} |
| 141 | +``` |
| 142 | + |
| 143 | +--- |
| 144 | + |
50 | 145 | ### `list_available_pdks` |
51 | 146 |
|
52 | 147 | Gets a list of all available Process Design Kits (PDKs), with its granted status. |
@@ -184,6 +279,7 @@ This server requires extra dependencies, please see [Check system requirements]( |
184 | 279 | 1. **Design Generation**: Use the MCP server to create initial designs |
185 | 280 | 2. **Local Execution**: Run generated code with GDSFactory |
186 | 281 | 3. **Simulation**: Use `simulate_circuit` to generate wavelength sweeps and notebook results |
| 282 | +4. **Optimization**: Use `optimize_circuit` to refine the circuit code and parameters based on formalized design constraints |
187 | 283 |
|
188 | 284 | --- |
189 | 285 |
|
|
0 commit comments