API Documentation¶
C3objs¶
Basic custom objects.
-
class
c3.c3objs.
C3obj
(name, desc='', comment='', params=None)[source]¶ Bases:
object
Represents an abstract object with parameters. To be inherited from.
- Parameters
name (str) – short name that will be used as identifier
desc (str) – longer description of the component
comment (str) – additional information about the component
params (dict) – Parameters in this dict can be accessed and optimized
-
class
c3.c3objs.
Quantity
(value, min_val=None, max_val=None, unit='undefined', symbol='\\alpha')[source]¶ Bases:
object
Represents any physical quantity used in the model or the pulse specification. For arithmetic operations just the numeric value is used. The value itself is stored in an optimizer friendly way as a float between -1 and 1. The conversion is given by
scale (value + 1) / 2 + offset
- Parameters
value (np.array(np.float64) or np.float64) – value of the quantity
min_val (np.array(np.float64) or np.float64) – minimum this quantity is allowed to take
max_val (np.array(np.float64) or np.float64) – maximum this quantity is allowed to take
unit (str) – physical unit
symbol (str) – latex representation
-
get_value
(val=None) → tensorflow.python.framework.ops.Tensor[source]¶ Return the value of this quantity as tensorflow.
- Parameters
val (tf.float64) –
Parameter map¶
ParameterMap class
- class
c3.parametermap.
ParameterMap
(instructions: list = [], generator=None, model=None)[source]¶Bases:
object
Collects information about control and model parameters and provides different representations depending on use.
get_full_params
() → Dict[str, c3.c3objs.Quantity][source]¶Returns the full parameter vector, including model and control parameters.
get_parameter
(par_id: Tuple[str]) → c3.c3objs.Quantity[source]¶Return one the current parameters.
- Parameters
par_id (tuple) – Hierarchical identifier for parameter.
- Returns
- Return type
get_parameters
(opt_map=None) → List[c3.c3objs.Quantity][source]¶Return the current parameters.
- Parameters
opt_map (list) – Hierarchical identifier for parameters.
- Returns
- Return type
list of Quantity
get_parameters_scaled
() → numpy.ndarray[source]¶Return the current parameters. This fuction should only be called by an optimizer. Are you an optimizer?
- Parameters
opt_map (tuple) – Hierarchical identifier for parameters.
- Returns
- Return type
list of Quantity
load_values
(init_point)[source]¶Load a previous parameter point to start the optimization from.
- Parameters
init_point (str) – File location of the initial point
read_config
(filepath: str) → None[source]¶Load a file and parse it to create a ParameterMap object.
- Parameters
filepath (str) – Location of the configuration file
set_parameters
(values: list, opt_map=None) → None[source]¶Set the values in the original instruction class.
- Parameters
values (list) – List of parameter values. Can be nested, if a parameter is matrix valued.
opt_map (list) – Corresponding identifiers for the parameter values.
set_parameters_scaled
(values: tensorflow.python.ops.variables.Variable) → None[source]¶Set the values in the original instruction class. This fuction should only be called by an optimizer. Are you an optimizer?
- Parameters
values (list) – List of parameter values. Matrix valued parameters need to be flattened.
opt_map (list) – Corresponding identifiers for the parameter values.
Experiment module¶
Experiment class that models and simulates the whole experiment.
It combines the information about the model of the quantum device, the control stack and the operations that can be done on the device.
Given this information an experiment run is simulated, returning either processes, states or populations.
-
class
c3.experiment.
Experiment
(pmap: c3.parametermap.ParameterMap = None)[source]¶ Bases:
object
It models all of the behaviour of the physical experiment, serving as a host for the individual parts making up the experiment.
- Parameters
-
evaluate
(seqs)[source]¶ Compute the population values for a given sequence of operations.
- Parameters
seqs (str list) – A list of control pulses/gates to perform on the device.
- Returns
A list of populations
- Return type
list
-
get_gates
()[source]¶ Compute the unitary representation of operations. If no operations are specified in self.opt_gates the complete gateset is computed.
- Returns
A dictionary of gate names and their unitary representation.
- Return type
dict
-
populations
(state, lindbladian)[source]¶ Compute populations from a state or density vector.
- Parameters
state (tf.Tensor) – State or densitiy vector.
lindbladian (boolean) – Specify if conversion to density matrix is needed.
- Returns
Vector of populations.
- Return type
tf.Tensor
-
process
(populations, labels=None)[source]¶ Apply a readout procedure to a population vector. Very specialized at the moment.
- Parameters
populations (list) – List of populations from evaluating.
labels (list) – List of state labels specifying a subspace.
- Returns
A list of processed populations.
- Return type
list
-
propagation
(signal: dict, gate)[source]¶ Solve the equation of motion (Lindblad or Schrödinger) for a given control signal and Hamiltonians.
- Parameters
signal (dict) – Waveform of the control signal per drive line.
ts (tf.float64) – Vector of times.
gate (str) – Identifier for one of the gates.
- Returns
Matrix representation of the gate.
- Return type
unitary
-
quick_setup
(filepath: str) → None[source]¶ Load a quick setup file and create all necessary components.
- Parameters
filepath (str) – Location of the configuration file
-
set_enable_store_unitaries
(flag, logdir, exist_ok=False)[source]¶ Saving of unitary propagators.
- Parameters
flag (boolean) – Enable or disable saving.
logdir (str) – File path location for the resulting unitaries.
-
set_opt_gates
(gates)[source]¶ Specify a selection of gates to be computed.
- Parameters
opt_gates (Identifiers of the gates of interest. Can contain duplicates.) –
-
set_opt_gates_seq
(seqs)[source]¶ Specify a selection of gates to be computed.
- Parameters
opt_gates (Identifiers of the gates of interest. Can contain duplicates.) –