Public API: opics package
Contents
Public API: opics package¶
components
types¶
|
Defines the base component model class used to create new components for a library. |
opics.components
module¶
- class opics.components.componentModel(f=None, nports=2, s=None, data_folder=None, filename=None, sparam_attr=None, **kwargs)[source]¶
Bases:
object
Defines the base component model class used to create new components for a library.
- Parameters
f (numpy.ndarray) – Frequency datapoints.
nports (int) – Number of ports in the component. Defaults to 2.
s (numpy.ndarray, optional) – S-parameter data. Defaults to None.
data_folder (pathlib.Path) – The location of the data folder containing s-parameter data files and the XML look-up-table.
filename (str) – Name of the XML look-up-table file.
sparam_attr (str, optional) – Look-up-table attribute Defaults to None.
- get_data(ports=None, xscale='freq', yscale='log')[source]¶
Get the S-parameters data for specific [input,output] port combinations, to be used for plotting functionalities. (WARNING: unused, to be used in plot_sparameters)
- Parameters
- Returns
Dictionary containing the plotting information to be used, including S-parameters data and plotting labels.
- Return type
temp_data
- interpolate_sparameters(target_f, source_f, source_s)[source]¶
Cubic interpolation of the component sparameter data to match the desired simulation frequency range.
- Parameters
- Returns
Interpolated s-parameters value over the target frequency range.
- Return type
sparameters
- load_sparameters(data_folder, filename)[source]¶
Loads sparameters either from an npz file or from a raw sparam file using a look-up table.
- plot_sparameters(ports=None, show_freq=True, scale='log', interactive=False)[source]¶
Plot the component’s S-parameters.
- Parameters
ports (
Optional
[List
[List
[int
]]]) – List of lists that contains the desired S-parameters, e.g., [[1,1],[1,2],[2,1],[2,2]]. Defaults to None.show_freq (
bool
) – Flag to determine whether to plot with respect to frequency or wavelength. Defaults to True.scale (
str
) – Plotting y axis scale, options available: [“log”, “abs”, “abs_sq”]. Defaults to “log”.interactive (
bool
) – Make the plots interactive or not.
opics.network module¶
- class opics.network.Network(network_id=None, f=None, mp_config={'close_pool': False, 'enabled': False, 'proc_count': 0})[source]¶
Bases:
object
Defines a circuit or a network.
- Parameters
mp_config (
Dict
) –Enable/Disable multiprocessing (disabled by default); Expects the following information:
”enabled” : bool - enable/disable multiprocessing,
”proc_count”: int - process count
”close_pool”: bool - Should the solver terminate all the processes after the simulation is finished.
- add_component(component, params={}, component_id=None)[source]¶
Adds component to a network.
- Parameters
component (
componentModel
) – An instance of componentModel class.params (
Dict
) – Component parameter values.
- connect(component_A_id, port_A, component_B_id, port_B)[source]¶
Connects two components together.
- Parameters
component_A_id (
Union
[str
,componentModel
]) – A component ID or an instance of componentModel class.port_A (
int
) – Port number of component_Acomponent_B_id (
Union
[str
,componentModel
]) – A component ID or an instance of componentModel class.port_B (
int
) – Port number of component_B
- enable_mp(process_count=0, close_pool=True)[source]¶
Enables OPICS multiprocessing
- Parameters
process_count (
int
) – Number of processes to start. Leave the default value if not sure (let the system decide). Otherwise, use multiprocessing.cpu_count() to know the maximum number of processes that can be run safely.close_pool (
bool
) – Whether to terminate all the processes after the simulation is done.
- global_to_local_ports(net_id, nets)[source]¶
Maps the net_id to components and their local port numbers.
- initiate_global_netlist()[source]¶
Initiates a global netlist with negative indices, overwrite indices that are used in the circuit with positive values.
- opics.network.bulk_add_component(network, components_data)[source]¶
Allows for bulk adding of components
- opics.network.inst_components(component_data)[source]¶
Given a component class, component parameter data, and component id, returns an instance of the component class.
- Parameters
component_data (
dict
) –{“component”: component_class, “params”: component_parameters, “component_id”, custom_component_id}
Example: {“component”: ebeam.Waveguide, “params”:{“f”: circuit.f, “length”: 10e-6}, “component_id”: “test_waveguide”}
opics.sparam_ops module¶
Functions operating on s-parameter matrices
- opics.sparam_ops.connect_s(A, port_idx_A, B, port_idx_B, create_composite_matrix=True)[source]¶
connect two n-port networks’ s-matrices together.
specifically, connect port port_idx_A on network A to port port_idx_B on network B. The resultant network has nports = (A.rank + B.rank-2). This function operates on, and returns s-matrices. The function
connect()
operates onNetwork
types.- Parameters
A (
numpy.ndarray
) – S-parameter matrix of A, shape is fxnxnport_idx_A (int) – port index on A (port indices start from 0)
B (
numpy.ndarray
) – S-parameter matrix of B, shape is fxnxnport_idx_B (int) – port index on B
- Returns
C – new S-parameter matrix
- Return type
Notes
internally, this function creates a larger composite network and calls the
innerconnect_s()
function. see that function for more details about the implementationSee also
connect
operates on
Network
typesinnerconnect_s
function which implements the connection connection algorithm
- opics.sparam_ops.innerconnect_s(A, port_idx_A, port_idx_B)[source]¶
connect two ports of a single n-port network’s s-matrix.
Specifically, connect port port_idx_A to port port_idx_B on A. This results in a (n-2)-port network. This function operates on, and returns s-matrices. The function
innerconnect()
operates onNetwork
types.- Parameters
A (
numpy.ndarray
) – S-parameter matrix of A, shape is fxnxnport_idx_A (int) – port index on A (port indices start from 0)
port_idx_B (int) – port index on A
- Returns
C – new S-parameter matrix
- Return type
Notes
The algorithm used to calculate the resultant network is called a ‘sub-network growth’, can be found in [#]_. The original paper describing the algorithm is given in [#]_.
References
Compton, R.C.; , “Perspectives in microwave circuit analysis,”
Circuits and Systems, 1989., Proceedings of the 32nd Midwest Symposium on , vol., no., pp.716-718 vol.2, 14-16 Aug 1989. http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=101955&isnumber=3167
Filipsson, Gunnar;
“A New General Computer Algorithm for S-Matrix Calculation of Interconnected Multiports,” Microwave Conference, 1981. 11th European , vol., no., pp.700-704, 7-11 Sept. 1981. http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4131699&isnumber=4131585
opics.utils module¶
- opics.utils.LUT_processor(filedir, lutfilename, lutdata, nports, sparam_attr, verbose=False)[source]¶
process look up table data
- opics.utils.NetlistProcessor(spice_filepath, Network, libraries, c_, circuitData, verbose=True)[source]¶
Processes a spice netlist to setup and simulate a circuit.
- Parameters
spice_filepath – Path to the spice netlist file.
Network –
- class opics.utils.netlistParser(mainfile_path)[source]¶
Bases:
object
A netlist parser to read spi files generated by SiEPIC tools
- opics.utils.universal_sparam_filereader(nports, sfilename, sfiledir, format_type='auto')[source]¶
Function to automatically detect the sparameter file format and use appropriate method to delimit and format sparam data
This function is a unified version of sparameter reader function defined in https://github.com/BYUCamachoLab/simphony
- Parameters
nports (
int
) – Number of portssfilename (
str
) – XML look-up-table filenamesfiledir (
PosixPath
) – Path to the directory containing the XML fileformat_type (
str
) – Format type. For more information: https://support.lumerical.com/hc/en-us/articles/360036618513-S-parameter-file-formats
- Return type