def getCircuit(name, geometry, basis, multiplicity, charge, mapping): # Load appropraite molecule molecule = GenerateCircuit() molecule.set_name(name) if (geometry == "pubchem"): molecule.get_geometry_from_pubchem() else: molecule.set_geometry(geometry) molecule.set_basis('sto-3g') molecule.set_multiplicity(multiplicity) molecule.set_charge(charge) molecule.load_molecule() molecule.create_hamiltonians() molecule.create_circuits(mapping) if (mapping == "BK"): return molecule.bk_circuit elif (mapping == "JW"): return molecule.jw_circuit else: sys.exit("Didn't understand mapping")
def getMoleculeData(name, geometry, basis, multiplicity, charge): # Load appropraite molecule molecule2 = GenerateCircuit() molecule2.set_name(name) if (geometry == "pubchem"): molecule2.get_geometry_from_pubchem() else: molecule2.set_geometry(geometry) molecule2.set_basis('sto-3g') molecule2.set_multiplicity(multiplicity) molecule2.set_charge(charge) molecule2.load_molecule() molecule2.create_hamiltonians() data = array.array('i', [0, 0, 0]) data[0] = molecule2.molecule.n_qubits data[1] = molecule2.active_space_start data[2] = molecule2.active_space_stop return data
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 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]
def getCircuit(name, geometry, basis, multiplicity, charge, mapping): # Load appropraite molecule molecule = GenerateCircuit() molecule.set_name(name) if(geometry == "pubchem"): molecule.get_geometry_from_pubchem() else: molecule.set_geometry(geometry) molecule.set_basis('sto-3g') molecule.set_multiplicity(multiplicity) molecule.set_charge(charge) molecule.load_molecule() molecule.create_hamiltonians() molecule.create_circuits(mapping) molecule.save_qasm(mapping)
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]