示例#1
0
def hf_occ(n_spin_orbitals, n_electrons, BK=False):
    '''
    Returns the HF canonical orbital occupations.
    Assumes Aufbau filling.
    '''
    hf_state = np.zeros(n_spin_orbitals)
    hf_state[:n_electrons] = 1
    # hf_state = np.expand_dims(hf_state, 1)

    if BK:
        bk_encoder = openfermion.bravyi_kitaev_code(
            n_spin_orbitals).encoder.toarray()
        return bk_encoder @ hf_state % 2
    else:
        return hf_state
def hf_occ(n_spin_orbitals, n_electrons, qubit_transf='jw'):
    '''
    Returns the HF canonical orbital occupations.
    Assumes Aufbau filling.
    '''
    hf_state = np.zeros(n_spin_orbitals)
    hf_state[:n_electrons] = 1
    # hf_state = np.expand_dims(hf_state, 1)

    if qubit_transf == 'bk':
        bk_encoder = openfermion.bravyi_kitaev_code(
            n_spin_orbitals).encoder.toarray()
        return bk_encoder @ hf_state % 2
    elif qubit_transf == 'jw':
        return hf_state
    else:
        raise (ValueError("Unknown transformation specified"))