Пример #1
0
def generateHChain(bondLength=.7414,
                   mapping="BK",
                   atoms=2,
                   uniform=True,
                   linear=True,
                   threedimensions=True):

    H2 = GenerateCircuit()
    H2.set_name("HChain")
    description = str(bondLength) + str(atoms) + str(uniform) + str(linear)
    H2.set_description(description)

    if (not threedimensions):
        geometry = createGeometry2D(bondLength, atoms, uniform, linear)
    else:
        geometry = createGeometry3D(bondLength, atoms, uniform, linear)

    H2.set_geometry(geometry)
    H2.set_basis("sto-3g")
    H2.set_multiplicity(1)
    H2.set_charge(atoms - 2)
    H2.load_molecule()
    H2.create_hamiltonians()
    # need to create fermion hamiltonian
    H2.create_circuits(mapping)
    # maps fermion to qubit hamil and circuit
    return [H2.getHamiltonians(mapping), geometry]
Пример #2
0
def generateHChain(bondLength=.7414,
                   mapping="BK",
                   atoms=2,
                   uniform=True,
                   linear=True,
                   theta=0):

    H2 = GenerateCircuit()
    H2.set_name("HChain")
    description = str(bondLength) + str(atoms) + str(uniform) + str(linear)
    H2.set_description(description)

    geometry = [("H", (0, 0, 0)), ("H", (bondLength, 0, 0)),
                ("H", (bondLength + (bondLength * math.cos(theta)),
                       bondLength * math.sin(theta), 0))]
    file = open("geometries.txt", "a")
    file.write("{} {}\n".format(theta, geometry[2]))
    file.close()
    H2.set_geometry(geometry)
    H2.set_basis("sto-3g")
    H2.set_multiplicity(1)
    H2.set_charge(atoms - 2)
    H2.load_molecule()
    H2.create_hamiltonians()
    H2.create_circuits(mapping)
    # print(H2.getHamiltonians(mapping));
    # print("\n\n");
    values, vectors = H2.getEigen(mapping)
    print("\n\nEIGENVALUES FOR ANGLE {} Degrees".format(theta * 180 / math.pi))
    print(values)
    # print("\nEIGENVECTORS")
    # print(vectors)
    return None
def getLowest(geometry, middleLength, radian=0):
    molecule = GenerateCircuit()
    molecule.set_name("oscillatingHChain")
    description = "wobbly_middlelocation=" + str(
        middleLength) + "charge=" + str(-1) + "angle=" + str(radian)
    molecule.set_description(description)
    molecule.set_geometry(geometry)
    molecule.set_basis("sto-3g")
    molecule.set_multiplicity(1)
    molecule.set_charge(-1)
    molecule.load_molecule()
    energy = molecule.molecule.hf_energy
    molecule.create_hamiltonians()
    molecule.create_circuits("BK")
    values = molecule.getLowestEigen("BK")
    return [values, energy]