223 lines
8.7 KiB
Plaintext
223 lines
8.7 KiB
Plaintext
---
|
||
title: UnitarySimulatorPy
|
||
description: API reference for qiskit.providers.basicaer.UnitarySimulatorPy
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.providers.basicaer.UnitarySimulatorPy
|
||
---
|
||
|
||
# UnitarySimulatorPy
|
||
|
||
<Class id="qiskit.providers.basicaer.UnitarySimulatorPy" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.46/qiskit/providers/basicaer/unitary_simulator.py" signature="qiskit.providers.basicaer.UnitarySimulatorPy(configuration=None, provider=None, **fields)" modifiers="class">
|
||
Bases: [`BackendV1`](qiskit.providers.BackendV1 "qiskit.providers.backend.BackendV1")
|
||
|
||
Python implementation of a unitary simulator.
|
||
|
||
<Admonition title="Deprecated since version 0.46.0" type="danger">
|
||
The class `qiskit.providers.basicaer.unitary_simulator.UnitarySimulatorPy` is deprecated as of qiskit 0.46.0. It will be removed in Qiskit 1.0.0. The qiskit.providers.basicaer module has been superseded by qiskit.providers.basic\_provider. The new module has no replacement for this class. Use the qiskit.quantum\_info.Operator class instead.
|
||
</Admonition>
|
||
|
||
## Attributes
|
||
|
||
### DEFAULT\_CONFIGURATION
|
||
|
||
<Attribute id="qiskit.providers.basicaer.UnitarySimulatorPy.DEFAULT_CONFIGURATION" attributeValue="{'backend_name': 'unitary_simulator', 'backend_version': '1.1.0', 'basis_gates': ['u1', 'u2', 'u3', 'rz', 'sx', 'x', 'cx', 'id', 'unitary'], 'conditional': False, 'coupling_map': None, 'description': 'A python simulator for unitary matrix corresponding to a circuit', 'gates': [{'name': 'u1', 'parameters': ['lambda'], 'qasm_def': 'gate u1(lambda) q { U(0,0,lambda) q; }'}, {'name': 'u2', 'parameters': ['phi', 'lambda'], 'qasm_def': 'gate u2(phi,lambda) q { U(pi/2,phi,lambda) q; }'}, {'name': 'u3', 'parameters': ['theta', 'phi', 'lambda'], 'qasm_def': 'gate u3(theta,phi,lambda) q { U(theta,phi,lambda) q; }'}, {'name': 'rz', 'parameters': ['phi'], 'qasm_def': 'gate rz(phi) q { U(0,0,phi) q; }'}, {'name': 'sx', 'parameters': [], 'qasm_def': 'gate sx(phi) q { U(pi/2,7*pi/2,pi/2) q; }'}, {'name': 'x', 'parameters': [], 'qasm_def': 'gate x q { U(pi,7*pi/2,pi/2) q; }'}, {'name': 'cx', 'parameters': [], 'qasm_def': 'gate cx c,t { CX c,t; }'}, {'name': 'id', 'parameters': [], 'qasm_def': 'gate id a { U(0,0,0) a; }'}, {'name': 'unitary', 'parameters': ['matrix'], 'qasm_def': 'unitary(matrix) q1, q2,...'}], 'local': True, 'max_shots': 0, 'memory': False, 'n_qubits': 14, 'open_pulse': False, 'simulator': True, 'url': 'https://github.com/Qiskit/qiskit-terra'}" />
|
||
|
||
### DEFAULT\_OPTIONS
|
||
|
||
<Attribute id="qiskit.providers.basicaer.UnitarySimulatorPy.DEFAULT_OPTIONS" attributeValue="{'chop_threshold': 1e-15, 'initial_unitary': None}" />
|
||
|
||
### MAX\_QUBITS\_MEMORY
|
||
|
||
<Attribute id="qiskit.providers.basicaer.UnitarySimulatorPy.MAX_QUBITS_MEMORY" attributeValue="14" />
|
||
|
||
### options
|
||
|
||
<Attribute id="qiskit.providers.basicaer.UnitarySimulatorPy.options">
|
||
Return the options for the backend
|
||
|
||
The options of a backend are the dynamic parameters defining how the backend is used. These are used to control the [`run()`](#qiskit.providers.basicaer.UnitarySimulatorPy.run "qiskit.providers.basicaer.UnitarySimulatorPy.run") method.
|
||
</Attribute>
|
||
|
||
### version
|
||
|
||
<Attribute id="qiskit.providers.basicaer.UnitarySimulatorPy.version" attributeValue="1" />
|
||
|
||
## Methods
|
||
|
||
### configuration
|
||
|
||
<Function id="qiskit.providers.basicaer.UnitarySimulatorPy.configuration" signature="configuration()">
|
||
Return the backend configuration.
|
||
|
||
**Returns**
|
||
|
||
the configuration for the backend.
|
||
|
||
**Return type**
|
||
|
||
[BackendConfiguration](qiskit.providers.models.BackendConfiguration "qiskit.providers.models.BackendConfiguration")
|
||
</Function>
|
||
|
||
### name
|
||
|
||
<Function id="qiskit.providers.basicaer.UnitarySimulatorPy.name" signature="name()">
|
||
Return the backend name.
|
||
|
||
**Returns**
|
||
|
||
the name of the backend.
|
||
|
||
**Return type**
|
||
|
||
[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.12)")
|
||
</Function>
|
||
|
||
### properties
|
||
|
||
<Function id="qiskit.providers.basicaer.UnitarySimulatorPy.properties" signature="properties()">
|
||
Return the backend properties.
|
||
|
||
**Returns**
|
||
|
||
the configuration for the backend. If the backend does not support properties, it returns `None`.
|
||
|
||
**Return type**
|
||
|
||
[BackendProperties](qiskit.providers.models.BackendProperties "qiskit.providers.models.BackendProperties")
|
||
</Function>
|
||
|
||
### provider
|
||
|
||
<Function id="qiskit.providers.basicaer.UnitarySimulatorPy.provider" signature="provider()">
|
||
Return the backend Provider.
|
||
|
||
**Returns**
|
||
|
||
the Provider responsible for the backend.
|
||
|
||
**Return type**
|
||
|
||
[Provider](qiskit.providers.Provider "qiskit.providers.Provider")
|
||
</Function>
|
||
|
||
### run
|
||
|
||
<Function id="qiskit.providers.basicaer.UnitarySimulatorPy.run" signature="run(run_input, **backend_options)">
|
||
Run experiments in run\_input asynchronously.
|
||
|
||
<Admonition title="Deprecated since version 0.46.0" type="danger">
|
||
Using a QasmQobj for the first argument to UnitarySimulatorPy.run() is deprecated as of qiskit 0.46.0. It will be removed no earlier than 3 months after the release date.
|
||
</Admonition>
|
||
|
||
**Parameters**
|
||
|
||
* **run\_input** (*Qobj,* [*QuantumCircuit*](qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")*,* [*list*](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.12)")) – payload of the experiment
|
||
* **backend\_options** ([*dict*](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.12)")) – backend options
|
||
|
||
**Returns**
|
||
|
||
derived from BaseJob
|
||
|
||
**Return type**
|
||
|
||
[BasicAerJob](qiskit.providers.basicaer.BasicAerJob "qiskit.providers.basicaer.BasicAerJob")
|
||
|
||
Additional Information:
|
||
|
||
```python
|
||
backend_options: Is a dict of options for the backend. It may contain
|
||
* "initial_unitary": matrix_like
|
||
* "chop_threshold": double
|
||
|
||
The "initial_unitary" option specifies a custom initial unitary
|
||
matrix for the simulator to be used instead of the identity
|
||
matrix. This size of this matrix must be correct for the number
|
||
of qubits in all experiments in the run_input.
|
||
|
||
The "chop_threshold" option specifies a truncation value for
|
||
setting small values to zero in the output unitary. The default
|
||
value is 1e-15.
|
||
|
||
Example::
|
||
|
||
backend_options = {
|
||
"initial_unitary": np.array([[1, 0, 0, 0],
|
||
[0, 0, 0, 1],
|
||
[0, 0, 1, 0],
|
||
[0, 1, 0, 0]])
|
||
"chop_threshold": 1e-15
|
||
}
|
||
```
|
||
</Function>
|
||
|
||
### run\_experiment
|
||
|
||
<Function id="qiskit.providers.basicaer.UnitarySimulatorPy.run_experiment" signature="run_experiment(experiment)">
|
||
Run an experiment (circuit) and return a single experiment result.
|
||
|
||
**Parameters**
|
||
|
||
**experiment** ([*QasmQobjExperiment*](qiskit.qobj.QasmQobjExperiment "qiskit.qobj.QasmQobjExperiment")) – experiment from qobj experiments list
|
||
|
||
**Returns**
|
||
|
||
A result dictionary which looks something like:
|
||
|
||
```python
|
||
{
|
||
"name": name of this experiment (obtained from qobj.experiment header)
|
||
"seed": random seed used for simulation
|
||
"shots": number of shots used in the simulation
|
||
"data":
|
||
{
|
||
"unitary": [[[0.0, 0.0], [1.0, 0.0]],
|
||
[[1.0, 0.0], [0.0, 0.0]]]
|
||
},
|
||
"status": status string for the simulation
|
||
"success": boolean
|
||
"time taken": simulation time of this single experiment
|
||
}
|
||
```
|
||
|
||
**Return type**
|
||
|
||
[dict](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.12)")
|
||
|
||
**Raises**
|
||
|
||
[**BasicAerError**](qiskit.providers.basicaer.BasicAerError "qiskit.providers.basicaer.BasicAerError") – if the number of qubits in the circuit is greater than 24. Note that the practical qubit limit is much lower than 24.
|
||
</Function>
|
||
|
||
### set\_options
|
||
|
||
<Function id="qiskit.providers.basicaer.UnitarySimulatorPy.set_options" signature="set_options(**fields)">
|
||
Set the options fields for the backend
|
||
|
||
This method is used to update the options of a backend. If you need to change any of the options prior to running just pass in the kwarg with the new value for the options.
|
||
|
||
**Parameters**
|
||
|
||
**fields** – The fields to update the options
|
||
|
||
**Raises**
|
||
|
||
[**AttributeError**](https://docs.python.org/3/library/exceptions.html#AttributeError "(in Python v3.12)") – If the field passed in is not part of the options
|
||
</Function>
|
||
|
||
### status
|
||
|
||
<Function id="qiskit.providers.basicaer.UnitarySimulatorPy.status" signature="status()">
|
||
Return the backend status.
|
||
|
||
**Returns**
|
||
|
||
the status of the backend.
|
||
|
||
**Return type**
|
||
|
||
[BackendStatus](qiskit.providers.models.BackendStatus "qiskit.providers.models.BackendStatus")
|
||
</Function>
|
||
</Class>
|
||
|