Loading lib/qsim/base/qcor_qsim.hpp +14 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,12 @@ public: // e.g. a function to map from time to Hamiltonian operator. static QuatumSimulationModel createModel(Observable *obs, TdObservable td_ham, const HeterogeneousMap ¶ms = {}); // Pauli operator overload: static QuatumSimulationModel createModel(PauliOperator &obs, TdObservable td_ham, const HeterogeneousMap ¶ms = {}) { return createModel(&obs, td_ham, params); } // ======== High-level model builder ============== // The idea here is to have contributed modules to translate problem Loading Loading @@ -120,6 +126,14 @@ public: model.user_defined_ansatz = kernel_functor; return model; } template <typename... Args> static inline QuatumSimulationModel createModel( void (*quantum_kernel_functor)(std::shared_ptr<CompositeInstruction>, Args...), PauliOperator &obs, size_t nbQubits, size_t nbParams) { return createModel(quantum_kernel_functor, &obs, nbQubits, nbParams); } }; // Quantum Simulation Workflow (Protocol) Loading lib/qsim/impls/tests/TrotterTdWorkflow.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ int main(int argc, char **argv) { // Example: build model and TD workflow for Fig. 2 of // https://journals.aps.org/prb/pdf/10.1103/PhysRevB.101.184305 auto problemModel = ModelBuilder::createModel(&observable, H); auto problemModel = ModelBuilder::createModel(observable, H); // Trotter step = 3fs, number of steps = 100 -> end time = 300fs auto workflow = qcor::getWorkflow( "td-evolution", {{"method", "trotter"}, {"dt", 3.0}, {"steps", 100}}); Loading lib/qsim/impls/tests/VqeWithAnsatzCircuit.cpp +4 −7 Original line number Diff line number Diff line Loading @@ -14,14 +14,11 @@ __qpu__ void ansatz(qreg q, double theta) { } int main(int argc, char **argv) { // Allocate 2 qubits auto q = qalloc(2); // Create the Deuteron Hamiltonian auto H = createObservable( "5.907 - 2.1433 X0X1 - 2.1433 Y0Y1 + .21829 Z0 - 6.125 Z1"); auto problemModel = ModelBuilder::createModel(ansatz, H.get(), q.size(), 1); auto H = 5.907 - 2.1433*X(0)*X(1) - 2.143*Y(0)*Y(1) + 0.21829*Z(0) - 6.125*Z(1); const auto num_qubits = 2; const auto num_params = 1; auto problemModel = ModelBuilder::createModel(ansatz, H, num_qubits, num_params); auto optimizer = createOptimizer("nlopt"); // Instantiate a VQE workflow with the nlopt optimizer auto workflow = qcor::getWorkflow("vqe", {{"optimizer", optimizer}}); Loading Loading
lib/qsim/base/qcor_qsim.hpp +14 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,12 @@ public: // e.g. a function to map from time to Hamiltonian operator. static QuatumSimulationModel createModel(Observable *obs, TdObservable td_ham, const HeterogeneousMap ¶ms = {}); // Pauli operator overload: static QuatumSimulationModel createModel(PauliOperator &obs, TdObservable td_ham, const HeterogeneousMap ¶ms = {}) { return createModel(&obs, td_ham, params); } // ======== High-level model builder ============== // The idea here is to have contributed modules to translate problem Loading Loading @@ -120,6 +126,14 @@ public: model.user_defined_ansatz = kernel_functor; return model; } template <typename... Args> static inline QuatumSimulationModel createModel( void (*quantum_kernel_functor)(std::shared_ptr<CompositeInstruction>, Args...), PauliOperator &obs, size_t nbQubits, size_t nbParams) { return createModel(quantum_kernel_functor, &obs, nbQubits, nbParams); } }; // Quantum Simulation Workflow (Protocol) Loading
lib/qsim/impls/tests/TrotterTdWorkflow.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ int main(int argc, char **argv) { // Example: build model and TD workflow for Fig. 2 of // https://journals.aps.org/prb/pdf/10.1103/PhysRevB.101.184305 auto problemModel = ModelBuilder::createModel(&observable, H); auto problemModel = ModelBuilder::createModel(observable, H); // Trotter step = 3fs, number of steps = 100 -> end time = 300fs auto workflow = qcor::getWorkflow( "td-evolution", {{"method", "trotter"}, {"dt", 3.0}, {"steps", 100}}); Loading
lib/qsim/impls/tests/VqeWithAnsatzCircuit.cpp +4 −7 Original line number Diff line number Diff line Loading @@ -14,14 +14,11 @@ __qpu__ void ansatz(qreg q, double theta) { } int main(int argc, char **argv) { // Allocate 2 qubits auto q = qalloc(2); // Create the Deuteron Hamiltonian auto H = createObservable( "5.907 - 2.1433 X0X1 - 2.1433 Y0Y1 + .21829 Z0 - 6.125 Z1"); auto problemModel = ModelBuilder::createModel(ansatz, H.get(), q.size(), 1); auto H = 5.907 - 2.1433*X(0)*X(1) - 2.143*Y(0)*Y(1) + 0.21829*Z(0) - 6.125*Z(1); const auto num_qubits = 2; const auto num_params = 1; auto problemModel = ModelBuilder::createModel(ansatz, H, num_qubits, num_params); auto optimizer = createOptimizer("nlopt"); // Instantiate a VQE workflow with the nlopt optimizer auto workflow = qcor::getWorkflow("vqe", {{"optimizer", optimizer}}); Loading