Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/selected fock space #80

Merged
merged 14 commits into from
Oct 23, 2018
2 changes: 1 addition & 1 deletion cmake/FindPackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


# Find the Boost package
find_package(Boost REQUIRED)
find_package(Boost REQUIRED COMPONENTS system thread)
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved

# Find Eigen3
find_package(Eigen3 3.3.4 REQUIRED)
Expand Down
17 changes: 13 additions & 4 deletions cmake/SetCMakeEnvironment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(PROJECT_SOURCE_FILES
${PROJECT_SOURCE_FOLDER}/FockSpace/BaseFockSpace.cpp
${PROJECT_SOURCE_FOLDER}/FockSpace/FockSpace.cpp
${PROJECT_SOURCE_FOLDER}/FockSpace/FockSpaceProduct.cpp
${PROJECT_SOURCE_FOLDER}/FockSpace/SelectedFockSpace.cpp
${PROJECT_SOURCE_FOLDER}/HamiltonianBuilder/DOCI.cpp
${PROJECT_SOURCE_FOLDER}/HamiltonianBuilder/FCI.cpp
${PROJECT_SOURCE_FOLDER}/HamiltonianBuilder/HamiltonianBuilder.cpp
Expand All @@ -45,13 +46,17 @@ set(PROJECT_SOURCE_FILES
${PROJECT_SOURCE_FOLDER}/RDM/DOCIRDMBuilder.cpp
${PROJECT_SOURCE_FOLDER}/RDM/FCIRDMBuilder.cpp
${PROJECT_SOURCE_FOLDER}/RDM/OneRDM.cpp
${PROJECT_SOURCE_FOLDER}/RDM/SelectedRDMBuilder.cpp
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
${PROJECT_SOURCE_FOLDER}/RDM/RDMCalculator.cpp
${PROJECT_SOURCE_FOLDER}/RDM/RDMs.cpp
${PROJECT_SOURCE_FOLDER}/RDM/SelectedRDMBuilder.cpp
${PROJECT_SOURCE_FOLDER}/RDM/TwoRDM.cpp
${PROJECT_SOURCE_FOLDER}/RHF/DIISRHFSCFSolver.cpp
${PROJECT_SOURCE_FOLDER}/RHF/PlainRHFSCFSolver.cpp
${PROJECT_SOURCE_FOLDER}/RHF/RHF.cpp
${PROJECT_SOURCE_FOLDER}/RHF/RHFSCFSolver.cpp
${PROJECT_SOURCE_FOLDER}/WaveFunction/WaveFunction.cpp
${PROJECT_SOURCE_FOLDER}/WaveFunction/WaveFunctionReader.cpp
${PROJECT_SOURCE_FOLDER}/AOBasis.cpp
${PROJECT_SOURCE_FOLDER}/Atom.cpp
${PROJECT_SOURCE_FOLDER}/DOCINewtonOrbitalOptimizer.cpp
Expand All @@ -61,8 +66,7 @@ set(PROJECT_SOURCE_FILES
${PROJECT_SOURCE_FOLDER}/miscellaneous.cpp
${PROJECT_SOURCE_FOLDER}/Molecule.cpp
${PROJECT_SOURCE_FOLDER}/ONV.cpp
${PROJECT_SOURCE_FOLDER}/RMP2.cpp
${PROJECT_SOURCE_FOLDER}/WaveFunction.cpp)
${PROJECT_SOURCE_FOLDER}/RMP2.cpp)

# Find the header folder
set(PROJECT_INCLUDE_FOLDER ${CMAKE_SOURCE_DIR}/include)
Expand All @@ -78,6 +82,7 @@ set(PROJECT_INCLUDE_FILES
${PROJECT_INCLUDE_FOLDER}/FockSpace/FockSpace.hpp
${PROJECT_INCLUDE_FOLDER}/FockSpace/FockSpaceProduct.hpp
${PROJECT_INCLUDE_FOLDER}/FockSpace/FockSpaceType.hpp
${PROJECT_INCLUDE_FOLDER}/FockSpace/SelectedFockSpace.hpp
${PROJECT_INCLUDE_FOLDER}/HamiltonianBuilder/DOCI.hpp
${PROJECT_INCLUDE_FOLDER}/HamiltonianBuilder/FCI.hpp
${PROJECT_INCLUDE_FOLDER}/HamiltonianBuilder/HamiltonianBuilder.hpp
Expand All @@ -92,16 +97,19 @@ set(PROJECT_INCLUDE_FILES
${PROJECT_INCLUDE_FOLDER}/RDM/DOCIRDMBuilder.hpp
${PROJECT_INCLUDE_FOLDER}/RDM/FCIRDMBuilder.hpp
${PROJECT_INCLUDE_FOLDER}/RDM/OneRDM.hpp
${PROJECT_INCLUDE_FOLDER}/RDM/SelectedRDMBuilder.hpp
${PROJECT_INCLUDE_FOLDER}/RDM/RDMCalculator.hpp
${PROJECT_INCLUDE_FOLDER}/RDM/RDMs.hpp
${PROJECT_INCLUDE_FOLDER}/RDM/TwoRDM.hpp
${PROJECT_INCLUDE_FOLDER}/RHF/DIISRHFSCFSolver.hpp
${PROJECT_INCLUDE_FOLDER}/RHF/PlainRHFSCFSolver.hpp
${PROJECT_INCLUDE_FOLDER}/RHF/RHF.hpp
${PROJECT_INCLUDE_FOLDER}/RHF/RHFSCFSolver.hpp
${PROJECT_INCLUDE_FOLDER}/WaveFunction/WaveFunction.hpp
${PROJECT_INCLUDE_FOLDER}/AOBasis.hpp
${PROJECT_INCLUDE_FOLDER}/Atom.hpp
${PROJECT_INCLUDE_FOLDER}/common.hpp
${PROJECT_INCLUDE_FOLDER}/Configuration.hpp
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
${PROJECT_INCLUDE_FOLDER}/DOCINewtonOrbitalOptimizer.hpp
${PROJECT_INCLUDE_FOLDER}/elements.hpp
${PROJECT_INCLUDE_FOLDER}/JacobiRotationParameters.hpp
Expand All @@ -110,8 +118,7 @@ set(PROJECT_INCLUDE_FILES
${PROJECT_INCLUDE_FOLDER}/Molecule.hpp
${PROJECT_INCLUDE_FOLDER}/ONV.hpp
${PROJECT_INCLUDE_FOLDER}/RMP2.hpp
${PROJECT_INCLUDE_FOLDER}/units.hpp
${PROJECT_INCLUDE_FOLDER}/WaveFunction.hpp)
${PROJECT_INCLUDE_FOLDER}/units.hpp)

# Find the tests folder
set(PROJECT_TESTS_FOLDER ${CMAKE_SOURCE_DIR}/tests)
Expand All @@ -129,6 +136,7 @@ set(PROJECT_TEST_SOURCE_FILES
${PROJECT_TESTS_FOLDER}/AP1roG/AP1roGPSESolver_test.cpp
${PROJECT_TESTS_FOLDER}/FockSpace/FockSpace_test.cpp
${PROJECT_TESTS_FOLDER}/FockSpace/FockSpaceProduct_test.cpp
${PROJECT_TESTS_FOLDER}/FockSpace/SelectedFockSpace_test.cpp
${PROJECT_TESTS_FOLDER}/HamiltonianBuilder/DOCI_test.cpp
${PROJECT_TESTS_FOLDER}/HamiltonianBuilder/FCI_test.cpp
${PROJECT_TESTS_FOLDER}/HamiltonianParameters/HamiltonianParameters_test.cpp
Expand All @@ -137,6 +145,7 @@ set(PROJECT_TEST_SOURCE_FILES
${PROJECT_TESTS_FOLDER}/Operator/TwoElectronOperator_test.cpp
${PROJECT_TESTS_FOLDER}/RDM/DOCIRDMBuilder_test.cpp
${PROJECT_TESTS_FOLDER}/RDM/FCIRDMBuilder_test.cpp
${PROJECT_TESTS_FOLDER}/RDM/SelectedRDMBuilder_test.cpp
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
${PROJECT_TESTS_FOLDER}/RDM/RDMCalculator_test.cpp
${PROJECT_TESTS_FOLDER}/RHF/DIISRHFSCFSolver_test.cpp
${PROJECT_TESTS_FOLDER}/RHF/PlainRHFSCFSolver_test.cpp
Expand Down
3 changes: 2 additions & 1 deletion include/CISolver/CISolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
#define GQCP_CISOLVER_HPP



#include "HamiltonianBuilder/HamiltonianBuilder.hpp"
#include "HamiltonianParameters/HamiltonianParameters.hpp"
#include "WaveFunction.hpp"
#include "WaveFunction/WaveFunction.hpp"

#include <numopt.hpp>

Expand Down
21 changes: 21 additions & 0 deletions include/Configuration.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef GQCP_CONFIGURATION_HPP
#define GQCP_CONFIGURATION_HPP


#include "ONV.hpp"
#include "common.hpp"
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved


namespace GQCP {


tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
struct Configuration {
ONV onv_alpha;
ONV onv_beta;
};


} // namespace GQCP


#endif // GQCP_CONFIGURATION_HPP
2 changes: 1 addition & 1 deletion include/DOCINewtonOrbitalOptimizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "HamiltonianParameters/HamiltonianParameters.hpp"
#include "HamiltonianBuilder/DOCI.hpp"
#include "OrbitalOptimizationOptions.hpp"
#include "WaveFunction.hpp"
#include "WaveFunction/WaveFunction.hpp"

#include <numopt.hpp>

Expand Down
6 changes: 3 additions & 3 deletions include/FockSpace/BaseFockSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ namespace GQCP {
*/
class BaseFockSpace {
protected:
const size_t K; // number of spatial orbitals
const size_t dim; // dimension of the Fock space
size_t K; // number of spatial orbitals
size_t dim; // dimension of the Fock space


// PROTECTED CONSTRUCTORS
/**
* Protected constructor given a @param K and @param dim
*/
explicit BaseFockSpace(size_t K, size_t dim);

BaseFockSpace() = default;
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved

public:
// DESTRUCTOR
Expand Down
3 changes: 2 additions & 1 deletion include/FockSpace/FockSpaceType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace GQCP {
*/
enum class FockSpaceType {
FockSpace,
FockSpaceProduct
FockSpaceProduct,
SelectedFockSpace
};


Expand Down
88 changes: 88 additions & 0 deletions include/FockSpace/SelectedFockSpace.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// This file is part of GQCG-gqcp.
//
// Copyright (C) 2017-2018 the GQCG developers
//
// GQCG-gqcp is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GQCG-gqcp is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with GQCG-gqcp. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef GQCP_SELECTEDSPACEPRODUCT_HPP
#define GQCP_SELECTEDSPACEPRODUCT_HPP
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved


#include "FockSpace/BaseFockSpace.hpp"
#include "FockSpace/FockSpaceProduct.hpp"
#include "Configuration.hpp"

#include <boost/numeric/conversion/converter.hpp>
#include <boost/math/special_functions.hpp>


namespace GQCP {


/**
* A Fock space for a given set of orbitals and number of alpha and beta electrons.
* Where the considered configurations are manually selected and represented as a Configuration :
* a combination of two ONVs, one holding the alpha configuration and holding the beta configuration.
*/
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
class SelectedFockSpace : public GQCP::BaseFockSpace {
private:
size_t N_alpha; // number of alpha electrons
size_t N_beta; // number of beta electrons

std::vector<Configuration> selection; // the selected configurations
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved

/**
* Given @param onv1 and onv2, make a configuration
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
*/
Configuration makeConfiguration(std::string onv1, std::string onv2);

public:
// CONSTRUCTORS
/**
* Constructor given a @param K (spatial orbitals), N_alpha and N_beta (electrons);
* the initial dimension of the space is 0, as no selections are made.
*/
SelectedFockSpace(size_t K, size_t N_alpha, size_t N_beta);
SelectedFockSpace() = default;
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved

// DESTRUCTORS
~SelectedFockSpace() override = default;
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved


// GETTERS
size_t get_N_alpha() const { return this->N_alpha; }
size_t get_N_beta() const { return this->N_beta; }
Configuration get_Configuration(size_t index) const { return this->selection[index]; }
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
FockSpaceType get_type() const override { return FockSpaceType::SelectedFockSpace; }


// PUBLIC METHODS
/**
* Add configuration(s) (@param onv1(s) and onv2(s)) to the current selected Fock space
* increasing its selected dimension.
*/
void addConfiguration(std::string onv1, std::string onv2);
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
void addConfiguration(std::vector<std::string> onv1s, std::vector<std::string> onv2s);

/**
* Sets the current expansion to that of @param fock_space
*/
void setExpansion(const FockSpaceProduct& fock_space);
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
};


} // namespace GQCP


#endif // GQCP_SELECTEDSPACEPRODUCT_HPP
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
23 changes: 21 additions & 2 deletions include/ONV.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace GQCP {
*/
class ONV {
private:
const size_t K; // number of spatial orbitals
const size_t N; // number of electrons
size_t K; // number of spatial orbitals
size_t N; // number of electrons
size_t unsigned_representation; // unsigned representation
VectorXs occupation_indices; // the occupied orbital electron indexes
// it is a vector of N elements in which occupation_indices[j]
Expand All @@ -50,11 +50,17 @@ class ONV {

public:
// CONSTRUCTORS
ONV() = default;
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
/**
* Constructor from a @param K orbitals, N electrons and an @param unsigned_representation
*/
ONV(size_t K, size_t N, size_t unsigned_representation);

/**
* Constructor from a @param K orbitals and an @param unsigned_representation
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved
*/
ONV(size_t K, size_t unsigned_representation);


// OPERATORS
/**
Expand Down Expand Up @@ -159,6 +165,19 @@ class ONV {
size_t slice(size_t index_start, size_t index_end) const;


/**
* @return the number of different bits between this and @param other, i.e. two times the number of electron excitations
*/
size_t countNumberOfDifferences(const ONV& other) const;


/**
* @return the positions of the bits (lexical indices) that are occupied in this, but unoccupied in @param other
*/
std::vector<size_t> findOccupiedDifferences(const ONV& other) const;



// FRIEND CLASSES
friend class FockSpace;
};
Expand Down
3 changes: 3 additions & 0 deletions include/RDM/OneRDM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class OneRDM : public BaseRDM {
Eigen::MatrixXd get_matrix_representation() const { return this->D; }
double get(size_t p, size_t q) const { return this->D(p, q); }

// OPERATOR
tmhuysen marked this conversation as resolved.
Show resolved Hide resolved



// PUBLIC METHODS
/**
Expand Down
4 changes: 3 additions & 1 deletion include/RDM/RDMCalculator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "RDM/BaseRDMBuilder.hpp"
#include "FockSpace/FockSpace.hpp"
#include "FockSpace/FockSpaceProduct.hpp"
#include "FockSpace/SelectedFockSpace.hpp"

#include <memory>

Expand All @@ -26,7 +27,8 @@ class RDMCalculator {
*/
RDMCalculator(const FockSpace& fock_space); // DOCIRDMBuilder
RDMCalculator(const FockSpaceProduct& fock_space); // FCIRDMBuilder
RDMCalculator(const BaseFockSpace& fock_space);
RDMCalculator(const SelectedFockSpace& fock_space); // SelectedRDMBuilder
RDMCalculator(const BaseFockSpace& fock_space); // runtime


// PUBLIC METHODS
Expand Down
Loading