3.3.1. lekkersim.Solver

class lekkersim.Solver(name: str = None, structures: List[Structure] = None, connections: Dict[tuple[Structure, Pin], tuple[Structure, Pin]] = None, pin_mapping: Dict[Pin, tuple[Structure, Pin]] = None, param_dic: Dict[str, Any] = None, param_mapping: Dict[str, str] = None)

Class Solver This class defines the simulations. It contains all the structures of the optical componets, and has the methods for running the simulation and accessing the results.

Parameters:
  • structures (list) – list of structures in the solver. Default is None (empty list)

  • connections (dict) – dictionary of tuples (structure (Structure), pin (str)) containing connections {(structure1,pin1):(structure2,pin2)}. Default is None (empty dictionary)

  • param_dic (dict) – dictionary of parameters {param_name (str) : param_value (usually float)}. Default is None (empty dictionary). The provided values are assume as the default parameters

  • param_mapping (dict) – dict for re-definition of the parameters. Useful to include some kind of physic level knowledge in the model. The dictionary is build as: >>> {‘old_name’ : (func, {‘new_name’ : new_default_vaule})}. where func is a function whose parameter are provided by the second dictionary. When simulating, the values of the parameters in the ‘new_name’ dictionary are passed to func and the retunrded values assigned to ‘old_name’.

__init__(name: str = None, structures: List[Structure] = None, connections: Dict[tuple[Structure, Pin], tuple[Structure, Pin]] = None, pin_mapping: Dict[Pin, tuple[Structure, Pin]] = None, param_dic: Dict[str, Any] = None, param_mapping: Dict[str, str] = None) None

Creator

Methods

__init__([name, structures, connections, ...])

Creator

add_param(old_name, func[, default])

Define a paramter of the solver in term of new paramter(s)

add_structure(structure)

Add a structure to the solver

connect(structure1, pin1, structure2, pin2)

Connect two different structures in the solver by the specified pins

connect_all(structure1, basename1, ...)

Connect the two structures using all the pins with the matching basename

cut_structure(structure)

Remove structure from solver, cutting all the connections to other structures (pins in connected structure are not removed, but freed again)

flatten()

Collapse the hyerarchycal structure of the solver in only one level.

flatten_top_level()

Flatten top level of a solver

inspect([max_depth])

Print the full hierarchy of the solver

is_empty()

Checks if solver is empy

map_pins(pin_mapping)

Add mapping of pins

maps_all_pins()

Function for automatically map all pins.

monitor_structure([structure, name])

Add structure to the ones to be monitored for internal modes

prune()

Remove dead branch in the solver hierarchy (the ones ending with an empy solver)

put([source_pin, target_pin, param_mapping])

Function for putting a Solver in another Solver object, and eventually specify connections

remove_structure(structure)

Remove structure from solver, also removing all the connections to other structures

set_param(name[, value])

Set a value for one parameter.

shallow_copy()

Build a shallow copy of the solver

show_connections()

Print all connected pins in the solver

show_default_params()

Print the names of all the top-level parameters and corresponding default value

show_free_pins()

Print all pins of the structure in the solver whcih are not connected.

show_pin_mapping()

If a pin mapping is defined, print only mapped pins

show_structures()

Print all structures in the solver

solve(**kwargs)

Calculates the scattering matrix of the solver

split()

Identify sub-circuits inside the solver and splits them into multiple solvers

update_params(update_dic)

Update the parameters of solver, setting defaults when value is not provides.

Attributes

depth

space

structures