MADNESS  0.10.1
Functions
examples/gaussian.cc File Reference

A simple example of projecting and using MADNESS functions. More...

#include <madness/mra/mra.h>
#include <madness/mra/operator.h>
Include dependency graph for examples/gaussian.cc:

Functions

double gaussian (const coord_3d &r)
 C++ function for projecting the Gaussian test function. More...
 
int main (int argc, char **argv)
 Main function. Project the function and compute the integrals. More...
 

Detailed Description

A simple example of projecting and using MADNESS functions.

This example projects a simple Gaussian function,

\[ g(\vec{x}) = e^{-|\vec{x}|^2}, \]

into the MADNESS adaptive basis and computes several integrals:

\[ \int \mathrm{d}^3 \vec{x} \; g(\vec{x}) = \pi^{3/2} \doteq 5.5683279, \]

\[ \left( \int \mathrm{d}^3 \vec{x} \; g(\vec{x})^2 \right)^{1/2} = (\pi/2)^{3/4} \doteq 1.403104, \]

\[ \int \mathrm{d}^3 \vec{x} \; g(\vec{x}) \int \mathrm{d}^3 \vec{y} \; |\vec{x}-\vec{y}|^{-1} g(\vec{y}) = \pi^{5/2} 2^{1/2} \doteq 24.739429. \]

Function Documentation

◆ gaussian()

double gaussian ( const coord_3d r)

C++ function for projecting the Gaussian test function.

Parameters
[in]rThe coordinate at which to evaluate the function.
Returns
The value of the Gaussian at the specified coordinate.

◆ main()

int main ( int  argc,
char **  argv 
)

Main function. Project the function and compute the integrals.

Parameters
[in]argcThe number of command-line arguments.
[in]argvThe command-line arguments.
Returns
Exit status.

References SafeMPI::COMM_WORLD, madness::CoulombOperator(), e(), madness::finalize(), madness::g, madness::initialize(), madness::inner(), op(), madness::print(), madness::FunctionDefaults< NDIM >::set_cubic_cell(), and madness::startup().