Scope: This reference lists everything accepted by the current .photon expression parser. There are no user-defined classes, methods, imports, loops, or functions in this language. Optical operations are expression forms, not object methods. Read the guide for the core-first learning path.
| Name / category | Signature | Returns | Behavior and constraints |
|---|---|---|---|
| letSyntax | let name = value in body | type of body | Bind one result for use in the following expression. Bindings are nested expressions, not mutable assignments. A bound optical signal must be consumed exactly once. Example: |
| unpackSyntax | unpack pair as (a, b) in body | type of body | Bind both values of a two-output operation. Use for split, power_split, unitary, coupler, or mzi. Both signals must be consumed. Example: |
| pairSyntax | (a, b) | (Optical, Optical) | Construct an ordered pair of optical signals. Use as the last argument to unitary, coupler, and mzi. This is an expression, not an array. Example: |
| unitSyntax | () | Unit | Finish an expression after all signals are consumed. The Unit literal usually terminates a program. It carries no optical signal. Example: |
| outputCore | output(port) <- signal; body | type of body | Consume a signal at a numbered output port. Output ports are unique nonnegative integers. The semicolon introduces the remaining program; use () when finished. Constraints: port: nonnegative integer, unique Example: |
| inputCore | input(port) | Optical | Create an optical input from the test bench. The default ideal input is 1 mW at 1550 nm; input properties can be changed in Circuit Designer. The same input port cannot be read twice. Constraints: port: nonnegative integer, unique Example: |
| phaseCore | phase(radians, signal) | Optical | Apply an ideal phase rotation. The complex field is multiplied by exp(i × radians). This preserves power in the ideal model. Constraints: radians: finite real Example: |
| splitCore | split(ratio, signal) | (Optical, Optical) | Split the field by core λλ amplitude ratio. The output fields are ratio × E and (1 − ratio) × E. At ratio 0.5, each branch has 25% of input power; use power_split for a power-conserving split. Constraints: ratio: 0 to 1 Example: |
| unitaryCore | unitary(matrix, (a, b)) | (Optical, Optical) | Apply a 2×2 unitary matrix to two optical fields. Matrix may be H, I, or [[a,b],[c,d]] with real or complex entries. The compiler checks unitarity to a numerical tolerance. Constraints: matrix: 2×2 unitary Example: |
| sourceOptical extension | source(power_mw, phase_rad) | Optical | Create a coherent model source. The field has amplitude √power and the given phase. source(0, 0) supplies a zero-power input to a two-input component. Sources are ideal and mutually coherent in this model. Constraints: power_mw ≥ 0; phase_rad finite Example: |
| waveguideOptical extension | waveguide(length_um, loss_db_cm, effective_index, signal) | Optical | Apply compact waveguide phase and loss. Uses path length, distributed loss, effective index, and the configured wavelength to calculate forward propagation. No bend geometry or electromagnetic solver is implied. Constraints: length_um ≥ 0; loss_db_cm ≥ 0; effective_index > 0 Example: |
| attenuateOptical extension | attenuate(loss_db, signal) | Optical | Apply lumped optical loss. The field amplitude is multiplied by 10^(−loss_db/20), so power falls by 10^(−loss_db/10). Constraints: loss_db ≥ 0 Example: |
| kerrOptical extension | kerr(gamma_rad_per_mw, signal) | Optical | Apply illustrative power-dependent phase. The phase shift is gamma_rad_per_mw × input power in mW. The optional loss_db also attenuates the field. This is a compact model, not calibrated material behavior. Constraints: gamma finite; optional loss_db ≥ 0 Example: |
| power_splitOptical extension | power_split(ratio, signal) | (Optical, Optical) | Split input power between two outputs. Output field amplitudes are √(1 − ratio) × E and √ratio × E. At 0.5, each branch has half the input power. Compare core split. Constraints: ratio: 0 to 1 Example: |
| couplerOptical extension | coupler(ratio, (a, b)) | (Optical, Optical) | Mix two coherent fields in an ideal directional coupler. Uses through amplitude √(1 − ratio) and cross amplitude i√ratio. Both inputs and both outputs are optical signals. Constraints: ratio: 0 to 1 Example: |
| mziOptical extension | mzi(phase_rad, coupling_ratio, (a, b)) | (Optical, Optical) | Model a Mach–Zehnder interferometer. Two identical ideal couplers surround a phase shift in one arm. It consumes a pair and returns a pair. Constraints: phase_rad finite; coupling_ratio: 0 to 1 Example: |
| probeOptical extension | probe(threshold_mw, signal) | Optical | Record a threshold measurement and pass the optical signal onward. The measured bit is 1 when input power is at least threshold_mw, otherwise 0. The optical field is passed through unchanged. The bit is a readout, not an optical Boolean value. Constraints: threshold_mw ≥ 0 Example: |
| detectOptical extension | detect(responsivity_a_w, signal); body | type of body | Terminate a signal at a model photodetector. Reports photocurrent in mA as input power in mW × responsivity in A/W. It consumes the optical signal and returns Unit, allowing the next expression after a semicolon. Constraints: responsivity_a_w ≥ 0 Example: |
| realValues | 0.5 · -1 · 1e-3 | Real | Numeric literal for operation parameters. Parameter arithmetic supports multiplication and division, not general addition/subtraction or named numeric variables. Values must be finite. Constraints: finite real Example: |
| piValues | pi · π | Real | Mathematical π in numeric parameters. Both spellings are accepted by the parser. Use for phase angles and unitary matrix entries. Example: |
| HValues | H | 2×2 unitary matrix | Built-in normalized Hadamard matrix. Rows are [1/√2, 1/√2] and [1/√2, −1/√2]. Only accepted as a unitary matrix argument. Example: |
| IValues | I | 2×2 unitary matrix | Built-in identity matrix. Passes the two fields through unchanged in the ideal unitary operation. Only accepted as a matrix argument. Example: |
| complexValues | complex(real, imag) | Complex matrix entry | Specify a complex entry in an explicit unitary matrix. Only accepted inside an explicit 2×2 matrix passed to unitary; not a general complex-number constructor for optical expressions. Constraints: real and imag finite Example: |
| matrixValues | [[a, b], [c, d]] | 2×2 unitary matrix | Explicit matrix literal for unitary. Rows each contain two real or complex entries. The result must be unitary. Constraints: 2×2 and unitary Example: |
| operatorsSyntax | = · in · as · <- · ; · , · ( ) · [ ] · * · / | Syntax | Punctuation and operators supported by the source parser. = binds after let; in starts a body; as names pair outputs; <- connects an output; ; continues after output or detector. * and / are numeric parameter arithmetic only. There is no general + or binary − operator. Example: |
| commentsSyntax | // comment · # comment | Syntax | Line comments. Either marker ignores the remainder of the line. Comments cannot interrupt a token. Example: |
No entries match. Try another name, parameter, or category.
Operation parameters are positional and finite. Optical values obey the one-use rule. The simulator uses an idealized compact model, not a foundry-calibrated device model.
PhotonSharp