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

Save or read orbitals in text format, portable and readable by MADNESS group #249

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
56c96dc
template for native complex trees
Apr 25, 2024
0760089
update examples for native complex trees
Apr 26, 2024
b8c9085
Merge branch 'master' of github.com:MRChemSoft/mrcpp into NativeCompl…
Apr 26, 2024
f271ea9
remove Complex template from Gaussians
gitpeterwind Jul 9, 2024
2627f64
test with derivative of Complex Exponential
gitpeterwind Jul 9, 2024
365bd0c
Merge branch 'master' into NativeComplexTrees
gitpeterwind Jul 9, 2024
fa478e8
mrchem compatibility
Jul 10, 2024
a595da6
Four components class and apply
gitpeterwind Jul 12, 2024
303a545
More native Complex tree operations: add, mult, Bank, send, rescale
gitpeterwind Jul 12, 2024
daaed5c
Merge branch 'NativeComplexTrees' into FourComponents
gitpeterwind Jul 15, 2024
fbc96f7
FunctionnTree deepcopy, addinplace, creator from components function
gitpeterwind Jul 16, 2024
3aa778a
Component Functions: mpi send and recv
gitpeterwind Jul 17, 2024
9ce1b76
Component Functions: norms
gitpeterwind Jul 19, 2024
3057d0a
CompFunction destructor
gitpeterwind Jul 20, 2024
9b24281
FourComp for share, add, multiply rescale, dot
gitpeterwind Jul 24, 2024
f734374
removed typename template and upgrades
gitpeterwind Jul 26, 2024
47471f8
moved ComplexFunctions.h from parallel.cpp to Bank.h
gitpeterwind Jul 29, 2024
aa6f254
removed the mpi:: in parallel.cpp
gitpeterwind Jul 29, 2024
52a6d52
Function vector with pointers
gitpeterwind Jul 29, 2024
0971589
explicit real and complex reduce and broadcast
gitpeterwind Jul 29, 2024
6e6e881
all functions upgraded to component functions
gitpeterwind Aug 1, 2024
da6e5e9
added #ifdef MRCPP_HAS_MPI in parallel.cpp
gitpeterwind Aug 1, 2024
6ffb77f
moved #ifdef MRCPP_HAS_MPI in parallel.cpp
gitpeterwind Aug 1, 2024
36ee92b
compiles together with UseComponent branch of mrchem
gitpeterwind Aug 5, 2024
0df20bc
removed ComplexFunction from api
gitpeterwind Aug 5, 2024
1e33df7
shared CompFunctions trees
gitpeterwind Aug 6, 2024
e95e128
dagger, serial rotate and overlap
gitpeterwind Aug 14, 2024
5d8ee63
multiply, apply, rescale, mixed types
gitpeterwind Aug 21, 2024
6624a73
orthogonalize for complex type
gitpeterwind Aug 22, 2024
1b29dea
all tests passes
gitpeterwind Aug 23, 2024
d9b07c2
mixed complex/real linear combination
gitpeterwind Aug 26, 2024
9081abb
redefined alloc for components
gitpeterwind Aug 26, 2024
9db89c6
soft multiplicative factor for components
gitpeterwind Aug 28, 2024
6d718ec
Merge branch 'master' of github.com:MRChemSoft/mrcpp into FourComponents
gitpeterwind Aug 28, 2024
cdd24cb
read and write orbitals in text format
gitpeterwind Dec 19, 2024
1548bbf
read and write set of orbitals
gitpeterwind Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/MWFunctions
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "trees/BoundingBox.h"
#include "trees/FunctionTree.h"
#include "trees/FunctionTreeVector.h"
#include "utils/ComplexFunction.h"
#include "utils/CompFunction.h"

#include "core/InterpolatingBasis.h"
#include "core/LegendreBasis.h"
Expand Down
55 changes: 28 additions & 27 deletions api/mrcpp_declarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,36 @@ namespace mrcpp {

class Timer;
class Printer;
template <int D> class Plotter;
template <int D, typename T = double> class Plotter;

template <int D> class Gaussian;
template <int D> class GaussFunc;
template <int D> class GaussPoly;
template <int D> class GaussExp;

template <int D> class BoundingBox;
template <int D> class NodeBox;
template <int D, typename T = double> class NodeBox;
template <int D> class NodeIndex;
template <int D> class NodeIndexComp;

class SharedMemory;
template <typename T = double> class SharedMemory;
class ScalingBasis;
class LegendreBasis;
class InterpolatingBasis;

template <int D> class RepresentableFunction;
template <int D, typename T = double> class RepresentableFunction;
template <int D> class MultiResolutionAnalysis;

template <int D> class MWTree;
template <int D> class FunctionTree;
template <int D, typename T = double> class MWTree;
template <int D, typename T = double> class FunctionTree;
class OperatorTree;

template <int D> class NodeAllocator;
template <int D, typename T = double> class NodeAllocator;

template <int D> class MWNode;
template <int D> class FunctionNode;
template <int D, typename T = double> class MWNode;
template <int D, typename T = double> class FunctionNode;
template <int D = 3> class CompFunction;
class ComplexFunction;
class OperatorNode;

template <int D> class IdentityConvolution;
Expand All @@ -79,31 +81,30 @@ template <int D> class DerivativeKernel;
class PoissonKernel;
class HelmholtzKernel;

template <int D> class TreeBuilder;
template <int D> class TreeCalculator;
template <int D> class DefaultCalculator;
template <int D> class ProjectionCalculator;
template <int D> class AdditionCalculator;
template <int D> class MultiplicationCalculator;
template <int D> class ConvolutionCalculator;
template <int D> class DerivativeCalculator;
template <int D, typename T = double> class TreeBuilder;
template <int D, typename T = double> class TreeCalculator;
template <int D, typename T = double> class DefaultCalculator;
template <int D, typename T = double> class ProjectionCalculator;
template <int D, typename T = double> class AdditionCalculator;
template <int D, typename T = double> class MultiplicationCalculator;
template <int D, typename T = double> class ConvolutionCalculator;
template <int D, typename T = double> class DerivativeCalculator;
class CrossCorrelationCalculator;

template <int D> class TreeAdaptor;
template <int D> class AnalyticAdaptor;
template <int D> class WaveletAdaptor;
template <int D> class CopyAdaptor;
template <int D, typename T = double> class TreeAdaptor;
template <int D, typename T = double> class AnalyticAdaptor;
template <int D, typename T = double> class WaveletAdaptor;
template <int D, typename T = double> class CopyAdaptor;

template <int D> class TreeIterator;
template <int D> class IteratorNode;
template <int D, typename T = double> class TreeIterator;
template <int D, typename T = double> class IteratorNode;

class BandWidth;
template <int D> class OperatorState;
template <int D, typename T = double> class OperatorState;

template <int D> using Coord = std::array<double, D>;
template <int D> using MWNodeVector = std::vector<MWNode<D> *>;
template <int D, typename T = double> using MWNodeVector = std::vector<MWNode<D, T> *>;

template <typename T, typename U> using FMap_ = std::function<T(U)>;
typedef FMap_<double, double> FMap;
template <typename T = double, typename U = double> using FMap = std::function<T(U)>;

} // namespace mrcpp
4 changes: 2 additions & 2 deletions examples/derivative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ int main(int argc, char **argv) {
mrcpp::FunctionTree<D> err_tree(MRA);

// Projecting functions
mrcpp::project<D>(prec, f_tree, f);
mrcpp::project<D>(prec, df_tree, df);
mrcpp::project<D, double>(prec, f_tree, f);
mrcpp::project<D, double>(prec, df_tree, df);

// Applying derivative operator
mrcpp::apply(dg_tree, D_00, f_tree, 0);
Expand Down
2 changes: 1 addition & 1 deletion examples/mpi_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main(int argc, char **argv) {
};
mrcpp::FunctionTree<3> *tree = new mrcpp::FunctionTree<3>(MRA);
if (i % wsize == wrank) {
mrcpp::project<3>(prec, *tree, f);
mrcpp::project<3, double>(prec, *tree, f);
tree->normalize();
}
f_vec.push_back(std::make_tuple(1.0, tree));
Expand Down
2 changes: 1 addition & 1 deletion examples/mpi_send_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main(int argc, char **argv) {
mrcpp::FunctionTree<D> f_tree(MRA);

// Only rank 0 projects the function
if (wrank == 0) mrcpp::project<D>(prec, f_tree, f);
if (wrank == 0) mrcpp::project<D, double>(prec, f_tree, f);

{ // Print data before send
auto integral = f_tree.integrate();
Expand Down
4 changes: 2 additions & 2 deletions examples/mpi_shared_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ int main(int argc, char **argv) {
};

// Initialize a shared memory tree, max 100MB
auto shared_mem = new mrcpp::SharedMemory(scomm, 100);
auto shared_mem = new mrcpp::SharedMemory<double>(scomm, 100);
mrcpp::FunctionTree<D> f_tree(MRA, shared_mem);

// Only first rank projects
auto frank = 0;
if (srank == frank) mrcpp::project<D>(prec, f_tree, f);
if (srank == frank) mrcpp::project<D, double>(prec, f_tree, f);
mrcpp::share_tree(f_tree, frank, 0, scomm);

{ // Print data after share
Expand Down
2 changes: 1 addition & 1 deletion examples/projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main(int argc, char **argv) {

// Projecting function
mrcpp::FunctionTree<D> f_tree(MRA);
mrcpp::project<D>(prec, f_tree, f, -1);
mrcpp::project<D, double>(prec, f_tree, f, -1);
auto integral = f_tree.integrate();

mrcpp::print::header(0, "Projecting analytic function");
Expand Down
4 changes: 2 additions & 2 deletions examples/scf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void setupNuclearPotential(double Z, FunctionTree<D> &V) {
};

// Projecting function
project<D>(prec, V, f);
project<D, double>(prec, V, f);

print::footer(0, timer, 2);
Printer::setPrintLevel(oldlevel);
Expand All @@ -48,7 +48,7 @@ void setupInitialGuess(FunctionTree<D> &phi) {
};

// Projecting and normalizing function
project<D>(prec, phi, f);
project<D, double>(prec, phi, f);
phi.normalize();

print::footer(0, timer, 2);
Expand Down
8 changes: 4 additions & 4 deletions examples/schrodinger_semigroup1d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ int main(int argc, char **argv)

// Projecting functions
mrcpp::FunctionTree<1> Re_f_tree(MRA);
mrcpp::project<1>(prec, Re_f_tree, Re_f);
mrcpp::project<1, double>(prec, Re_f_tree, Re_f);
mrcpp::FunctionTree<1> Im_f_tree(MRA);
mrcpp::project<1>(prec, Im_f_tree, Im_f);
mrcpp::project<1, double>(prec, Im_f_tree, Im_f);
mrcpp::FunctionTree<1> Re_g_tree(MRA);
mrcpp::project<1>(prec, Re_g_tree, Re_g);
mrcpp::project<1, double>(prec, Re_g_tree, Re_g);
mrcpp::FunctionTree<1> Im_g_tree(MRA);
mrcpp::project<1>(prec, Im_g_tree, Im_g);
mrcpp::project<1, double>(prec, Im_g_tree, Im_g);

// Output function trees
mrcpp::FunctionTree<1> Re_fout_tree(MRA);
Expand Down
5 changes: 3 additions & 2 deletions examples/tree_cleaner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const auto order = 7;
const auto prec = 1.0e-5;

const auto D = 3;

int main(int argc, char **argv) {
auto timer = mrcpp::Timer();

Expand Down Expand Up @@ -42,14 +43,14 @@ int main(int argc, char **argv) {
auto iter = 0;
auto n_nodes = 1;
while (n_nodes > 0) {
mrcpp::project<D>(-1.0, f_tree, f); // Projecting on fixed grid
mrcpp::project<D, double>(-1.0, f_tree, f); // Projecting on fixed grid
n_nodes = mrcpp::refine_grid(f_tree, prec); // Refine grid
mrcpp::clear_grid(f_tree); // Clear MW coefs
printout(0, " iter " << std::setw(3) << iter++ << std::setw(45));
printout(0, " n_nodes " << std::setw(5) << n_nodes << std::endl);
}
// Projecting on final converged grid
mrcpp::project<D>(-1.0, f_tree, f);
mrcpp::project<D, double>(-1.0, f_tree, f);

auto integral = f_tree.integrate();
auto sq_norm = f_tree.getSquareNorm();
Expand Down
16 changes: 8 additions & 8 deletions src/functions/AnalyticFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,29 @@

namespace mrcpp {

template <int D> class AnalyticFunction : public RepresentableFunction<D> {
template <int D, typename T = double> class AnalyticFunction : public RepresentableFunction<D, T> {
public:
AnalyticFunction() = default;
~AnalyticFunction() override = default;

AnalyticFunction(std::function<double(const Coord<D> &r)> f, const double *a = nullptr, const double *b = nullptr)
: RepresentableFunction<D>(a, b)
AnalyticFunction(std::function<T(const Coord<D> &r)> f, const double *a = nullptr, const double *b = nullptr)
: RepresentableFunction<D, T>(a, b)
, func(f) {}
AnalyticFunction(std::function<double(const Coord<D> &r)> f,
AnalyticFunction(std::function<T(const Coord<D> &r)> f,
const std::vector<double> &a,
const std::vector<double> &b)
: AnalyticFunction(f, a.data(), b.data()) {}

void set(std::function<double(const Coord<D> &r)> f) { this->func = f; }
void set(std::function<T(const Coord<D> &r)> f) { this->func = f; }

double evalf(const Coord<D> &r) const override {
double val = 0.0;
T evalf(const Coord<D> &r) const override {
T val = 0.0;
if (not this->outOfBounds(r)) val = this->func(r);
return val;
}

protected:
std::function<double(const Coord<D> &r)> func;
std::function<T(const Coord<D> &r)> func;
};

} // namespace mrcpp
6 changes: 3 additions & 3 deletions src/functions/BoysFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
namespace mrcpp {

BoysFunction::BoysFunction(int n, double p)
: RepresentableFunction<1>()
: RepresentableFunction<1, double>()
, order(n)
, prec(p)
, MRA(BoundingBox<1>(), InterpolatingBasis(13)) {}
Expand All @@ -50,8 +50,8 @@ double BoysFunction::evalf(const Coord<1> &r) const {
return std::exp(-xt_2) * t_2n;
};

FunctionTree<1> tree(this->MRA);
mrcpp::project<1>(this->prec, tree, f);
FunctionTree<1, double> tree(this->MRA);
mrcpp::project<1, double>(this->prec, tree, f);
double result = tree.integrate();

Printer::setPrintLevel(oldlevel);
Expand Down
2 changes: 1 addition & 1 deletion src/functions/BoysFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace mrcpp {

class BoysFunction final : public RepresentableFunction<1> {
class BoysFunction final : public RepresentableFunction<1, double> {
public:
BoysFunction(int n, double prec = 1.0e-10);

Expand Down
2 changes: 1 addition & 1 deletion src/functions/GaussExp.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace mrcpp {
*
*/

template <int D> class GaussExp : public RepresentableFunction<D> {
template <int D> class GaussExp : public RepresentableFunction<D, double> {
public:
GaussExp(int nTerms = 0, double prec = GAUSS_EXP_PREC);
GaussExp(const GaussExp<D> &gExp);
Expand Down
2 changes: 1 addition & 1 deletion src/functions/Gaussian.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

namespace mrcpp {

template <int D> class Gaussian : public RepresentableFunction<D> {
template <int D> class Gaussian : public RepresentableFunction<D, double> {
public:
Gaussian(double a, double c, const Coord<D> &r, const std::array<int, D> &p);
Gaussian(const std::array<double, D> &a, double c, const Coord<D> &r, const std::array<int, D> &p);
Expand Down
2 changes: 1 addition & 1 deletion src/functions/Polynomial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace mrcpp {
/** Construct polynomial of order zero with given size and bounds.
* Includes default constructor. */
Polynomial::Polynomial(int k, const double *a, const double *b)
: RepresentableFunction<1>(a, b) {
: RepresentableFunction<1, double>(a, b) {
assert(k >= 0);
this->N = 1.0;
this->L = 0.0;
Expand Down
2 changes: 1 addition & 1 deletion src/functions/Polynomial.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

namespace mrcpp {

class Polynomial : public RepresentableFunction<1> {
class Polynomial : public RepresentableFunction<1, double> {
public:
Polynomial(int k = 0, const double *a = nullptr, const double *b = nullptr);
Polynomial(int k, const std::vector<double> &a, const std::vector<double> &b)
Expand Down
21 changes: 12 additions & 9 deletions src/functions/RepresentableFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

namespace mrcpp {

template <int D> RepresentableFunction<D>::RepresentableFunction(const double *a, const double *b) {
template <int D, typename T> RepresentableFunction<D, T>::RepresentableFunction(const double *a, const double *b) {
if (a == nullptr or b == nullptr) {
this->bounded = false;
this->A = nullptr;
Expand All @@ -56,7 +56,7 @@ template <int D> RepresentableFunction<D>::RepresentableFunction(const double *a
}

/** Constructs a new function with same bounds as the input function */
template <int D> RepresentableFunction<D>::RepresentableFunction(const RepresentableFunction<D> &func) {
template <int D, typename T> RepresentableFunction<D, T>::RepresentableFunction(const RepresentableFunction<D, T> &func) {
if (func.isBounded()) {
this->bounded = true;
this->A = new double[D];
Expand All @@ -74,11 +74,11 @@ template <int D> RepresentableFunction<D>::RepresentableFunction(const Represent

/** Copies function, not bounds. Use copy constructor if you want an
* identical function. */
template <int D> RepresentableFunction<D> &RepresentableFunction<D>::operator=(const RepresentableFunction<D> &func) {
template <int D, typename T> RepresentableFunction<D, T> &RepresentableFunction<D, T>::operator=(const RepresentableFunction<D, T> &func) {
return *this;
}

template <int D> RepresentableFunction<D>::~RepresentableFunction() {
template <int D, typename T> RepresentableFunction<D, T>::~RepresentableFunction() {
if (this->isBounded()) {
delete[] this->A;
delete[] this->B;
Expand All @@ -87,7 +87,7 @@ template <int D> RepresentableFunction<D>::~RepresentableFunction() {
this->B = nullptr;
}

template <int D> void RepresentableFunction<D>::setBounds(const double *a, const double *b) {
template <int D, typename T> void RepresentableFunction<D, T>::setBounds(const double *a, const double *b) {
if (a == nullptr or b == nullptr) { MSG_ERROR("Invalid arguments"); }
if (not isBounded()) {
this->bounded = true;
Expand All @@ -101,7 +101,7 @@ template <int D> void RepresentableFunction<D>::setBounds(const double *a, const
}
}

template <int D> bool RepresentableFunction<D>::outOfBounds(const Coord<D> &r) const {
template <int D, typename T> bool RepresentableFunction<D, T>::outOfBounds(const Coord<D> &r) const {
if (not isBounded()) { return false; }
for (int d = 0; d < D; d++) {
if (r[d] < getLowerBound(d)) return true;
Expand All @@ -110,8 +110,11 @@ template <int D> bool RepresentableFunction<D>::outOfBounds(const Coord<D> &r) c
return false;
}

template class RepresentableFunction<1>;
template class RepresentableFunction<2>;
template class RepresentableFunction<3>;
template class RepresentableFunction<1, double>;
template class RepresentableFunction<2, double>;
template class RepresentableFunction<3, double>;
template class RepresentableFunction<1, ComplexDouble>;
template class RepresentableFunction<2, ComplexDouble>;
template class RepresentableFunction<3, ComplexDouble>;

} // namespace mrcpp
Loading
Loading