SymbolicCircuit¶
- class scqubits.core.symbolic_circuit.SymbolicCircuit(nodes_list, branches_list, couplers_list, branch_var_dict, basis_completion='heuristic', use_dynamic_flux_grouping=False, initiate_sym_calc=True, input_string='')[source]¶
Describes a circuit consisting of nodes and branches.
Examples
For a transmon qubit, the input file reads:
# file_name: transmon_num.inp nodes: 2 branches: C 1,2 1 JJ 1,2 1 10
- The Circuit object can be initiated using::
Circuit.from_input_file(“transmon_num.inp”)
- Parameters:
nodes_list (List[Node]) – List of nodes in the circuit
branches_list (List[Branch]) – List of branches connecting the above set of nodes.
couplers_list (List[Coupler]) – List of couplers connecting the branches.
basis_completion (str) – choices are: “heuristic” (default) or “canonical”; selects type of basis for completing the transformation matrix.
use_dynamic_flux_grouping (bool) – set to False by default. Indicates if the flux allocation is done by assuming that flux is time dependent. When set to True, it disables the option to change the closure branches.
initiate_sym_calc (bool) – set to True by default. Initiates the object attributes by calling the function initiate_symboliccircuit method when set to True.
branch_var_dict (Dict[Any | Symbol, Any | float])
input_string (str)
Methods
SymbolicCircuit.__init__
(nodes_list, ...[, ...])Determines whether two sets of branches are disconnected.
Method to identify the different modes in the transformation matrix provided by the user.
SymbolicCircuit.configure
([...])Method to initialize the CustomQCircuit instance and initialize all the attributes needed before it can be passed on to AnalyzeQCircuit.
SymbolicCircuit.create_from_file
(filename)Read initdata and spectral data from file, and use those to create a new SpectrumData object.
SymbolicCircuit.default_params
()SymbolicCircuit.deserialize
(io_data)Take the given IOData and return an instance of the described class, initialized with the data stored in io_data.
SymbolicCircuit.filewrite
(filename)Convenience method bound to the class.
SymbolicCircuit.from_yaml
(input_string[, ...])Constructs the instance of Circuit from an input string. Here is an example of an input string that is used to initiate an object of the class SymbolicCircuit::.
Returns the Hamiltonian of the circuit in terms of the new variables \(\theta_i\).
Returns four symbolic expressions: lagrangian_θ, potential_θ, lagrangian_φ, potential_φ, where θ represents the set of new variables and φ represents the set of node variables
Calculate the inverse of the transformed capacitance matrix C_mat_theta.
Convert the content of the current class instance into IOData format.
Calculate the transformed capacitance matrix C_mat_theta.
Updates the param init val for param_name.
Evaluates the boundary conditions and constructs the variable transformation matrix, which is returned along with the dictionary var_categories which classifies the types of variables present in the circuit.
- static are_branchsets_disconnected(branch_list1, branch_list2)¶
Determines whether two sets of branches are disconnected.
- check_transformation_matrix(transformation_matrix, enable_warnings=True)¶
Method to identify the different modes in the transformation matrix provided by the user.
- Parameters:
transformation_matrix (
ndarray
) – numpy ndarray which is a square matrix having the dimensions of the number of nodes present in the circuit.warnings – If False, will not raise the warnings regarding any unidentified modes. It is set to True by default.
enable_warnings (bool)
- Return type:
Dict
[str
,List
[int
]]- Returns:
A dictionary of lists which has the variable indices classified with var indices corresponding to the rows of the transformation matrix
- configure(transformation_matrix=None, closure_branches=[], use_dynamic_flux_grouping=None)[source]¶
Method to initialize the CustomQCircuit instance and initialize all the attributes needed before it can be passed on to AnalyzeQCircuit.
- Parameters:
transformation_matrix (
Optional
[ndarray
]) – array used to set a transformation matrix other than the one generated by the method variable_transformation_matrix.closure_branches (
List
[Union
[Branch
,Dict
[Branch
,float
]]]) – Each element of the list corresponds to one external flux variable. If the element is a branch the external flux will be associated with that branch. If the element is a dictionary, the external flux variable will be distributed across the branches according to the dictionary with the factor given as a key value.use_dynamic_flux_grouping (bool | None)
- classmethod create_from_file(filename)¶
Read initdata and spectral data from file, and use those to create a new SpectrumData object.
- Returns:
new SpectrumData object, initialized with data read from file
- Return type:
- Parameters:
filename (str)
- classmethod deserialize(io_data)¶
Take the given IOData and return an instance of the described class, initialized with the data stored in io_data.
- Return type:
TypeVar
(SerializableType
, bound= Serializable)- Parameters:
io_data (IOData)
- filewrite(filename)¶
Convenience method bound to the class.
Simply accesses the write function.
- Return type:
None
- Parameters:
filename (str)
- classmethod from_yaml(input_string, from_file=True, basis_completion='heuristic', use_dynamic_flux_grouping=False, initiate_sym_calc=True)¶
Constructs the instance of Circuit from an input string. Here is an example of an input string that is used to initiate an object of the class SymbolicCircuit:
#zero-pi.yaml nodes : 4 # zero-pi branches: - [JJ, 1,2, EJ = 10, 20] - [JJ, 3,4, 10, 20] - [L, 2,3, 0.008] - [L, 4,1, 0.008] - [C, 1,3, 0.02] - [C, 2,4, 0.02]
- Parameters:
input_string (
str
) – String describing the number of nodes and branches connecting then along with their parametersfrom_file (
bool
) – Set to True by default, when a file name should be provided to input_string, else the circuit graph description in YAML should be provided as a string.basis_completion (
str
) – choices: “heuristic” or “canonical”; used to choose a type of basis for completing the transformation matrix. Set to “heuristic” by default.use_dynamic_flux_grouping (bool) – set to False by default. Indicates if the flux allocation is done by assuming that flux is time dependent. When set to True, it disables the option to change the closure branches.
initiate_sym_calc (
bool
) – set to True by default. Initiates the object attributes by calling the function initiate_symboliccircuit method when set to True. Set to False for debugging.
- Returns:
Instance of the class SymbolicCircuit
- generate_symbolic_hamiltonian(substitute_params=False, reevaluate_lagrangian=False)[source]¶
Returns the Hamiltonian of the circuit in terms of the new variables \(\theta_i\).
- Parameters:
substitute_params – When set to True, the symbols defined for branch parameters will be substituted with the numerical values in the respective Circuit attributes.
reevaluate_lagrangian (bool)
- Return type:
Expr
- generate_symbolic_lagrangian(substitute_params=False)[source]¶
Returns four symbolic expressions: lagrangian_θ, potential_θ, lagrangian_φ, potential_φ, where θ represents the set of new variables and φ represents the set of node variables
- Return type:
Tuple
[Expr
,Expr
,Expr
,Expr
]- Parameters:
substitute_params (bool)
- inv_trans_cap_matrix(substitute_params=False)[source]¶
Calculate the inverse of the transformed capacitance matrix C_mat_theta.
- Return type:
Expr
- Parameters:
substitute_params (bool)
- serialize()¶
Convert the content of the current class instance into IOData format.
- Return type:
- trans_cap_matrix(substitute_params=False)[source]¶
Calculate the transformed capacitance matrix C_mat_theta.
- Parameters:
substitute_params (bool) – If True, substitute symbolic parameters with their numerical values.
- Returns:
The transformed capacitance matrix C_mat_theta.
- Return type:
numpy.ndarray or sympy.Matrix
- variable_transformation_matrix()¶
Evaluates the boundary conditions and constructs the variable transformation matrix, which is returned along with the dictionary var_categories which classifies the types of variables present in the circuit.
- Return type:
Tuple
[ndarray
,Dict
[str
,List
[int
]]]- Returns:
tuple of transformation matrix for the node variables and var_categories dict which classifies the variable types for each variable index