Public API: opics package¶
components
types¶
|
Defines the base component model class used to create new components for a library. |
|
Defines the properties of a compound element or simulated component. |
|
Defines the properties of a waveguide component, can be used in the interconnected between components. |
opics.components
module¶
-
class
opics.components.
Waveguide
(f, length, data_folder, filename, TE_loss, **kwargs)[source]¶ Bases:
opics.components.componentModel
Defines the properties of a waveguide component, can be used in the interconnected between components.
-
class
opics.components.
componentModel
(f, data_folder, filename, nports=0, sparam_attr='', **kwargs)[source]¶ Bases:
object
Defines the base component model class used to create new components for a library.
-
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
ports (list, optional) – List of lists that contains the desired S-parameters, e.g., [[1,1],[1,2],[2,1],[2,2]]. Defaults to None.
xscale (str, optional) – Plotting x axis label. Defaults to “freq”.
yscale (str, optional) – Plotting Y axis label. Defaults to “log”.
- Returns
temp_data (dict) – Dictionary containing the plotting information to be used, including S-parameters data and plotting labels.
-
interpolate_sparameters
(target_f, source_f, source_s)[source]¶ Cubic interpolation of the component sparameter data to match the desired simulation frequency range.
- Parameters
target_f (numpy.ndarray) – The target frequency range onto which the s-parameters will be interpereted on.
source_f (numpy.ndarray) – The source frequency range that the component data has stored.
source_s (numpy.ndarray) – The source s-parameters that the component data has stored.
- Returns
sparameters (numpy.ndarray) – Interpolated s-parameters value over the target frequency range.
-
load_sparameters
(data_folder, filename)[source]¶ Decides whether to load sparameters from npz file or from a raw sparam file or from a look-up table (for tunable components with attributes).
- Parameters
data_folder (pathlib.Path) – The location of the data folder containing s-parameter data files and a look up table.
filename (str) – File name of the component.
- Returns
sparameters (numpy.ndarray) – Array of the component’s s-parameters.
-
plot_sparameters
(ports=None, show_freq=True, scale='log')[source]¶ Plot the component’s S-parameters.
- Parameters
ports (list, optional) – 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, optional) – Flag to determine whether to plot with respect to frequency or wavelength. Defaults to True.
scale (str, optional) – Plotting y axis scale, options available: [“log”, “abs”, “abs_sq”]. Defaults to “log”.
-
write_sparameters
(dirpath, filename, f_data, s_data)[source]¶ Export the simulated s-parameters to a file.
- Parameters
dirpath (pathlib.Path) – Directory of the filed to be saved.
filename (str) – Name of the file to be saved.
f_data (numpy.ndarray) – Frequency range data to be exported.
s_data (numpy.ndarray) – S-parameter data to be exported.
-
-
class
opics.components.
compoundElement
(f, s, nets=None)[source]¶ Bases:
opics.components.componentModel
Defines the properties of a compound element or simulated component. A compound element is a collection of connected components, inherits componentModel OPICS class.
opics.network module¶
-
class
opics.network.
Network
(networkID=None)[source]¶ Bases:
object
specifies the network
-
global_to_local_ports
(net_id, nets)[source]¶ returns which components the net_id refers to and their corresponding local ports
-
opics.sparam_ops module¶
-
opics.sparam_ops.
connect_s
(A, k, B, l, create_composite_matrix=True)[source]¶ connect two n-port networks’ s-matrices together.
specifically, connect port k on network A to port l 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 fxnxnk (int) – port index on A (port indices start from 0)
B (
numpy.ndarray
) – S-parameter matrix of B, shape is fxnxnl (int) – port index on B
- Returns
C (
numpy.ndarray
) – new S-parameter matrix
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, k, l)[source]¶ connect two ports of a single n-port network’s s-matrix.
Specifically, connect port k to port l 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 fxnxnk (int) – port index on A (port indices start from 0)
l (int) – port index on A
- Returns
C (
numpy.ndarray
) – new S-parameter matrix
Notes
The algorithm used to calculate the resultant network is called a ‘sub-network growth’, can be found in 1. The original paper describing the algorithm is given in 2.
References
- 1
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. URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=101955&isnumber=3167
- 2
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. URL: 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)[source]¶ process a spice netlist to setup and simulate a circuit.
-
opics.utils.
fromSI
(value_)[source]¶ converts from SI unit values to metric
- Parameters
value (str) – a value in SI units, e.g. 1.3u
- Returns
float – the value in metric units.
-
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