zero.circuit module¶
Electronic circuit class to which linear components can be added and on which simulations can be performed.
-
class
zero.circuit.
Circuit
[source]¶ Bases:
object
Represents an electronic circuit containing components and nodes.
A circuit can contain components like
resistors
,capacitors
,inductors
andop-amps
. These are added to the circuit via theadd_component()
method.-
RESERVED_NAMES
= ['all', 'allop', 'allr', 'sum']¶
-
add_component
(component)[source]¶ Add existing component to circuit.
- Parameters
component (
Component
) – The component to add.- Raises
ValueError – If component is None, or already present in the circuit.
-
add_library_opamp
(model, **kwargs)[source]¶ Add library op-amp to circuit.
Keyword arguments can be used to override individual library parameters.
- Parameters
model (
str
) – The op-amp model name.
-
property
capacitors
¶ The circuit capacitors.
-
property
component_names
¶ The names of the components in the circuit.
-
property
element_names
¶ The names of the elements (components and nodes) in the circuit.
- Yields
str
– The element names.
-
property
elements
¶ Circuit nodes and components.
-
get_component
(component_name)[source]¶ Get circuit component by name.
- Parameters
component_name (
str
orComponent
) – The name of the component to fetch.- Returns
Component
– The component.- Raises
ComponentNotFoundError – If the component is not found.
-
get_element
(element_name)[source]¶ Get circuit element (component or node) by name.
- Parameters
element_name (
str
) – The name of the element to fetch.- Returns
- Raises
ElementNotFoundError – If the element is not found.
-
get_node
(node_name)[source]¶ Get circuit node by name.
- Parameters
- Returns
Node
– The node.- Raises
NodeNotFoundError – If the node is not found.
-
get_noise
(noise_name)[source]¶ Get noise by component or node name.
- Parameters
noise_name (
str
) – The name of the noise to fetch.- Returns
Noise
– The noise.- Raises
NoiseNotFoundError – If the noise is not found.
-
has_component
(component_name)[source]¶ Check if component is present in circuit.
- Parameters
component_name (str) – The name of the component to check.
- Returns
bool
– True if component exists, False otherwise.
-
has_element
(element_name)[source]¶ Check if element (component or node) is present in circuit.
- Parameters
element_name (str) – The name of the element to check.
- Returns
bool
– True if element exists, False otherwise.
-
property
has_input
¶ Whether the circuit has an input.
- Returns
bool
– True if the circuit has an input, False otherwise.
-
has_node
(node_name)[source]¶ Check if node is present in circuit.
- Parameters
node_name (str) – The name of the node to check.
- Returns
bool
– True if node exists, False otherwise.
-
property
n_components
¶ The number of components in the circuit.
- Returns
int
– The number of components.
-
property
noise_sources
¶ The noise sources in the circuit.
- Returns
list
ofComponentNoise
orNodeNoise
– The component and node noise sources.
-
property
opamp_noise_sources
¶ The op-amp noise sources in the circuit.
- Yields
Noise
– The op-amp noise source.
-
property
opamp_output_nodes
¶ Circuit op-amp output nodes.
-
property
passive_components
¶ The circuit passive components.
-
remove_component
(component)[source]¶ Remove component from circuit.
- Parameters
- Raises
ComponentNotFoundError – If the component is not found.
-
replace_component
(current_component, new_component)[source]¶ Replace circuit component with a new one.
This can be used to replace components of the same type, but can also replace components of different types as long as they have the same number of nodes.
- Parameters
- Raises
ComponentNotFoundError – If the current component is not in the circuit.
ValueError – If the new component is already in the circuit, or if the nodes of the new component are incompatible with those of the current component.
-
property
resistor_noise_sources
¶ The resistor noise sources in the circuit.
- Yields
Noise
– The resistor noise source.
-
set_inductor_coupling
(inductor_1, inductor_2, coupling_factor=1)[source]¶ Set the coupling factor between the specified inductors
- Parameters
inductor_1, inductor_2 (
str
orcomponents.Inductor
) – The inductors to couple.coupling_factor (any, optional) – The coupling factor between the specified inductors, specified between 0 and 1. A coupling factor less than 1 represents loss.
- Raises
ValueError – If a specified inductor is not an inductor.
-