class QPanda::ChemiQ

Overview

ChemiQ Algorithm class. More…

#include <ChemiQ.h>

class ChemiQ
{
public:
    // methods

    void initialize(const std::string& dir);
    void finalize();
    void setMolecule(const std::string& molecule);
    void setMoleculesStr(const std::string& molecule);
    void setMolecules(const vector_s& molecules);
    void setMultiplicity(int multiplicity);
    void setCharge(int charge);
    void setBasis(const std::string& basis);
    void setEqTolerance(const double val);
    void setTransformType(TransFormType type);
    void setUccType(UccType ucc_type);
    void setOptimizerType(OptimizerType optimizer_type);
    void setOptimizerIterNum(size_t iter_num);
    void setOptimizerFuncCallNum(size_t num);
    void setOptimizerXatol(double value);
    void setOptimizerFatol(double value);
    void setOptimizerDisp(bool enable);
    void setLearningRate(double learning_rate);
    void setEvolutionTime(double t);
    void setHamiltonianSimulationSlices(size_t slices);
    void setSaveDataDir(const std::string dir);
    void setQuantumMachineType(QMachineType type);
    void setRandomPara(bool enable);
    void setDefaultOptimizedPara(const vector_d& para);
    void setToGetHamiltonianFromFile(bool enable);
    void setHamiltonianGenerationOnly(bool enable);
    int getQubitsNum();
    bool exec();
    std::string getLastError() const;
    vector_d getEnergies() const;
};

Detailed Documentation

ChemiQ Algorithm class.

Methods

void initialize(const std::string& dir)

Initialize the quantum chemistry calculation.

Parameters:

std::string

The dir of the psi4 chemistry calculation package

void finalize()

Finalize the quantum chemistry calculation.

void setMolecule(const std::string& molecule)

Set the molecular model to calculate separated by commas(‘

‘) between atoms.

Parameters:

std::string

molecule model

void setMoleculesStr(const std::string& molecule)

Setup molecular models, separated by semicolons(‘;’) and separated by commas(‘,’) between atoms.

Parameters:

std::string

molecule model

void setMolecules(const vector_s& molecules)

Set the molecular model to calculate.

Parameters:

vector_s

molecule model

See also:

vector_s

void setMultiplicity(int multiplicity)

Set the multiplicity of the molecular model.

Parameters:

int

multiplicity

void setCharge(int charge)

Set the charge of the molecular model.

Parameters:

int

charge

void setBasis(const std::string& basis)

Set the calculation basis.

Parameters:

std::string

basis

void setEqTolerance(const double val)

set Eq Tolerance

Parameters:

double

the val of Tolerance

void setTransformType(TransFormType type)

Set the transform type from Fermion operator to Pauli operator.

Parameters:

TransFormType

transform type

See also:

TransFormType

void setUccType(UccType ucc_type)

Set the ucc type to contruct the Fermion operator.

Parameters:

UccType

ucc type

See also:

UccType

void setOptimizerType(OptimizerType optimizer_type)

Set the optimizer type.

Parameters:

OptimizerType

optimizer type

See also:

OptimizerType

void setOptimizerIterNum(size_t iter_num)

Set the optimizer iteration number.

Parameters:

size_t

iteration number

void setOptimizerFuncCallNum(size_t num)

Set the optimizer function callback number.

Parameters:

size_t

function callback number

void setOptimizerXatol(double value)

Set the optimizer xatol.It is the Absolute error in xopt between iterations that is acceptable for convergence.

Parameters:

double

absolute error between iterations

void setOptimizerFatol(double value)

Set the optimizer fatol.It is the Absolute error in func(xopt) between iterations that is acceptable for convergence.

Parameters:

double

absolute error between func(xopt)

void setOptimizerDisp(bool enable)

Whether to print the optimized log to the terminal.

Parameters:

bool

enable

void setLearningRate(double learning_rate)

Set the learing rate when using Gradient optimizer.

Parameters:

double

learing rate

void setEvolutionTime(double t)

Set the evolution time when doing hamiltonian simulation.

Parameters:

double

evolution time

void setHamiltonianSimulationSlices(size_t slices)

Set the hamiltonian simulation slices (e^iAt/n*e^iBt/n)^n, n is the slices.

Parameters:

double

hamiltonian simulation slices

void setSaveDataDir(const std::string dir)

Set the directory to save the calculated data. If it’s a not exist dir data will not be saved.

Parameters:

std::string

dir

void setQuantumMachineType(QMachineType type)

Set the quantum machine type.

Parameters:

QMachineType

quantum machine type

See also:

QMachineType

void setRandomPara(bool enable)

Set random default optimizer paramter.

Parameters:

bool

enable

void setDefaultOptimizedPara(const vector_d& para)

Set the default optimizer paramter by the given paramter.

Parameters:

vecotr_d

default paramter

See also:

vector_d

void setToGetHamiltonianFromFile(bool enable)

Set to get hamiltonian from file.

Parameters:

bool

enable

void setHamiltonianGenerationOnly(bool enable)

Set hamiltonian generation only.

Parameters:

bool

enable

int getQubitsNum()

get qubits num with the above config.

Returns:

int -1:means failed.

bool exec()

exec molecule calculate.

Returns:

bool true:success; false:failed

std::string getLastError() const

get last error.

Returns:

std::string last error

vector_d getEnergies() const

get calculated energies of the molecules.

Returns:

vector_d energies