Model Libraries

simphony.libraries.siepic

This package contains parameterized models of PIC components from the SiEPIC Electron Beam Lithography Process Development Kit (PDK), which is licensed under the terms of the MIT License.

Terminology

argset

The code and documentation of this module frequently refer to something hereafter known as an “argset”. An argset is a dictionary of parameters to values.

For example, let’s look at the data files available for a y-branch coupler, as available in source_data/y_branch_source. The filename has the format:

Ybranch_Thickness =220 width=500.sparam

When naming argsets, we use lowercase, underescore-delimited words by convention. In this case, our keys are thickness and `width and an argset generated from this filename is:

{'thickness': '220', 'width': '500'}

It is the responsibility of the model processing argsets to convert this to the normalized form used by the model for comparing its parameters to available data files. For example, the y-branch takes the following parameters:

class YBranch(SiEPIC_PDK_Base):
    def __init__(self, thickness=220e-9, width=500e-9, polarization='TE'):
        ...

Note that thickness and width are both floats; lengths, in meters. However, the values parsed from the datafile are strings representing lengths in nanometers. The model therefore creates a normalized set of argsets by converting the values to a form that can be compared with the arguments received by __init__().

Suppose we have the following filename:

te_ebeam_dc_halfring_straight_gap=30nm_radius=3um_width=520nm_thickness=210nm_CoupleLength=0um.dat

An argset generated from this filename would be:

{'gap': '30n', 'radius': '3u', 'width': '520n', 'thickness': '210n', 'couple_length': '0u'}

A normalized version of the above argset would be:

{'gap': 30e-9, 'radius': 3e-6, 'width': 520e-9, 'thickness': 210e-9, 'couple_length': 0.0}

normalized

A variation on argset where the values are formatted to be comparable to the attributes stored by the model. This means that while an argset always reads in strings from datafile names, a normalized argset converts the value to whatever value it actually represents (usually floats).

Future Work

Perhaps we should load the .sparam data files only when s_parameters() is called, instead of each time when values are changed. If 2+ attributes are changed, that turns into a lot of extra (needless) file loading.

class simphony.libraries.siepic.BidirectionalCoupler(thickness=2.2e-07, width=5e-07, **kwargs)

A bidirectional coupler optimized for TE polarized light at 1550 nanometers.

The bidirectional coupler has 4 ports, labeled as pictured. Its efficiently splits light that is input from one port into the two outputs on the opposite side (with a corresponding pi/2 phase shift). Additionally, it efficiently interferes lights from two adjacent inputs, efficiently splitting the interfered signal between the two ports on the opposing side.

ebeam_bdc_te1550.png
Parameters
  • thickness (float, optional) – Waveguide thickness, in meters (default 220 nanometers). Valid values are 210, 220, or 230 nanometers.

  • width (float, optional) – Waveguide width, in meters (default 500 nanometers). Valid values are 480, 500, or 520 nanometers.

on_args_changed()

Callback for when model attributes are changed; updates the stored s-parameters based on current model attributes.

This function is triggered any time an attribute that is in the model’s argument list is changed. For example, if the thickness of the model’s waveguides are changed, and thickness is a member of the class’s _args_keys, this function will automatically be called.

This function should operate only on instance attributes and should not accept parameters.

In summary, on_args_changed() must do the following things:

  1. Disable autoupdate (suspend_autoupdate()).

  2. Normalize all argsets for comparison with model attributes.

  3. Pass the list of normalized argsets to _get_matched_args(), which returns a single normalized argset most closely matching the model’s attributes.

  4. Update the model’s attributes with valid values; values for which we actually have simulation data (so, the values in the argset returned by _get_matched_args().

  5. Load the s-parameters from file and store them in a way they can later be accessed by s_parameters(), a function also implemented on a class-by-class basis.

  6. Set the instance attribute freq_range; if this is not set, all simulations on circuits incorporating this model will fail.

  7. Enable autoupdate (enable_autoupdate()).

Warning

This function will silently change parameters to existing values if no matching data file can be found. For example, if some parameter radius has a requested value of 17 but there only exists data for values 15 and 20, the value of radius may be forced to 15 without raising any errors.

A change to any attribute results in a call to this function. To avoid an infinite recursive loop, you should call suspend_autoupdate() before modifying any instance attributes. At the end of the function, re-enable autoupdate by calling enable_autoupdate().

s_parameters(freqs)

Returns scattering parameters for the element with its given parameters as declared in the optional __init__().

Parameters

freqs (np.array) – The frequency range to get scattering parameters for.

Returns

s – The scattering parameters corresponding to the frequency range. Its shape should be (the number of frequency points x ports x ports). If the scattering parameters are requested for only a single frequency, for example, and the device has 4 ports, the shape returned by s_parameters would be (1, 4, 4).

Return type

np.ndarray

Raises

NotImplementedError – Raised if the subclassing element doesn’t implement this function.

class simphony.libraries.siepic.DirectionalCoupler(gap=2e-07, Lc=1e-05, **kwargs)

A directional coupler optimized for TE polarized light at 1550 nanometers.

The directional coupler has 4 ports, labeled as pictured. Its efficiently splits light that is input from one port into the two outputs on the opposite side (with a corresponding pi/2 phase shift). Additionally, it efficiently interferes lights from two adjacent inputs, efficiently splitting the interfered signal between the two ports on the opposing side.

ebeam_bdc_te1550.png
Parameters
  • gap (float, optional) – Coupling gap distance, in meters (default 200 nanometers).

  • Lc (float, optional) – Length of coupler, in meters (default 10 microns).

on_args_changed()

Callback for when model attributes are changed; updates the stored s-parameters based on current model attributes.

This function is triggered any time an attribute that is in the model’s argument list is changed. For example, if the thickness of the model’s waveguides are changed, and thickness is a member of the class’s _args_keys, this function will automatically be called.

This function should operate only on instance attributes and should not accept parameters.

In summary, on_args_changed() must do the following things:

  1. Disable autoupdate (suspend_autoupdate()).

  2. Normalize all argsets for comparison with model attributes.

  3. Pass the list of normalized argsets to _get_matched_args(), which returns a single normalized argset most closely matching the model’s attributes.

  4. Update the model’s attributes with valid values; values for which we actually have simulation data (so, the values in the argset returned by _get_matched_args().

  5. Load the s-parameters from file and store them in a way they can later be accessed by s_parameters(), a function also implemented on a class-by-class basis.

  6. Set the instance attribute freq_range; if this is not set, all simulations on circuits incorporating this model will fail.

  7. Enable autoupdate (enable_autoupdate()).

Warning

This function will silently change parameters to existing values if no matching data file can be found. For example, if some parameter radius has a requested value of 17 but there only exists data for values 15 and 20, the value of radius may be forced to 15 without raising any errors.

A change to any attribute results in a call to this function. To avoid an infinite recursive loop, you should call suspend_autoupdate() before modifying any instance attributes. At the end of the function, re-enable autoupdate by calling enable_autoupdate().

s_parameters(freqs)

Returns scattering parameters for the element with its given parameters as declared in the optional __init__().

Parameters

freqs (np.array) – The frequency range to get scattering parameters for.

Returns

s – The scattering parameters corresponding to the frequency range. Its shape should be (the number of frequency points x ports x ports). If the scattering parameters are requested for only a single frequency, for example, and the device has 4 ports, the shape returned by s_parameters would be (1, 4, 4).

Return type

np.ndarray

Raises

NotImplementedError – Raised if the subclassing element doesn’t implement this function.

class simphony.libraries.siepic.GratingCoupler(thickness=2.2e-07, deltaw=0, polarization='TE', **kwargs)

A grating coupler optimized for TE polarized light at 1550 nanometers.

The grating coupler efficiently couples light from a fiber array positioned above the chip into the circuit. For the TE mode, the angle is -25 degrees [needs citation].

ebeam_bdc_te1550.png
Parameters
  • thickness (float, optional) – The thickness of the grating coupler, in meters (default 220 nanometers). Valid values are 210, 220, or 230 nanometers.

  • deltaw (float, optional) – FIXME: unknown parameter (default 0). Valid values are -20, 0, or 20.

  • polarization (str, optional) – The polarization of light in the circuit. One of ‘TE’ (default) or ‘TM’.

on_args_changed()

Callback for when model attributes are changed; updates the stored s-parameters based on current model attributes.

This function is triggered any time an attribute that is in the model’s argument list is changed. For example, if the thickness of the model’s waveguides are changed, and thickness is a member of the class’s _args_keys, this function will automatically be called.

This function should operate only on instance attributes and should not accept parameters.

In summary, on_args_changed() must do the following things:

  1. Disable autoupdate (suspend_autoupdate()).

  2. Normalize all argsets for comparison with model attributes.

  3. Pass the list of normalized argsets to _get_matched_args(), which returns a single normalized argset most closely matching the model’s attributes.

  4. Update the model’s attributes with valid values; values for which we actually have simulation data (so, the values in the argset returned by _get_matched_args().

  5. Load the s-parameters from file and store them in a way they can later be accessed by s_parameters(), a function also implemented on a class-by-class basis.

  6. Set the instance attribute freq_range; if this is not set, all simulations on circuits incorporating this model will fail.

  7. Enable autoupdate (enable_autoupdate()).

Warning

This function will silently change parameters to existing values if no matching data file can be found. For example, if some parameter radius has a requested value of 17 but there only exists data for values 15 and 20, the value of radius may be forced to 15 without raising any errors.

A change to any attribute results in a call to this function. To avoid an infinite recursive loop, you should call suspend_autoupdate() before modifying any instance attributes. At the end of the function, re-enable autoupdate by calling enable_autoupdate().

s_parameters(freqs)

Returns scattering parameters for the element with its given parameters as declared in the optional __init__().

Parameters

freqs (np.array) – The frequency range to get scattering parameters for.

Returns

s – The scattering parameters corresponding to the frequency range. Its shape should be (the number of frequency points x ports x ports). If the scattering parameters are requested for only a single frequency, for example, and the device has 4 ports, the shape returned by s_parameters would be (1, 4, 4).

Return type

np.ndarray

Raises

NotImplementedError – Raised if the subclassing element doesn’t implement this function.

class simphony.libraries.siepic.HalfRing(gap=3e-08, radius=1e-05, width=5e-07, thickness=2.2e-07, couple_length=0.0, **kwargs)

A half-ring resonator optimized for TE polarized light at 1550 nanometers.

The halfring has 4 ports, labeled as pictured.

halfring.png
Parameters
  • gap (float, optional) – Coupling distance between ring and straight waveguide in meters (default 30 nanometers).

  • radius (float, optional) – Ring radius in meters (default 10 microns).

  • width (float, optional) – Waveguide width in meters (default 500 nanometers).

  • thickness (float, optional) – Waveguide thickness in meters (default 220 nanometers).

  • coupler_length (float, optional) – Length of the coupling edge, squares out ring; in meters (default 0).

on_args_changed()

Callback for when model attributes are changed; updates the stored s-parameters based on current model attributes.

This function is triggered any time an attribute that is in the model’s argument list is changed. For example, if the thickness of the model’s waveguides are changed, and thickness is a member of the class’s _args_keys, this function will automatically be called.

This function should operate only on instance attributes and should not accept parameters.

In summary, on_args_changed() must do the following things:

  1. Disable autoupdate (suspend_autoupdate()).

  2. Normalize all argsets for comparison with model attributes.

  3. Pass the list of normalized argsets to _get_matched_args(), which returns a single normalized argset most closely matching the model’s attributes.

  4. Update the model’s attributes with valid values; values for which we actually have simulation data (so, the values in the argset returned by _get_matched_args().

  5. Load the s-parameters from file and store them in a way they can later be accessed by s_parameters(), a function also implemented on a class-by-class basis.

  6. Set the instance attribute freq_range; if this is not set, all simulations on circuits incorporating this model will fail.

  7. Enable autoupdate (enable_autoupdate()).

Warning

This function will silently change parameters to existing values if no matching data file can be found. For example, if some parameter radius has a requested value of 17 but there only exists data for values 15 and 20, the value of radius may be forced to 15 without raising any errors.

A change to any attribute results in a call to this function. To avoid an infinite recursive loop, you should call suspend_autoupdate() before modifying any instance attributes. At the end of the function, re-enable autoupdate by calling enable_autoupdate().

s_parameters(freqs)

Returns scattering parameters for the element with its given parameters as declared in the optional __init__().

Parameters

freqs (np.array) – The frequency range to get scattering parameters for.

Returns

s – The scattering parameters corresponding to the frequency range. Its shape should be (the number of frequency points x ports x ports). If the scattering parameters are requested for only a single frequency, for example, and the device has 4 ports, the shape returned by s_parameters would be (1, 4, 4).

Return type

np.ndarray

Raises

NotImplementedError – Raised if the subclassing element doesn’t implement this function.

class simphony.libraries.siepic.SiEPIC_PDK_Base(**kwargs)

A base model that includes pre-implemented functions for reading, building, and selecting appropriate .sparam files.

This class is a template to be subclassed and is not supposed to be initialized on its own. Note that the __init__() function of subclasses ought to create a normalized set of loaded available parameters that can be compared to the parameters passed in upon construction. Additionally, after finding the most matching parameter set, the parameters should be stored locally for future reference.

By default, a recalculation is triggered to update the s-parameters of the model anytime an instance attribute that is also found in _args_keys is modified. To suspend or enable autoupdating, see the functions enable_autoupdate() and suspend_autoupdate().

To define a fully working model that subclasses SiEPIC_PDK_Base, only __init__(), on_args_changed(), s_parameters(), and the class attributes need to be redefined. A subclass’ __init__() function should call super().__init__() and pass in all parameters that will be saved as attributes. The call to super will automatically save them as instance attributes. WARNING: The child class’ __init__() should NOT save instance attributes itself! They should all be passed to super.

Parameters

**kwargs (dict) – The variables that parameterize this component. All are stored as object instance attributes.

args
pins

The default pin names of the device.

Type

tuple of str

_base_path

Path to directory containing .sparam files. This should be redefined in every subclass.

Type

str

_base_file

A string template that can be filled with argument values to load the appropriate .sparam file. This should be redefined in every subclass.

Type

str

_args_keys

The arguments as found in the filename of .sparam files. Note that model kwargs should match these names, as they are matched by string. The _base_file is also filled by matching keywords to the keys defined here. This attribute should be redefined by all subclasses.

Type

list of str

_args_trigger_update

Other attributes that, if changed, should also trigger a callback to on_args_changed(). Can be an empty list.

Type

list of str

_regex

The regular expression that selects available parameters from filenames. This attribute should be redefined by all subclasses.

Type

str

Warning

The child class’ __init__() should NOT save instance attributes itself! They should all be passed to super.

property args

A mapping of args (as found in _args_keys) to the stored attribute values.

Returns

args – A property that generates a dictionary of keys to instance values. Keys are specified by _args_keys.

Return type

dict

enable_autoupdate()

Enables the autoupdate of models when object attributes are modified.

on_args_changed()

Callback for when model attributes are changed; updates the stored s-parameters based on current model attributes.

This function is triggered any time an attribute that is in the model’s argument list is changed. For example, if the thickness of the model’s waveguides are changed, and thickness is a member of the class’s _args_keys, this function will automatically be called.

This function should operate only on instance attributes and should not accept parameters.

In summary, on_args_changed() must do the following things:

  1. Disable autoupdate (suspend_autoupdate()).

  2. Normalize all argsets for comparison with model attributes.

  3. Pass the list of normalized argsets to _get_matched_args(), which returns a single normalized argset most closely matching the model’s attributes.

  4. Update the model’s attributes with valid values; values for which we actually have simulation data (so, the values in the argset returned by _get_matched_args().

  5. Load the s-parameters from file and store them in a way they can later be accessed by s_parameters(), a function also implemented on a class-by-class basis.

  6. Set the instance attribute freq_range; if this is not set, all simulations on circuits incorporating this model will fail.

  7. Enable autoupdate (enable_autoupdate()).

Warning

This function will silently change parameters to existing values if no matching data file can be found. For example, if some parameter radius has a requested value of 17 but there only exists data for values 15 and 20, the value of radius may be forced to 15 without raising any errors.

A change to any attribute results in a call to this function. To avoid an infinite recursive loop, you should call suspend_autoupdate() before modifying any instance attributes. At the end of the function, re-enable autoupdate by calling enable_autoupdate().

suspend_autoupdate()

Prevents the autoupdate of models when object attributes are modified.

class simphony.libraries.siepic.Terminator(w1=5e-07, w2=6e-08, L=1e-05, **kwargs)

A terminator component that dissipates light into free space optimized for TE polarized light at 1550 nanometers.

The terminator dissipates excess light into free space. If you have a path where the light doesn’t need to be measured but you don’t want it reflecting back into the circuit, you can use a terminator to release it from the circuit.

ebeam_bdc_te1550.png
Parameters
  • w1 (float, optional) – Width at connecting end in meters (default 500 nanometers).

  • w2 (float, optional) – Width at terminating end in meters (default 60 nanometers).

  • L (float, optional) – Length of terminator, in meters (default 10 microns).

on_args_changed()

Callback for when model attributes are changed; updates the stored s-parameters based on current model attributes.

This function is triggered any time an attribute that is in the model’s argument list is changed. For example, if the thickness of the model’s waveguides are changed, and thickness is a member of the class’s _args_keys, this function will automatically be called.

This function should operate only on instance attributes and should not accept parameters.

In summary, on_args_changed() must do the following things:

  1. Disable autoupdate (suspend_autoupdate()).

  2. Normalize all argsets for comparison with model attributes.

  3. Pass the list of normalized argsets to _get_matched_args(), which returns a single normalized argset most closely matching the model’s attributes.

  4. Update the model’s attributes with valid values; values for which we actually have simulation data (so, the values in the argset returned by _get_matched_args().

  5. Load the s-parameters from file and store them in a way they can later be accessed by s_parameters(), a function also implemented on a class-by-class basis.

  6. Set the instance attribute freq_range; if this is not set, all simulations on circuits incorporating this model will fail.

  7. Enable autoupdate (enable_autoupdate()).

Warning

This function will silently change parameters to existing values if no matching data file can be found. For example, if some parameter radius has a requested value of 17 but there only exists data for values 15 and 20, the value of radius may be forced to 15 without raising any errors.

A change to any attribute results in a call to this function. To avoid an infinite recursive loop, you should call suspend_autoupdate() before modifying any instance attributes. At the end of the function, re-enable autoupdate by calling enable_autoupdate().

s_parameters(freqs)

Returns scattering parameters for the element with its given parameters as declared in the optional __init__().

Parameters

freqs (np.array) – The frequency range to get scattering parameters for.

Returns

s – The scattering parameters corresponding to the frequency range. Its shape should be (the number of frequency points x ports x ports). If the scattering parameters are requested for only a single frequency, for example, and the device has 4 ports, the shape returned by s_parameters would be (1, 4, 4).

Return type

np.ndarray

Raises

NotImplementedError – Raised if the subclassing element doesn’t implement this function.

class simphony.libraries.siepic.Waveguide(length=0.0, width=5e-07, height=2.2e-07, polarization='TE', sigma_ne=0.05, sigma_ng=0.05, sigma_nd=0.0001, **kwargs)

Model for an waveguide optimized for TE polarized light at 1550 nanometers.

A waveguide easily connects other optical components within a circuit.

ebeam_bdc_te1550.png
Parameters
  • length (float) – Waveguide length in meters (default 0.0 meters).

  • width (float, optional) – Waveguide width in meters (default 500 nanometers).

  • height (float, optional) – Waveguide height in meters (default 220 nanometers).

  • polarization (str, optional) – Polarization of light in the waveguide; one of ‘TE’ (default) or ‘TM’.

  • sigma_ne (float, optional) – Standard deviation of the effective index for monte carlo simulations (default 0.05).

  • sigma_ng (float, optional) – Standard deviation of the group velocity for monte carlo simulations (default 0.05).

  • sigma_nd (float, optional) – Standard deviation of the group dispersion for monte carlo simulations (default 0.0001).

Notes

The sigma_ values in the parameters are used for monte carlo simulations.

freq_range: ClassVar[Tuple[Optional[float], Optional[float]]] = (187370000000000.0, 199862000000000.0)

The valid frequency range for this model.

monte_carlo_s_parameters(freqs)

Returns a monte carlo (randomized) set of s-parameters.

In this implementation of the monte carlo routine, random values are generated for ne, ng, and nd for each run through of the monte carlo simulation. This means that all waveguide elements throughout a single circuit will have the same (random) ne, ng, and nd values. Hence, there is correlated randomness in the monte carlo parameters but they are consistent within a single circuit.

on_args_changed()

Callback for when model attributes are changed; updates the stored s-parameters based on current model attributes.

This function is triggered any time an attribute that is in the model’s argument list is changed. For example, if the thickness of the model’s waveguides are changed, and thickness is a member of the class’s _args_keys, this function will automatically be called.

This function should operate only on instance attributes and should not accept parameters.

In summary, on_args_changed() must do the following things:

  1. Disable autoupdate (suspend_autoupdate()).

  2. Normalize all argsets for comparison with model attributes.

  3. Pass the list of normalized argsets to _get_matched_args(), which returns a single normalized argset most closely matching the model’s attributes.

  4. Update the model’s attributes with valid values; values for which we actually have simulation data (so, the values in the argset returned by _get_matched_args().

  5. Load the s-parameters from file and store them in a way they can later be accessed by s_parameters(), a function also implemented on a class-by-class basis.

  6. Set the instance attribute freq_range; if this is not set, all simulations on circuits incorporating this model will fail.

  7. Enable autoupdate (enable_autoupdate()).

Warning

This function will silently change parameters to existing values if no matching data file can be found. For example, if some parameter radius has a requested value of 17 but there only exists data for values 15 and 20, the value of radius may be forced to 15 without raising any errors.

A change to any attribute results in a call to this function. To avoid an infinite recursive loop, you should call suspend_autoupdate() before modifying any instance attributes. At the end of the function, re-enable autoupdate by calling enable_autoupdate().

regenerate_monte_carlo_parameters()

Regenerates parameters used to generate monte carlo s-matrices.

If a monte carlo method is not implemented for a given model, this method does nothing. However, it can optionally be implemented so that parameters are regenerated once per circuit simulation. This ensures correlation between all components of the same type that reference this model in a circuit. For example, the effective index of a waveguide should not be different for each waveguide in a small circuit; they will be more or less consistent within a single small circuit.

The MonteCarloSweepSimulation calls this function once per run over the circuit.

Notes

This function should not accept any parameters, but may act on instance or class attributes.

s_parameters(freqs)

Get the s-parameters of a waveguide.

Parameters

freqs (float) – The array of frequencies to get s parameters for.

Returns

(freqs, s) – Returns a tuple containing the frequency array, freqs, corresponding to the calculated s-parameter matrix, s.

Return type

tuple

class simphony.libraries.siepic.YBranch(thickness=2.2e-07, width=5e-07, polarization='TE', **kwargs)

A y-branch efficiently splits the input 50/50 between the two outputs. It can also be used as a combiner if used in the opposite direction, combining and interfering the light from two inputs into the one output.

ebeam_bdc_te1550.png
Parameters
  • thickness (float, optional) – Waveguide thickness, in meters (default 220 nanometers). Valid values are 210, 220, or 230 nanometers.

  • width (float, optional) – Waveguide width, in meters (default 500 nanometers). Valid values are 480, 500, or 520 nanometers.

  • polarization (str, optional) – Polarization of light in the circuit, either ‘TE’ (default) or ‘TM’.

on_args_changed()

Callback for when model attributes are changed; updates the stored s-parameters based on current model attributes.

This function is triggered any time an attribute that is in the model’s argument list is changed. For example, if the thickness of the model’s waveguides are changed, and thickness is a member of the class’s _args_keys, this function will automatically be called.

This function should operate only on instance attributes and should not accept parameters.

In summary, on_args_changed() must do the following things:

  1. Disable autoupdate (suspend_autoupdate()).

  2. Normalize all argsets for comparison with model attributes.

  3. Pass the list of normalized argsets to _get_matched_args(), which returns a single normalized argset most closely matching the model’s attributes.

  4. Update the model’s attributes with valid values; values for which we actually have simulation data (so, the values in the argset returned by _get_matched_args().

  5. Load the s-parameters from file and store them in a way they can later be accessed by s_parameters(), a function also implemented on a class-by-class basis.

  6. Set the instance attribute freq_range; if this is not set, all simulations on circuits incorporating this model will fail.

  7. Enable autoupdate (enable_autoupdate()).

Warning

This function will silently change parameters to existing values if no matching data file can be found. For example, if some parameter radius has a requested value of 17 but there only exists data for values 15 and 20, the value of radius may be forced to 15 without raising any errors.

A change to any attribute results in a call to this function. To avoid an infinite recursive loop, you should call suspend_autoupdate() before modifying any instance attributes. At the end of the function, re-enable autoupdate by calling enable_autoupdate().

s_parameters(freqs)

Returns scattering parameters for the y-branch based on its parameters.

Parameters

freqs (np.ndarray) – The frequency range to get scattering parameters for.

Returns

s – The scattering parameters corresponding to the frequency range.

Return type

np.ndarray

simphony.libraries.siepic.closest(sorted_list, value)

Assumes sorted_list is sorted. Returns closest value to value.

If two numbers are equally close, return the smallest number.

Parameters
  • sorted_list (list of ints or floats) –

  • value (int or float) –

Returns

closest

Return type

int or float

References

https://stackoverflow.com/a/12141511/11530613

simphony.libraries.siepic.extract_args(strings, regex, args)
Parameters
  • strings (list of str) – A list of the strings containing parameters to be extracted.

  • regex (str) – A string representing the regex used to extract the values from the strings.

  • args (list of str) – A list of strings that will be used as keys in the dictionary of values returned. These must be in the same order as the parameters will be extracted by the regex.

Returns

argsets – A list of all parameter combinations as dictionaries of args to values extracted from the string.

Return type

list

simphony.libraries.siepic.get_files_from_dir(path)

Gets the string name of every file in a given directory.

Parameters

path (str) – The absolute path to the directory where the files should be found.

Returns

files – A list of filenames as strings.

Return type

list

simphony.libraries.siepic.percent_diff(ideal, actual)

Calculates the percent error.

Ideally the parameters are of a numeric nature. However, if they are of other types (say, string) a simple value of “1.0” is returned, representing the fact that the two objects are utterly, entirely different.

Parameters
  • ideal (float, int, or object) – The verified accepted value.

  • actual (float, int, or object) – The measured or desired value.

Returns

error – The percent error of actual from ideal.

Return type

float

Notes

Percent error is calculated as (ideal - actual) / ideal