CircuitModelView

class ipkiss3.all.CircuitModelView

The CircuitModelView calculates a CompactModel with a circuit solver

It stores parameters and a model to use in circuit simulation.

The model view data is called model. Use _generate_model to define a model on the view. The _generate_model should return either a CompactModel or HierarchicalModel.

Parameters:
layout_view: ( _LayoutView ), *None allowed*
netlist_view: ( NetlistView ), *None allowed*
view_name: String that contains only alphanumeric characters from the ASCII set or contains _$. ASCII set is extended on PY3.

The name of the view

Other Parameters:
solver: str and String that contains only ISO/IEC 8859-1 (extended ASCII py3) or pure ASCII (py2) characters, locked

circuit solver to use

get_smatrix(wavelengths, temperature=None, debug=False, validate_netlist=True, progress_bar=False, verbose=False, spice_path=None, flavor='spice')

Run a frequency-domain simulation of the circuit model in Caphe, returning an S-matrix for all the outside terms.

Parameters:
wavelengthsarray

Array of wavelengths that is contained in the simulation.

temperaturefloat, optional

Ambient temperature to simulate at.

debugboolean, optional

When True, run all models in Python mode. That means they are run in pure Python, allowing you to debug your model more easily.

validate_netlistboolean, optional

When True, validate that the netlist doesn’t have unconnected terms, duplicate nets or optical terms with multiple links.

progress_bar: boolean, optional

Whether or not to display a progress bar for the parameter sweep. Defaults to False.

verbose: boolean, optional

Whether or not to display information about the simulated circuit. Defaults to False.

spice_path: str | Path | None

Optional. When set, the simulation is performed by first netlisting to spice, and running the simulation from the spice file directly.

flavorstr, optional

The flavor of the SPICE netlist to generate. Currently, “spectre” and “spice” are supported. The default is “spice”.

Returns:
smatrix

An smatrix containing the transmissions from/to all terms of this circuit model.

Examples

>>> import numpy as np
>>> import ipkiss3.all as i3
>>> import matplotlib.pyplot as plt
>>> dev = MyDevice()
>>> model = dev.CircuitModel(length=10.)
>>> wavelengths = np.linspace(1.4, 1.6, 1001)
>>> S = model.get_smatrix(wavelengths)
>>> transmission = S['in', 'out', :]
>>> plt.plot(wavelengths, np.abs(transmission) ** 2)
>>> plt.show()
get_time_response(t0, dt, t1, center_wavelength, temperature=None, integration_method='runge_kutta4', debug=False, validate_netlist=True, verbose=False)

Get the transient time response of a CircuitModelView.

This runs a time-domain simulation in the circuit simulator Caphe. The testbench must contain certain excitations and monitors. The output is a structure containing the times that were simulated, and the input on each monitors.

Please check out the tutorial in IPKISS (Tutorials –> Implementing circuit models in IPKISS) for an example and more information.

Parameters:
t0float

Start time.

dtfloat

Time step.

t1float

End time.

center_wavelength: float

The carrier wavelength to simulate at.

temperaturefloat, optional

Ambient temperature to simulate at.

integration_method: str, optional

The Caphe integration method to use, ‘runge_kutta4’ (default) or ‘euler’.

debugboolean, optional

When True, run all models in Python mode. That means they are run in pure Python, allowing you to debug your model more easily.

validate_netlistboolean, optional

When True, validate that the netlist doesn’t have unconnected terms, duplicate nets or optical terms with multiple links.

verbose: boolean, optional

Whether or not to display the debug prints. Defaults to False.

Returns:
result: TimeResponse

Data structure with times and data for all Excitation and Probe elements in the circuit.

Examples

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> import ipkiss3.all as i3
>>> laser = MyLaser()
>>> def my_signal(t):
>>>     return np.sin(t)
>>> testbench = i3.ConnectComponents(
>>>     child_cells={
>>>         'input': i3.FunctionExcitation(port_domain=i3.ElectricalDomain, excitation_function=my_signal),
>>>         'laser': laser,
>>>         'monitor': i3.Probe(port_domain=i3.OpticalDomain)
>>>     },
>>>     links=[('input:out', 'laser:in'),
>>>            ('laser:optical_out', 'monitor:in')]
>>> )
>>> testbench_cm = testbench.CircuitModel()
>>> res = cm.get_time_response(0, 1e-12, 5e-9, 1.55)
>>> plt.plot(res.times, res.data['monitor'])
>>>
to_spice(filename, flavor='spice', max_len=120)

Exports a SPICE netlist in spice or spectre flavor from a CircuitModelView.

This function performs a single, bottom-up recursive traversal to gather all definitions, dependencies, and parameter mappings. It then generates a spice file with subcircuits and concrete values at the top level.

Parameters:
filenamestr

The name of the file to write the SPICE netlist to.

flavorstr, optional

The flavor of the SPICE netlist to generate. Currently, “spectre” and “spice” are supported. The default is “spice”.

max_lenint, optional

The maximum length of a line in the output file. Lines longer than this will be wrapped. The default is 120.

Examples

>>> cmv = MyDevice().CircuitModel()
>>> cmv.to_spice('circuit.spice')