# Active space or orbit of Pennylean and Qiskit

**URL:** <https://discuss.pennylane.ai/t/active-space-or-orbit-of-pennylean-and-qiskit/3659>\
**Category:** PennyLane Help\
**Created:** [November 11, 2023, 4:30am UTC](https://discuss.pennylane.ai/t/active-space-or-orbit-of-pennylean-and-qiskit/3659 "2023-11-11T04:30:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qiming\_Ding](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/qiming_ding/32/2090_2.png) [@Qiming\_Ding](https://discuss.pennylane.ai/u/Qiming_Ding)\
**Post date:** [November 11, 2023, 4:30am UTC](https://discuss.pennylane.ai/t/active-space-or-orbit-of-pennylean-and-qiskit/3659/1 "2023-11-11T04:30:57Z")

</div>

Dear Community,

I’m currently working on mapping a Qiskit program to PennyLane, but I’m facing some challenges when it comes to selecting the active space.

First, I found a sample PennyLane program on [ADAPT-VQE](https://pennylane.ai/qml/demos/tutorial_adaptive_circuits/) that I’d like to use as a reference:

```python
import pennylane as qml
from pennylane import qchem
from pennylane import numpy as np

symbols = ["Li", "H"]
geometry = np.array([[0., 0., 0], [0., 0., 2.8]])
H, qubits = qchem.molecular_hamiltonian(
    symbols,
    geometry,
    charge=0,
    mult=1,
    basis='sto-3g',
    method='pyscf',
    active_electrons=2,
    active_orbitals=5
)

active_electrons = 2
singles, doubles = qchem.excitations(active_electrons, qubits)
print(f"Total number of excitations = {len(singles) + len(doubles)}")

electrons = 4
orbitals = 6
core, active = qchem.active_space(electrons, orbitals, active_electrons=a_electrons, active_orbitals=a_orbitals)
print("List of core orbitals: {:}".format(core))
print("List of active orbitals: {:}".format(active))
print("Number of qubits: {:}".format(2 * len(active)))

```

Result:

```python
List of core orbitals: [0]
List of active orbitals: [1, 2, 3, 4, 5]
Number of qubits: 10

```

In this PennyLane program, they set active\_orbitals=5. When I change it to active\_orbitals=3, the result is:

```python
List of core orbitals: [0]
List of active orbitals: [1, 2, 3]
Number of qubits: 6

```

Now, here’s my Qiskit program. Please note that the `generate_hamiltonian` function doesn’t directly relate to my issue, but I’ve included it for context:

```python
molecule = 'LiH'
d = 2.8
spin = 0
charge = 0
use_cas = False

if molecule == "LiH":
    atoms = f'H .0, .0, .0; Li .0, .0, {d}'
    occupied_indices = [0]
    active_indices = [1, 2, 5]
    n_elec = 2

molecular_hamiltonian, qubit_hamiltonian = generate_hamiltonian(molecule, atoms, occupied_indices, active_indices, n_elec, spin, charge, use_cas)

```

We have found that using [1, 2, 5] is better than [1, 2, 3] for approaching the ground state energy.

Now, my question is how can I translate the `occupied_indices=[0]` and `active_indices=[1,2,5]` from Qiskit to PennyLane?

Also, I’m interested in using the ADAPT-VQE method as described [ADAPT](https://pennylane.ai/qml/demos/tutorial_adaptive_circuits/). How can I input the quantum circuits I obtain using this method into Qiskit, as I want to apply Qiskit’s noise model?

I understand that it is possible to increase the noise model by qiskit\_aer the backend, but it is simply too slow. And I have a significant part of my subsequent processing is written in Qiskit.

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [November 13, 2023, 10:45pm UTC](https://discuss.pennylane.ai/t/active-space-or-orbit-of-pennylean-and-qiskit/3659/2 "2023-11-13T22:45:40Z")

</div>

Hey @Qiming_Ding! Welcome to the forum 🕶

I’ll have to get back to you on this. My initial thought is that the active space indices aren’t changeable, so wanting them to be `[1, 2, 5]` instead of `[1, 2, 3]` isn’t doable. But, I’ll double check with one of our `qchem` experts here 🙂. Sit tight!

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [November 13, 2023, 11:06pm UTC](https://discuss.pennylane.ai/t/active-space-or-orbit-of-pennylean-and-qiskit/3659/3 "2023-11-13T23:06:02Z")

</div>

Hey @Qiming_Ding, I got a quick response back. Correct me if I’m misinterpreting your original question, but PennyLane doesn’t let you change the active orbital index labels in the way that I mentioned in my previous comment. You can only change the number of active orbitals.

If this is a feature that you’d like us to implement, I suggest that you make a [Feature Request](https://github.com/PennyLaneAI/pennylane/issues/new?assignees=&labels=enhancement+%3Asparkles%3A&projects=&template=feature_request.yml) to our github repository for the paper trail 😄.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Qiming\_Ding](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/qiming_ding/32/2090_2.png) [@Qiming\_Ding](https://discuss.pennylane.ai/u/Qiming_Ding)\
**Post date:** [November 14, 2023, 3:26am UTC](https://discuss.pennylane.ai/t/active-space-or-orbit-of-pennylean-and-qiskit/3659/5 "2023-11-14T03:26:13Z")

</div>

Hi @isaacdevlugt ,  
Thank you for your reply, your understanding of my question is correct. Unfortunately, Pennylane is not free to change the settings of the active space just yet, although I do see in qiskit that using [1, 2, 5] is better than [1, 2, 3] for approaching the ground state energy. I hope to experience such a feature in future releases.

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [November 14, 2023, 2:51pm UTC](https://discuss.pennylane.ai/t/active-space-or-orbit-of-pennylean-and-qiskit/3659/6 "2023-11-14T14:51:38Z")

</div>

Thanks @Qiming_Ding! Don’t hesitate to make a feature request 😁 appreciate the feedback!
