Commit 799ba176 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

merged master

parents 92b753a1 41aeb593
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -18,6 +18,11 @@ add_test(NAME qrt_ftqc_deuteron COMMAND ${CMAKE_BINARY_DIR}/qcor -c -qrt ftqc ${
add_test(NAME qrt_ftqc_bit_flip_qec_std_lib COMMAND ${CMAKE_BINARY_DIR}/qcor -c -qrt ftqc ${CMAKE_CURRENT_SOURCE_DIR}/ftqc_qrt/error_correcting_code.cpp)
add_test(NAME qrt_ftqc_five_qubit_qec_std_lib COMMAND ${CMAKE_BINARY_DIR}/qcor -c -qrt ftqc ${CMAKE_CURRENT_SOURCE_DIR}/ftqc_qrt/five_qubit_qec_code.cpp)
add_test(NAME qrt_ftqc_steane_qec_std_lib COMMAND ${CMAKE_BINARY_DIR}/qcor -c -qrt ftqc ${CMAKE_CURRENT_SOURCE_DIR}/ftqc_qrt/steane_qec_code.cpp)
add_test(NAME qsim_vqe COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/qsim/VqeWithAnsatzCircuit.cpp)
add_test(NAME qsim_trotter COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/qsim/TrotterTdWorkflow.cpp)
add_test(NAME qsim_iqpe_vqe COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/qsim/IterativeQpeVqe.cpp)
add_test(NAME quasimo_vqe COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/quasimo/VqeWithAnsatzCircuit.cpp)
add_test(NAME quasimo_trotter COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/quasimo/TrotterTdWorkflow.cpp)
add_test(NAME quasimo_iqpe_vqe COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/quasimo/IterativeQpeVqe.cpp)
add_test(NAME quasimo_adapt_vqe COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/quasimo/AdaptVqeWorkflow.cpp)
add_test(NAME quasimo_qaoa COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/quasimo/QaoaWorkflow.cpp)
add_test(NAME quasimo_qite COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/quasimo/QiteWorkflow.cpp)
add_test(NAME quasimo_heisenberg COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/quasimo/TdWorkflowHeisenbergModel.cpp)
add_test(NAME quasimo_verified_qpe COMMAND ${CMAKE_BINARY_DIR}/qcor ${CMAKE_CURRENT_SOURCE_DIR}/quasimo/VerifiedQuantumPhaseEstimation.cpp)
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ Here we show a few examples of QCOR programs. These exampls highlight many aspec

`qpe/` showcases examples for [quantum phase estimation](https://en.wikipedia.org/wiki/Quantum_phase_estimation_algorithm) algorithm. Files Requiring quantum runtime library (qrt), compile with: `qcor -o qpe -qpu qpp -shots 1024 -qrt qpe_example_qrt.cpp`

`qsim/` a suite of examples employing the "Quantum Simulation Model" with qcor.  
`quasimo/` a suite of examples employing the "Quantum Simulation Modeling" library with qcor.  

`simple/` highlights core features and functionality of QCOR programs running straightforward quantum computing schemes. Reccomended starting point for new users. 

+48 −0
Original line number Diff line number Diff line
#include "qcor_qsim.hpp"

// Demonstrate qsim's Adapt-VQE workflow
/// $ qcor -qpu qpp AdaptVqeWorkflow.cpp
/// $ ./a.out

int main(int argc, char **argv) {
  const auto str = std::string(
      "(-0.165606823582,-0)  1^ 2^ 1 2 + (0.120200490713,0)  1^ 0^ 0 1 + "
      "(-0.0454063328691,-0)  0^ 3^ 1 2 + (0.168335986252,0)  2^ 0^ 0 2 + "
      "(0.0454063328691,0)  1^ 2^ 3 0 + (0.168335986252,0)  0^ 2^ 2 0 + "
      "(0.165606823582,0)  0^ 3^ 3 0 + (-0.0454063328691,-0)  3^ 0^ 2 1 + "
      "(-0.0454063328691,-0)  1^ 3^ 0 2 + (-0.0454063328691,-0)  3^ 1^ 2 0 + "
      "(0.165606823582,0)  1^ 2^ 2 1 + (-0.165606823582,-0)  0^ 3^ 0 3 + "
      "(-0.479677813134,-0)  3^ 3 + (-0.0454063328691,-0)  1^ 2^ 0 3 + "
      "(-0.174072892497,-0)  1^ 3^ 1 3 + (-0.0454063328691,-0)  0^ 2^ 1 3 + "
      "(0.120200490713,0)  0^ 1^ 1 0 + (0.0454063328691,0)  0^ 2^ 3 1 + "
      "(0.174072892497,0)  1^ 3^ 3 1 + (0.165606823582,0)  2^ 1^ 1 2 + "
      "(-0.0454063328691,-0)  2^ 1^ 3 0 + (-0.120200490713,-0)  2^ 3^ 2 3 + "
      "(0.120200490713,0)  2^ 3^ 3 2 + (-0.168335986252,-0)  0^ 2^ 0 2 + "
      "(0.120200490713,0)  3^ 2^ 2 3 + (-0.120200490713,-0)  3^ 2^ 3 2 + "
      "(0.0454063328691,0)  1^ 3^ 2 0 + (-1.2488468038,-0)  0^ 0 + "
      "(0.0454063328691,0)  3^ 1^ 0 2 + (-0.168335986252,-0)  2^ 0^ 2 0 + "
      "(0.165606823582,0)  3^ 0^ 0 3 + (-0.0454063328691,-0)  2^ 0^ 3 1 + "
      "(0.0454063328691,0)  2^ 0^ 1 3 + (-1.2488468038,-0)  2^ 2 + "
      "(0.0454063328691,0)  2^ 1^ 0 3 + (0.174072892497,0)  3^ 1^ 1 3 + "
      "(-0.479677813134,-0)  1^ 1 + (-0.174072892497,-0)  3^ 1^ 3 1 + "
      "(0.0454063328691,0)  3^ 0^ 1 2 + (-0.165606823582,-0)  3^ 0^ 3 0 + "
      "(0.0454063328691,0)  0^ 3^ 2 1 + (-0.165606823582,-0)  2^ 1^ 2 1 + "
      "(-0.120200490713,-0)  0^ 1^ 0 1 + (-0.120200490713,-0)  1^ 0^ 1 0 + "
      "(0.7080240981,0)");

  FermionOperator H_vqe;
  H_vqe.fromString(str);
  auto problemModel = QuaSiMo::ModelFactory::createModel(&H_vqe);
  auto optimizer = createOptimizer("nlopt", {{"nlopt-optimizer", "l-bfgs"}});
  const int nElectrons = 2;
  const auto pool_vqe = "qubit-pool";
  auto workflow = QuaSiMo::getWorkflow("adapt", {{"optimizer", optimizer},
                                              {"pool", pool_vqe},
                                              {"n-electrons", nElectrons}});
  auto result = workflow->execute(problemModel);
  std::cout << "Final energy: " << result.get<double>("energy") << "\n";
  auto final_ansatz =
      result.getPointerLike<xacc::CompositeInstruction>("circuit");
  std::cout << "HOWDY: \n" << final_ansatz->toString() << "\n";
  return 0;
}
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -22,11 +22,11 @@ int main(int argc, char **argv) {
  auto H = 5.907 - 2.1433 * X(0) * X(1) - 2.143 * Y(0) * Y(1) + 0.21829 * Z(0) -
           6.125 * Z(1);
  auto problemModel =
      qsim::ModelBuilder::createModel(eigen_state_prep, H, 2, 0);
      QuaSiMo::ModelFactory::createModel(eigen_state_prep, H, 2, 0);

  // Instantiate an IQPE workflow
  auto workflow =
      qsim::getWorkflow("iqpe", {{"time-steps", 8}, {"iterations", 8}});
      QuaSiMo::getWorkflow("iqpe", {{"time-steps", 8}, {"iterations", 8}});

  auto result = workflow->execute(problemModel);
  const double phaseValue = result.get<double>("phase");
+2 −2
Original line number Diff line number Diff line
@@ -10,11 +10,11 @@ int main(int argc, char **argv) {
  // Create the Deuteron Hamiltonian
  auto H = 5.907 - 2.1433 * X(0) * X(1) - 2.143 * Y(0) * Y(1) + 0.21829 * Z(0) -
           6.125 * Z(1);
  auto problemModel = qsim::ModelBuilder::createModel(H);
  auto problemModel = QuaSiMo::ModelFactory::createModel(H);
  auto optimizer = createOptimizer("nlopt");
  // Instantiate a QAOA workflow with the nlopt optimizer
  // "steps" = the (p) param in QAOA algorithm.
  auto workflow = qsim::getWorkflow("qaoa", {{"optimizer", optimizer}, {"steps", 8}});
  auto workflow = QuaSiMo::getWorkflow("qaoa", {{"optimizer", optimizer}, {"steps", 8}});

  // Result should contain the ground-state energy along with the optimal
  // parameters.
Loading