CircuitModelView

class ipkiss3.all.CircuitModelView

The Model View 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

dependencies()

returns the set of dependencies (child views) of this View.

Should be overloaded by specific views.

get_smatrix(wavelengths, debug=False, validate_netlist=True)

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

Parameters
wavelengthsarray

Array of wavelengths that is contained in the simulation.

debugboolean

When True, run all models in debug 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.

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
>>> from pylab import plt
>>> dev = MyDevice()
>>> model = dev.CircuitModel(length=10.)
>>> wavelengths = np.linspace(1.4, 1.6, 1001)
>>> S = wg.get_smatrix(wavelengths)
>>> transmission = S['in', 'out', :]
>>> plt.plot(wavelengths, np.abs(transmission) ** 2)
>>> plt.show()
get_time_response(t0, dt, t1, center_wavelength, integration_method='runge_kutta4', debug=False, validate_netlist=True)

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.

integration_method: str

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

debugboolean

When True, run all models in debug 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.

Returns
result: TimeResponse

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

Examples

>>> import numpy as np
>>> from pylab import 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'])
>>>