### Router Setup (Example) Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb A basic example of setting up routing using a hypothetical router library. ```jsx import React from 'react'; import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; // Assuming react-router-dom import HomePage from './HomePage'; import AboutPage from './AboutPage'; function AppRouter() { return ( ); } export default AppRouter; ``` -------------------------------- ### Basic Project Setup Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Demonstrates the fundamental structure for initializing a project. This is the starting point for most operations. ```python from flexcompute.photonforge.project import Project project = Project("my_project") print(f"Project '{project.name}' created.") ``` -------------------------------- ### Basic Configuration Example Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb This snippet shows a fundamental configuration setup. Ensure you have the necessary libraries imported. ```python import flexcompute.photonforge as pf # Basic configuration config = { "solver": "FDTD", "grid_size": [100, 100, 100], "wavelength": 1.55e-6 } # Initialize the simulation with the configuration sim = pf.Simulation(config) print("Simulation initialized with configuration:", config) ``` -------------------------------- ### Server-Side Rendering (SSR) Setup Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Conceptual example of setting up server-side rendering. ```javascript // This is a conceptual example and requires a specific SSR framework setup. // Example using Express.js and ReactDOMServer: // import express from 'express'; // import React from 'react'; // import ReactDOMServer from 'react-dom/server'; // import App from './App'; // Your main React App component // const app = express(); // app.get('*', (req, res) => { // const appString = ReactDOMServer.renderToString(); // res.send(` // // // // SSR Example // // //
${appString}
// {/* Your client-side bundle */} // // // `); // }); // app.listen(3000, () => { // console.log('SSR server listening on port 3000'); // }); ``` -------------------------------- ### Basic Project Setup Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Demonstrates the initial setup for a new project. This is a foundational step for most operations. ```python from flexcompute.photonforge.project import Project project = Project("my_project") project.save() ``` -------------------------------- ### Install Publicly Available PDKs Source: https://docs.flexcompute.com/projects/photonforge/en/latest/index.html Install publicly available PDKs for PhotonForge using pip. Examples include SiEPIC and Luxtelligence PDKs. ```bash pip install siepic-forge pip install siepic-sin-forge pip install luxtelligence-lnoi400-forge pip install luxtelligence-ltoi300-forge ``` -------------------------------- ### Basic Time Domain Simulation Setup Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Time_Domain_MZM.ipynb This snippet shows the fundamental setup for a time-domain simulation. It includes necessary imports and the basic structure for running a simulation. Ensure all required libraries are installed. ```python import numpy as np import matplotlib.pyplot as plt # Simulation parameters sim_duration = 1e-6 # seconds sampling_rate = 10e9 # Hz num_samples = int(sim_duration * sampling_rate) t = np.linspace(0, sim_duration, num_samples) # Input signal (e.g., a sine wave) frequency = 1e9 # Hz input_signal = np.sin(2 * np.pi * frequency * t) # MZM parameters (example values) Vpi = 5.0 # V loss = 0.1 # dB # Placeholder for MZM simulation function def simulate_mzm(t, input_signal, Vpi, loss): # This function would contain the core MZM time-domain simulation logic # For demonstration, returning a scaled and delayed version of the input output_signal = input_signal * (1 - loss) * 0.5 * (1 + np.cos(np.pi * Vpi / Vpi)) return output_signal # Run simulation output_signal = simulate_mzm(t, input_signal, Vpi, loss) # Plotting results plt.figure(figsize=(10, 6)) plt.plot(t * 1e9, input_signal, label='Input Signal') plt.plot(t * 1e9, output_signal, label='Output Signal') plt.xlabel('Time (ns)') plt.ylabel('Amplitude') plt.title('MZM Time Domain Simulation') plt.legend() plt.grid(True) plt.show() ``` -------------------------------- ### start() Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_autosummary/photonforge.live_viewer.LiveViewer.html Starts the LiveViewer server. ```APIDOC ## start() ### Description Start the server. ### Returns * **LiveViewer** - The LiveViewer instance. ### Example ```python >>> viewer.start() ``` ``` -------------------------------- ### Basic Analytic Waveguide Setup Source: https://docs.flexcompute.com/projects/photonforge/en/latest/guides/Analytic_Waveguide.ipynb Demonstrates the basic setup for an analytic waveguide. This is useful for initializing and configuring the waveguide for simulations. ```python from photonforge.analytic_waveguide import AnalyticWaveguide # Define waveguide parameters width = 1e-6 # meters height = 0.5e-6 # meters core_index = 1.45 clad_index = 1.44 # Create an AnalyticWaveguide instance wg = AnalyticWaveguide(width, height, core_index, clad_index) print(wg) ``` -------------------------------- ### Database Connection Example Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Conceptual example of establishing a database connection. ```javascript // Example using a hypothetical ORM or driver // const dbConfig = { // host: 'localhost', // user: 'dbuser', // password: 'dbpassword', // database: 'mydatabase' // }; // async function connectDB() { // try { // const connection = await createConnection(dbConfig); // console.log('Database connected successfully'); // return connection; // } catch (error) { // console.error('Database connection failed:', error); // throw error; // } // } ``` -------------------------------- ### Install PhotonForge CLI Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Use this command to install the PhotonForge command-line interface globally. ```bash npm install -g @photonforge/cli ``` -------------------------------- ### Basic Configuration Example Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Demonstrates setting up basic configuration parameters. Ensure you have the necessary libraries imported. ```python import os import sys from flexcompute.photonforge.core.config import Config from flexcompute.photonforge.core.utils import get_project_root def main(): project_root = get_project_root() config_path = os.path.join(project_root, "config.yaml") config = Config(config_path) # Example: Set a configuration value config["example_setting"] = "some_value" config.save() # Example: Get a configuration value value = config.get("example_setting") print(f"Example setting: {value}") if __name__ == "__main__": main() ``` -------------------------------- ### Data Visualization Example Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb This example shows how to visualize processed data using a plotting library. Ensure you have matplotlib installed. ```python import matplotlib.pyplot as plt def visualize_data(data): plt.plot(data) plt.title("Processed Data Visualization") plt.xlabel("Index") plt.ylabel("Value") plt.show() ``` -------------------------------- ### Basic Configuration Example Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Demonstrates how to set up basic configuration options for PhotonForge. This is useful for tailoring the library's behavior to your project's needs. ```javascript // Initialize PhotonForge const pf = photonforge.init(); // Set configuration options pf.config({ // Example configuration: set a default output path outputPath: "./output", // Example configuration: enable verbose logging verbose: true }); ``` -------------------------------- ### Create a Tidy3D Model Source: https://docs.flexcompute.com/projects/photonforge/en/latest/guides/Tidy3D_Model.ipynb Initializes a new Tidy3D model. This is the starting point for any simulation setup. ```python import tidy3d # Create a new model model = tidy3d.Model() ``` -------------------------------- ### Configuration Example Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Shows how to configure the library with specific options. Adjust these settings to tailor the library's behavior. ```javascript import * as FlexCompute from "@flexcompute/photonforge"; // Initialize with configuration FlexCompute.init({ apiKey: "YOUR_API_KEY", timeout: 5000 }); // Use the configured library const data = FlexCompute.fetchData(); console.log(data); ``` -------------------------------- ### setup() Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_autosummary/photonforge.TimeStepper.html Initializes the time stepper with component, time step, and optional carrier frequency and progress display settings. ```APIDOC ## Method setup() ### Description Initialize the time stepper. ### Method `setup(_component_ , _time_step_ , _*_ , _carrier_frequency =0_, _show_progress =True_, _** kwargs_) ### Parameters - **component** (_Component_) – Component for the time stepper. - **time_step** (_float_) – The interval between time steps (in seconds). - **carrier_frequency** (_float_) – The carrier frequency used to construct the time stepper. The carrier should be omitted from the input signals, as it is handled automatically by the time stepper. - **show_progress** (_bool_) – If `True`, show setup progress. - ****kwargs** (_object_) – Keyword arguments forwarded to `setup_state()`. ### Returns This time stepper. ### Return Type TimeStepper ``` -------------------------------- ### DRC: Input Validation Example Source: https://docs.flexcompute.com/projects/photonforge/en/latest/guides/DRC.ipynb Illustrates how input validation might be configured or handled within a DRC setup. ```json { "DRC": { "version": "1.0", "name": "ValidationDRC", "description": "DRC with input validation rules.", "validation_rules": { "field1": { "type": "string", "required": true }, "field2": { "type": "integer", "min": 0 } } } } ``` -------------------------------- ### Initialize a New Project Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Create a new PhotonForge project in the current directory. ```bash forge init ``` -------------------------------- ### DRC: Basic Configuration Source: https://docs.flexcompute.com/projects/photonforge/en/latest/guides/DRC.ipynb Example of a basic DRC configuration. This is useful for initial setup and understanding core parameters. ```json { "DRC": { "version": "1.0", "name": "MyDRC", "description": "A sample DRC configuration." } } ``` -------------------------------- ### Get Modulator Status Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/BTO_EO_Modulator.ipynb This example shows how to retrieve the current status or configuration of the BTO EO Modulator. This can be useful for debugging or monitoring. ```python from photonforge.components import BTO_EO_Modulator modulator = BTO_EO_Modulator() # Assume modulator is already configured # Get current parameters current_params = modulator.get_parameters() ``` -------------------------------- ### Setting and Getting Parameters Source: https://docs.flexcompute.com/projects/photonforge/en/latest/guides/S_Parameters.ipynb Illustrates how to set parameters programmatically and retrieve them later. This is useful for dynamic configuration. ```Go package main import ( "fmt" "github.com/spf13/viper" ) func main() { v.Set("app.name", "MyAwesomeApp") v.Set("app.version", "1.0.0") appName := v.GetString("app.name") appVersion := v.GetString("app.version") fmt.Printf("App Name: %s\n", appName) fmt.Printf("App Version: %s\n", appVersion) } ``` -------------------------------- ### Slice Profile Example Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_autosummary/photonforge.Component.html Demonstrates how to get the slice profile of a component's structures. This can be used to generate PortSpec.path_profiles from existing geometry. ```python >>> component = pf.parametric.straight(port_spec="Strip", length=1) >>> component.slice_profile("x", (0.5, 0)) [(2.5, 0.0, (1, 0)), (0.5, 0.0, (2, 0))] ``` -------------------------------- ### Create Component from Netlist (Example 1) Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_modules/photonforge/netlist.html Demonstrates creating a component with named instances, instance models, direct connections, and top-level ports. ```python from itertools import chain from typing import Any from .extension import Component, Reference from .parametric import route, route_manhattan [docs] def component_from_netlist(netlist: dict[str, Any]) -> Component: """Create a component from a netlist description. Args: netlist: Dictionary with the component description. The only required key is ``'instances'``, which describes the references to all sub-components. See other keys in the example below. Examples: >>> coupler = parametric.dual_ring_coupler( ... port_spec="Strip", ... coupling_distance=0.6, ... radius=4, ... ) ... bus = parametric.ring_coupler( ... port_spec="Strip", ... coupling_distance=0.6, ... radius=4, ... bus_length=5, ... ) >>> netlist1 = { ... "name": "RING", ... "instances": {"COUPLER": coupler, "BUS_0": bus, "BUS_1": bus}, ... "instance models": [ ... ("COUPLER", DirectionalCouplerModel(0.8, -0.5j)), ... ], ... "connections": [ ... (("COUPLER", "P0"), ("BUS_0", "P1")), ... (("BUS_1", "P1"), ("COUPLER", "P3")), ... ], ... "ports": [ ... ("BUS_0", "P0"), ... ("BUS_0", "P2"), ... ("BUS_1", "P2"), ... ("BUS_1", "P0"), ... ], ... "models": [CircuitModel()], ... } >>> component1 = component_from_netlist(netlist1) >>> netlist2 = { ... "instances": [ ... coupler, ... {"component": bus, "origin": (0, -12)}, ... {"component": bus, "origin": (3, 7), "rotation": 180}, ... ], ... "virtual connections": [ ... ((0, "P0"), (1, "P1")), ... ((0, "P2"), (1, "P3")), ... ((2, "P3"), (0, "P1")), ... ], ... "routes": [ ... ((1, "P2"), (2, "P0"), {"radius": 6}), ... ((2, "P1"), (0, "P3"), parametric.route_s_bend), ... ], ... "ports": [ ... (1, "P0", "In"), ... (2, "P2", "Add"), ... ], ... "models": [(CircuitModel(), "Circuit")], ... "active models": {"optical": "Circuit"}, ... } >>> component2 = component_from_netlist(netlist2) >>> spec = cpw_spec("METAL", 3, 1) ... tl = parametric.straight(port_spec=spec, length=20) ... terminal = Terminal( ... "METAL", Rectangle(center=(-10, 20), size=(2, 2)) ... ) ... tl.add_terminal(terminal, "T0") ... netlist3 = { ... "instances": [tl], ... "terminal routes": [ ... ((0, "T0"), (0, ("E0", "gnd0"))), ... ], ... "terminals": [ ... (0, "T0", "GND0"), ... (0, ("E1", "gnd0"), "GND1"), ... ], ... } >>> component3 = component_from_netlist(netlist3) The value in ``"instances"`` can be a dictionary or a list, in which case, index numbers are used in place of the keys. Each value can be a :class:`Component`, a :class:`Reference`, or a dictionary with keyword arguments to create a :class:`Reference`. Sub-components can receive extra models from ``"instance models"``. The last added model for each sub-component will be active. The ``"connections"`` list specifies connections between instances. Each item is of the form ``((key1, port1), (key2, port2))``, indicating that the reference ``key1`` must be transformed to have its ``port1`` connected to ``port2`` from the reference ``key2``. Items in the ``"routes"`` list contain 2 reference ports, similarly to ``"connections"``, plus an optional routing function and a dictionary of keyword arguments to the function: ``((key1, port1), (key2, port2), route_function, kwargs_dict)``. If ``route_function`` is not provided, :func:`photonforge.parametric.route` is used. A list of ``"terminal routes"`` can be also be specified analogously to ``"routes"``, with the difference that only terminal routing functions can be used and :func:`photonforge.parametric.route_manhattan` is the default. Terminals within ports can also be used by replacing the terminal name string with a tuple ``(port_name, terminal_name)``. The ``"ports"`` list specify the top-level component ports derived from instance ports from ``(key, port)`` or ``(key, port, new_name)``. The same goes for the ``"terminals"`` lists, except that terminal names can be replaced by a ``(port_name, terminal_name)`` tuple to indicate a terminals within a port. """ component = Component(netlist.get("name", "")) ``` -------------------------------- ### Basic Tunable MZI Setup Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Tunable_MZI.ipynb Sets up a basic tunable MZI with phase shifters on both arms. This is a foundational example for understanding MZI configuration. ```python from phf import Circuit, Waveguide, MZI, PhaseShifter # Create a circuit c = Circuit(wavelength=1.55e-6) # Add waveguides wg_in = Waveguide(length=1e-6) wg_out = Waveguide(length=1e-6) # Add phase shifters ps1 = PhaseShifter(length=1e-6) ps2 = PhaseShifter(length=1e-6) # Add MZI mzi = MZI(arm1_coupler=0.5, arm2_coupler=0.5, arm1_waveguide=wg_in, arm2_waveguide=wg_out, arm1_phase_shifter=ps1, arm2_phase_shifter=ps2) # Add components to circuit c.add(mzi) # Simulate # result = c.simulate() ``` -------------------------------- ### Initialize and Configure PhotonForge Client Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Set up the PhotonForge client with your API key and desired configuration. This is the first step for interacting with the API. ```python from flexcompute.photonforge.client import PhotonForgeClient client = PhotonForgeClient(api_key="YOUR_API_KEY") ``` -------------------------------- ### Simulate Circuit with Differential CPW Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Differential_CPW.ipynb This example demonstrates how to simulate a quantum circuit containing a Differential CPW using Qiskit Aer. Ensure Aer is installed. ```python from qiskit.circuit.library import DifferentialCPW from qiskit import QuantumCircuit from qiskit_aer import AerSimulator # Create a Differential CPW element diff_cpw = DifferentialCPW() # Add the element to a QuantumCircuit qc = QuantumCircuit(1) nc = qc.add_register(qc.cregs[0]) qc.append(diff_cpw, [0]) # Use AerSimulator for simulation backend = AerSimulator() compiled_circuit = backend.run(qc).result().get_compiled_circuit() print(compiled_circuit.draw()) ``` -------------------------------- ### Custom Model Implementation Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_autosummary/photonforge.Model.html Example of creating a custom model by deriving from pf.Model. It demonstrates how to implement the __init__ and start methods, and how to register the custom model class. ```python class CustomModel(pf.Model): def __init__(self, *, coeff): super().__init__(coeff=coeff) self.coeff = coeff def start(self, component, frequencies, **kwargs): # Do any type of model calculation s_param = numpy.exp(self.coeff * frequencies) s = {("port_in@mode_in", "port_out@mode_out"): s_param} return pf.SMatrix(s) >>> pf.register_model_class(CustomModel) >>> model = CustomModel(coeff=5e-15j) ``` -------------------------------- ### Initialize PhotonForge and LiveViewer Source: https://docs.flexcompute.com/projects/photonforge/en/latest/guides/Layout_Paths.ipynb Sets up the PhotonForge environment and initializes the LiveViewer for real-time visualization. Ensures the default technology is configured. ```python import matplotlib.pyplot as plt import numpy as np import photonforge as pf from photonforge.live_viewer import LiveViewer viewer = LiveViewer() pf.config.default_technology = pf.basic_technology() ``` -------------------------------- ### Start the Development Server Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Launch a local development server with hot-reloading. ```bash forge dev ``` -------------------------------- ### Route Creation with Different Port Positions Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_autosummary/photonforge.parametric.route.html Illustrates creating a route with different port positions compared to the first example. This shows flexibility in defining start and end points. ```python component2 = pf.parametric.route( port1=pf.Port((0, 0), 180, "Strip"), port2=pf.Port((20, 20), 0, "Strip"), radius=5, bend_kwargs={"euler_fraction": 0.5}, s_bend_kwargs={"euler_fraction": 0.5}, ) ``` -------------------------------- ### Initialize and Run a Simulation Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb This snippet demonstrates the basic setup for initializing and running a simulation. Ensure you have the necessary libraries imported. ```python from flexcompute.photonforge.core.simulation import Simulation sim = Simulation() sim.run() print("Simulation finished.") ``` -------------------------------- ### Custom Port Bending Simulation Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Port_Bending_Simulation.ipynb This example shows how to configure custom parameters for port bending simulation, such as bending angle and radius. Ensure these parameters are valid for your simulation setup. ```Python from flexcompute.simulation import Simulation from flexcompute.port_bending import PortBending sim = Simulation() sim.setup_port_bending(PortBending(angle=90, radius=10e-3)) print(sim.get_port_bending_config()) ``` -------------------------------- ### Tidy3DModel.start Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_modules/photonforge/models/tidy3d.html Starts a Tidy3D simulation for a given component and frequencies. It handles port symmetries, source processing, and simulation setup. It returns a runner object that manages the simulation lifecycle. ```APIDOC ## Tidy3DModel.start ### Description Starts a Tidy3D simulation for a given component and frequencies. It handles port symmetries, source processing, and simulation setup. It returns a runner object that manages the simulation lifecycle. ### Method (Implicitly POST or similar, as it starts a process) ### Parameters - **component** (Component) - Required - The component to simulate. - **frequencies** (Sequence[float]) - Required - The frequencies for the simulation. - **inputs** (Sequence[str]) - Optional - Specifies the required sources for the simulation. - **verbose** (bool | None) - Optional - If set, overrides the model's `verbose` attribute. Controls the verbosity of the simulation output. - **cost_estimation** (bool | None) - Optional - If set, simulations are uploaded but not executed. The S matrix will not be computed. ### Returns - Result object with attributes `status` and `s_matrix`. ### Important When using geometry symmetry, the mode numbering in `inputs` is relative to the solver run *with the symmetry applied*, not the mode number presented in the final S matrix. ``` -------------------------------- ### Import PhotonForge and Start LiveViewer Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Add-Drop_Filter_Layout.ipynb Imports the PhotonForge library and initializes a LiveViewer instance for real-time layout visualization. Sets the default technology for the design. ```python import photonforge as pf from photonforge.live_viewer import LiveViewer pf.config.default_technology = pf.basic_technology() viewer = LiveViewer() ``` -------------------------------- ### Tunable MZI with Phase Shifter Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Tunable_MZI.ipynb This example demonstrates adding a phase shifter to one arm of the MZI to enable tuning. It uses the 'phase_shifter' component from gdsfactory. Ensure 'gdsfactory' is installed. ```python import gdsfactory as gf # Create a phase shifter component phase_shifter = gf.components.phase_shifter(length=20, width=10) # Create an MZI and add the phase shifter to one arm mzi_tunable = gf.components.mzi(length_mzi=100, width_mzi=10, coupler_length=5, coupler_gap=0.5) # Add phase shifter to the top arm # Note: This is a conceptual representation. Actual connection might require routing. mzi_tunable.add_ref(phase_shifter, alias='ps_top') # In a real layout, you would connect the phase shifter's ports to the MZI's arm. # Simulate the tunable MZI (using the same dummy simulation as before) def simulate_mzi(component): print(f"Simulating tunable MZI: {component.name}") s = { 'o1,o1': 0+0j, 'o1,o2': 0.707+0.707j, 'o1,o3': 0+0j, 'o1,o4': 0+0j, 'o2,o1': 0.707-0.707j, 'o2,o2': 0+0j, 'o2,o3': 0+0j, 'o2,o4': 0+0j, 'o3,o1': 0+0j, 'o3,o2': 0+0j, 'o3,o3': 0+0j, 'o3,o4': 1+0j, 'o4,o1': 0+0j, 'o4,o2': 0+0j, 'o4,o3': 1+0j, 'o4,o4': 0+0j } return s s_params_tunable = simulate_mzi(mzi_tunable) print(f"Tunable MZI S-parameters: {s_params_tunable}") mzi_tunable.write_gds("mzi_tunable.gds") print("Tunable MZI GDS file written to mzi_tunable.gds") ``` -------------------------------- ### Start EME Simulation and Get Runner Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_modules/photonforge/models/tidy3d.html Initiates an EME simulation for a given component and frequencies, returning a runner object. This method prepares the simulation, identifies component ports, and sets up mesh refinement. ```python @cache_s_matrix def start( self, component: Component, frequencies: Sequence[float], *, verbose: bool | None = None, cost_estimation: bool = False, **kwargs: object, ) -> _EMEModelRunner: """Start computing the S matrix response from a component. Args: component: Component from which to compute the S matrix. frequencies: Sequence of frequencies at which to perform the computation. verbose: If set, overrides the model's `verbose` attribute. cost_estimation: If set, simulations are uploaded, but not executed. S matrix will *not* be computed. **kwargs: Unused. Returns: Result object with attributes ``status`` and ``s_matrix``. Important: When using geometry symmetry, the mode numbering in ``inputs`` is relative to the solver run *with the symmetry applied*, not the mode number presented in the final S matrix. """ simulation, port_groups = self.get_simulation(component, frequencies) folder_name = _filename_cleanup(component.name) classification = frequency_classification(frequencies) component_ports = { name: port.copy(True) for name, port in component.select_ports(classification).items() } if verbose is None: verbose = self.verbose mesh_refinement = ( config.default_mesh_refinement if self.grid_spec is None or isinstance(self.grid_spec, tidy3d.GridSpec) else self.grid_spec ) if len(folder_name) == 0: folder_name = "default" result = _EMEModelRunner( simulation=simulation, ports=component_ports, port_groups=port_groups, mesh_refinement=mesh_refinement, technology=component.technology, folder_name=folder_name, cost_estimation=cost_estimation, verbose=verbose, use_interface_matrix=self._use_interface_matrix, ) return result ``` -------------------------------- ### Build the Project Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Compile your PhotonForge project for production. ```bash forge build ``` -------------------------------- ### Configuration File Example Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb A sample configuration file, e.g., for build tools or application settings. ```javascript // Example: webpack.config.js // const path = require('path'); // module.exports = { // entry: './src/index.js', // output: { // filename: 'bundle.js', // path: path.resolve(__dirname, 'dist'), // }, // module: { // rules: [ // { test: /\.js$/, use: 'babel-loader' }, // ], // }, // }; ``` -------------------------------- ### Verify PhotonForge Installation Source: https://docs.flexcompute.com/projects/photonforge/en/latest/index.html Verify the PhotonForge installation by printing the installed version using a Python command. ```python python -c 'import photonforge as pf; print(pf.__version__)' ``` -------------------------------- ### Start LiveViewer Server Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_autosummary/photonforge.live_viewer.LiveViewer.html Manually start the LiveViewer server. This method is useful if the server was not started automatically during initialization. ```python >>> viewer.start() ``` -------------------------------- ### Running a Simulation Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Example of how to initiate and run a simulation using the Photonforge framework. Requires simulation parameters to be set in the config. ```python from flexcompute.photonforge.core.config import Config from flexcompute.photonforge.core.utils import get_project_root import os def main(): project_root = get_project_root() config_path = os.path.join(project_root, "config.yaml") config = Config(config_path) # Example: Run simulation based on config print("Starting simulation...") # simulation_output = run_simulation(config) # print("Simulation finished.") if __name__ == "__main__": main() ``` -------------------------------- ### Initialize PhotonForge SDK Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb This snippet shows how to initialize the PhotonForge SDK. Ensure you have the necessary configuration before running. ```javascript import { PhotonForge } from "@photonforge/sdk"; const forge = new PhotonForge({ // Configuration options }); ``` -------------------------------- ### Setting up a CI/CD Pipeline Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Conceptual example of a CI/CD pipeline configuration (e.g., GitHub Actions). ```yaml # Example: .github/workflows/main.yml # name: CI/CD Pipeline # on: # push: # branches: [ main ] # jobs: # build: # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v3 # - name: Set up Node.js # uses: actions/setup-node@v3 # with: # node-version: '18' # - name: Install dependencies # run: npm ci # - name: Build project # run: npm run build # # Add deployment steps here (e.g., deploy to Netlify, Vercel, AWS) ``` -------------------------------- ### start Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_autosummary/photonforge.LumpedModel.html Start the S-matrix computation for this lumped model. ```APIDOC ## start ### Description Start the S-matrix computation for this lumped model. ### Method `start(component, frequencies, **kwargs)` ### Parameters #### Path Parameters - **component** (Component) - Description: Component to perform the calculation. - **frequencies** (Sequence[float]) - Description: Frequency values at which to calculate the scattering parameters (in Hz). - ****kwargs** (object) - Description: Additional keyword arguments. ``` -------------------------------- ### start Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_autosummary/photonforge.AnalyticDirectionalCouplerModel.html Start computing the S matrix response from a component. ```APIDOC ## start ### Description Start computing the S matrix response from a component. ### Parameters * **component** (_Component_) – Component from which to compute the S matrix. * **frequencies** (_Sequence_[__float_ _]_) – Sequence of frequencies at which to perform the computation. * ****kwargs** (_object_) – Unused. ### Returns Model result with attributes `status` and `s_matrix`. ### Return type _SMatrix_ ``` -------------------------------- ### Initialize Basic Technology Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Y_Splitter.ipynb Sets up the default technology for the project using predefined parameters for a silicon-on-oxide stack. This is the first step in configuring the optical simulation environment. ```python tech = pf.basic_technology() pf.config.default_technology = tech ``` -------------------------------- ### WebSockets Client Example Source: https://docs.flexcompute.com/projects/photonforge/en/latest/examples/Quick_Start.ipynb Basic example of connecting to a WebSocket server. ```javascript // const socket = new WebSocket('ws://localhost:8080'); // socket.addEventListener('open', function (event) { // console.log('WebSocket connection opened'); // socket.send('Hello Server!'); // }); // socket.addEventListener('message', function (event) { // console.log('Message from server:', event.data); // }); // socket.addEventListener('close', function (event) { // console.log('WebSocket connection closed'); // }); // socket.addEventListener('error', function (event) { // console.error('WebSocket error:', event); // }); ``` -------------------------------- ### Create Project Source: https://docs.flexcompute.com/projects/photonforge/en/latest/_modules/photonforge/pda/_project.html This snippet shows the process of creating a new project, including setting up components, technologies, and permissions. ```python project_components[obj_id] = _ComponentData( doc.read_only(), ui_doc.read_only(), obj, project_id, False ) document = await _find_repo_document(project_id) project_data["components"] = [{"ref": ref} for ref in component_refs.values()] project_data["technologies"] = technologies project_data["config"] = data["config"] document.change(project_data) project = Project(document) project._technologies = project_technologies project._components = project_components visibility, role = _resolved_create_permission(visibility, role) if visibility is not None and role is not None: grant_id = None if visibility == "organization": _, tenant_id = await _user_info() if tenant_id is None: raise RuntimeError( "Current session has no organization. Cannot grant organization permission." ) grant_id = tenant_id await _grant_permission(project.id, visibility, grant_id, role) project._load_module(module_path, True, create_template) return project ```