8 #ifndef SRC_EXAMPLES_SMOOTH_H_
9 #define SRC_EXAMPLES_SMOOTH_H_
23 if (x < 0.0)
return log(
RHOMIN);
33 if (fabs(x) <
thresh)
return 0.0;
38 return exp(-fabs(x[0])) + 0.1 * sin(30.0 * x[0]);
46 return x[0] * x[0] + x[1] * x[1] + x[2] * x[2];
64 double r = sqrt(
r2(x));
66 return 0.5 * (1.0 - tanh(1.0 * (r - 15)));
83 double f =
function(
IND);
92 template<
typename Archive>
109 double r = sqrt((x[0] * x[0] + x[1] * x[1] + x[2] * x[2]));
123 double prefactor = 1.0 / M_PI;
124 double r = sqrt((x[0] * x[0] + x[1] * x[1] + x[2] * x[2]));
144 double safety =
thresh_ * 0.01;
145 double safety_kernel =
pow(safety, -2.0 / 3.0);
146 double safety_kernel_safety_pd =
pre *
pow(safety, 1.0 / 3.0);
149 double pd = pt_rho(
IND);
150 if (
d < safety and fabs(pd) < safety) U(
IND) = safety_kernel_safety_pd;
151 else if (
d < safety) U(
IND) =
pre * safety_kernel * pd;
156 template<
typename Archive>
165 if (rho < 0.0) tmp = 0.0;
166 else tmp =
pow(rho, 1.0 / 3.0);
167 double prefactor = 1.0 / M_PI;
168 return prefactor * tmp;
179 const double r = sqrt((x[0] * x[0] + x[1] * x[1] + x[2] * x[2]));
180 const double kernel =
prefactor * exp(2.0 / 3.0 * 2.0 * sqrt(2.0 * fabs(
ipot)) * r);
193 if (tmp < 0.0) tmp = 1.e-10;
214 std::vector<long> kdims(3,
k);
226 madness::fcube<double, 3>(key,
asl, quad_x, kernel_val);
228 kernel_val =
copy(rho);
272 std::vector<long> kdims(3,
k);
306 template<std::
size_t NDIM>
313 template<std::
size_t NDIM>
319 template<std::
size_t NDIM>
324 template<std::
size_t NDIM>
325 static double munge(
const double x) {
330 template<
typename T, std::
size_t NDIM>
350 std::cout <<
"shift is " <<
shift_ << std::endl;
355 const double r = make_radius<NDIM>(shifted_x);
356 return (1.0 - tanh(r));
375 const double r = make_radius<NDIM>(shifted_x);
388 std::cout <<
"Make Sigma\n";
395 std::cout <<
"Make Smooth Density\n";
398 std::cout <<
"Make Smooth Sigma\n";
401 sigma.print_size(
"sigma");
412 for (
size_t i = 0; i < orbitals.size(); i++) {
423 density += sf_squared;
443 std::vector<std::shared_ptr<real_derivative_3d> >
gradop;
450 sigma += drho * drho;
459 std::cout <<
"Density thresh is " << density_thresh << std::endl;
464 linearized_ln_density =
gaussian_smoothing(linearized_ln_density, 0.5,
"linearized_ln_density");
469 return munged_density;
476 make_plots(result,
"linear_ln_rho_backprojected");
482 munged_density.
unaryop(munge<NDIM>);
483 return munged_density;
489 density_wrapper.push_back(density);
491 real_function_3d density_mask = multiop_values<double, density_mask_operator, 3>(op_tmp, density_wrapper);
498 double density_thresh =
thresh;
499 for (
size_t i = 0; i < 10; i++) {
500 double di = (double) i;
502 else density_thresh =
pow(10.0, -2.0 * di);
504 return density_thresh;
510 sample_wrapper.push_back(samplef);
512 real_function_3d mask = multiop_values<double, density_mask_operator, 3>(op_tmp, sample_wrapper);
545 make_plots(smoothed_logf,
"smoothed_log" + msg);
552 const std::string&
name =
"nooutput")
const {
554 double exponent = 1.0 / (2.0 * eps);
556 exponents(0
L) = exponent;
567 const std::string&
name =
"f")
const {
583 wrapper.push_back(
f);
584 wrapper.push_back(sf);
587 real_function_3d merged_f = multiop_values<double, merging_operator, 3>(op_tmp, wrapper);
608 exponents(0
L) = 1.0 / (2.0 * 0.04);
609 coeffs(0
L) =
pow((1.0 / (2.0 * 0.04)) / M_PI, 0.5);
618 plot_line(
"smoothed_1d", 1000, start, end, sf);
623 return pow(exponent / M_PI, 0.5 * 3.0);
626 void output(
const std::string& msg)
const {
627 if (
world.
rank() == 0) std::cout << msg << std::endl;
Operators for the molecular HF and DFT code.
Tensor< double > quad_x
quadrature points
Definition: function_common_data.h:99
FunctionDefaults holds default paramaters as static class members.
Definition: funcdefaults.h:204
static int get_k()
Returns the default wavelet order.
Definition: funcdefaults.h:266
static void set_thresh(double value)
Sets the default threshold.
Definition: funcdefaults.h:286
static void set_k(int value)
Sets the default wavelet order.
Definition: funcdefaults.h:273
static const double & get_thresh()
Returns the default threshold.
Definition: funcdefaults.h:279
static void set_cubic_cell(double lo, double hi)
Sets the user cell to be cubic with each dimension having range [lo,hi].
Definition: funcdefaults.h:461
static double get_cell_min_width()
Returns the minimum width of any user cell dimension.
Definition: funcdefaults.h:478
FunctionFactory implements the named-parameter idiom for Function.
Definition: function_factory.h:86
FunctionFactory & f(T(*f)(const coordT &))
Definition: function_factory.h:180
Abstract base class interface required for functors used as input to Functions.
Definition: function_interface.h:68
A multiresolution adaptive numerical function.
Definition: mra.h:122
const Function< T, NDIM > & refine(bool fence=true) const
Inplace autorefines the function using same test as for squaring.
Definition: mra.h:830
bool autorefine() const
Retunrs.
Definition: mra.h:548
const Function< T, NDIM > & reconstruct(bool fence=true) const
Reconstructs the function, transforming into scaling function basis. Possible non-blocking comm.
Definition: mra.h:775
void unaryop(T(*f)(T))
Inplace unary operation on function values.
Definition: mra.h:895
Key is the index for a node of the 2^NDIM-tree.
Definition: key.h:66
scalar_type absmax(long *ind=0) const
Return the absolute maximum value (and if ind is non-null, its index) in the Tensor.
Definition: tensor.h:1754
Tensor< T > & unaryop(opT &op)
Inplace apply a unary function to each element of the tensor.
Definition: tensor.h:1792
Tensor< T > & emul(const Tensor< T > &t)
Inplace multiply by corresponding elements of argument Tensor.
Definition: tensor.h:1798
A simple, fixed dimension vector.
Definition: vector.h:64
A parallel world class.
Definition: world.h:132
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition: world.h:318
Function< T, NDIM > merge_functions(const Function< T, NDIM > &f, const Function< T, NDIM > &sf, const Function< T, NDIM > &mask, const std::string &name="f") const
Definition: smooth.h:566
double gauss_norm(const double &exponent) const
Definition: smooth.h:622
Function< T, NDIM > mask_
Definition: smooth.h:633
Function< T, NDIM > cut_oscillations(const Function< T, NDIM > &f, const double &cutoff, const size_t order) const
Definition: smooth.h:432
void test_1d() const
Definition: smooth.h:602
void output(const std::string &msg) const
Definition: smooth.h:626
World & world
Definition: smooth.h:631
smooth(World &world, const double &box_mask_factor, const double box_mask_cutoff)
Definition: smooth.h:337
Function< T, NDIM > linearize(const Function< T, NDIM > &ln_rho) const
Definition: smooth.h:472
Function< T, NDIM > smooth_density_from_orbitals(const std::vector< Function< T, NDIM >> &orbitals) const
Definition: smooth.h:409
void make_plots(const Function< T, NDIM > &f, const std::string &name="function") const
Definition: smooth.h:591
const Function< T, NDIM > box_mask_
Definition: smooth.h:632
Function< T, NDIM > make_inv_mask(const Function< T, NDIM > &mask) const
Definition: smooth.h:520
Function< T, NDIM > make_mask(const Function< T, NDIM > &samplef, const double &thresh) const
Definition: smooth.h:507
Function< T, NDIM > make_explog(const Function< T, NDIM > &f, const std::string &msg="function") const
Definition: smooth.h:528
Function< T, NDIM > make_density_mask(const Function< T, NDIM > &density) const
Definition: smooth.h:486
Function< T, NDIM > gaussian_smoothing(const Function< T, NDIM > &f, const double &eps=0.04, const std::string &name="nooutput") const
Definition: smooth.h:551
Function< T, NDIM > smooth_sigma(const Function< T, NDIM > &density)
Definition: smooth.h:386
Function< T, NDIM > inv_mask_
Definition: smooth.h:634
double get_density_thresh() const
Definition: smooth.h:496
Function< T, NDIM > smooth_density(const Function< T, NDIM > &density, const std::string &msg="function")
Definition: smooth.h:455
Function< T, NDIM > merge_functions(const Function< T, NDIM > &f, const Function< T, NDIM > &sf, const double &thresh) const
Definition: smooth.h:580
smooth(World &world)
Definition: smooth.h:333
Function< T, NDIM > munge_density(const Function< T, NDIM > &density) const
Definition: smooth.h:480
Function< T, NDIM > make_sigma(const Function< T, NDIM > &density) const
Definition: smooth.h:441
const double sigma
Definition: dielectric.cc:185
real_function_3d mask
Definition: dirac-hatom.cc:27
static double shift
Definition: dirac-hatom.cc:19
Defines/implements plotting interface for functions.
std::vector< std::shared_ptr< real_derivative_3d > > gradop
Definition: h2dft.cc:51
Tensor< double > op(const Tensor< double > &x)
Definition: kain.cc:508
static double pow(const double *a, const double *b)
Definition: lda.h:74
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition: madness_exception.h:134
File holds all helper structures necessary for the CC_Operator and CC2 class.
Definition: DFParameters.h:10
static double cutoff_radius
Definition: smooth.h:56
static std::string stringify(T arg)
Definition: funcplot.h:1034
static double mask_munging(const double x)
Definition: smooth.h:314
static double mask_functor_box(const coord_3d &x)
Definition: smooth.h:63
response_space apply(World &world, std::vector< std::vector< std::shared_ptr< real_convolution_3d >>> &op, response_space &f)
Definition: basic_operators.cc:39
static double make_radius(const Vector< double, NDIM > &x)
Definition: smooth.h:307
Function< T, NDIM > project(const Function< T, NDIM > &other, int k=FunctionDefaults< NDIM >::get_k(), double thresh=FunctionDefaults< NDIM >::get_thresh(), bool fence=true)
Definition: mra.h:2399
static double r2(const coord_3d &x)
Definition: smooth.h:45
Function< T, NDIM > copy(const Function< T, NDIM > &f, const std::shared_ptr< WorldDCPmapInterface< Key< NDIM > > > &pmap, bool fence=true)
Create a new copy of the function with different distribution and optional fence.
Definition: mra.h:2002
double norm2(World &world, const std::vector< Function< T, NDIM > > &v)
Computes the 2-norm of a vector of functions.
Definition: vmra.h:851
static double slater_functor(const coord_3d &x)
Definition: smooth.h:49
void plot_plane(World &world, const Function< double, NDIM > &function, const std::string name)
Definition: funcplot.h:621
FunctionFactory< double, 3 > real_factory_3d
Definition: functypedefs.h:93
FunctionFactory< double, 1 > real_factory_1d
Definition: functypedefs.h:91
double make_log(double x)
Definition: smooth.h:22
static double mask_factor
Definition: smooth.h:55
NDIM & f
Definition: mra.h:2416
static double xf(const coord_3d &x)
Definition: smooth.h:41
double make_exp(double x)
Definition: smooth.h:27
vector< functionT > vecfuncT
Definition: corepotential.cc:58
void refine_to_common_level(World &world, std::vector< Function< T, NDIM > > &vf, bool fence=true)
refine all functions to a common (finest) level
Definition: vmra.h:218
static double test_1d_functor(const coord_1d &x)
Definition: smooth.h:37
double estimate_area(double x)
Definition: smooth.h:31
static double analytical_slater_functor(double rho)
Definition: smooth.h:163
static double munge(const double x)
Definition: smooth.h:325
void plot_line(World &world, const char *filename, int npt, const Vector< double, NDIM > &lo, const Vector< double, NDIM > &hi, const opT &op)
Generates ASCII file tabulating f(r) at npoints along line r=lo,...,hi.
Definition: funcplot.h:438
std::string name(const FuncType &type, const int ex=-1)
Definition: ccpairfunction.h:28
static double unitfunctor(const Vector< double, NDIM > &x)
Definition: smooth.h:320
static Function< T, NDIM > diff(const Function< T, NDIM > &f, int axis)
Definition: navstokes_cosines.cc:119
static const double c
Definition: relops.cc:10
static const double L
Definition: rk.cc:46
static const double thresh
Definition: rk.cc:45
static const long k
Definition: rk.cc:44
const double xi
Exponent for delta function approx.
Definition: siam_example.cc:60
static double RHOMIN
Definition: smooth.h:19
double operator()(const double &rho) const
Definition: smooth.h:191
const double prefactor
Definition: smooth.h:197
const double safety_thresh_rho
Definition: smooth.h:242
const double prefactor
Definition: smooth.h:239
madness::Tensor< double > slater_apply(const std::vector< madness::Tensor< double > > &t, const madness::Key< 3 > &key, const FunctionCommonData< double, 3 > cdata) const
Definition: smooth.h:201
asymptotic_slater asl
Definition: smooth.h:241
apply_kernel_helper(const double &ipot_)
Definition: smooth.h:188
const double ipot
Definition: smooth.h:240
const double safety_thresh_ptrho
Definition: smooth.h:243
double operator()(const coord_3d &x1) const
Definition: smooth.h:104
const coord_3d center_of_charge_
Definition: smooth.h:115
asymptotic_density(const double &ie)
Definition: smooth.h:100
asymptotic_density(const double &ie, const coord_3d &coc)
Definition: smooth.h:102
const double ionization_energy_
Definition: smooth.h:114
const asymptotic_density asymptotic_rho_
Definition: smooth.h:132
asymptotic_slater_kernel(const asymptotic_density &tmp)
Definition: smooth.h:120
double operator()(const coord_3d &x) const
Definition: smooth.h:122
double operator()(const coord_3d &x) const
Definition: smooth.h:178
asymptotic_slater(const double &ipot_)
Definition: smooth.h:173
const double ipot
Definition: smooth.h:175
const double prefactor
Definition: smooth.h:176
density_mask_operator(const double thresh)
Definition: smooth.h:264
const double safety
Definition: smooth.h:283
madness::Tensor< double > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition: smooth.h:266
const double cutoff
Definition: smooth.h:302
madness::Tensor< double > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition: smooth.h:290
merging_operator(const double c)
Definition: smooth.h:288
munging_operator()
Definition: smooth.h:74
double thresh_
Definition: smooth.h:95
void operator()(const Key< 3 > &key, real_tensor U, const real_tensor &function, const real_tensor &smoothed_function) const
Definition: smooth.h:78
munging_operator(const double thresh)
Definition: smooth.h:76
void serialize(Archive &ar)
Definition: smooth.h:93
madness::Tensor< double > operator()(const madness::Key< 3 > &key, const std::vector< madness::Tensor< double > > &t) const
Definition: smooth.h:255
const apply_kernel_helper * xc
Definition: smooth.h:250
slater_kernel_apply(const apply_kernel_helper &xc_)
Definition: smooth.h:252
const FunctionCommonData< double, 3 > & cdata
Definition: smooth.h:248
void operator()(const Key< 3 > &key, real_tensor U, const real_tensor &rho, const real_tensor &pt_rho) const
Definition: smooth.h:140
void serialize(Archive &ar)
Definition: smooth.h:157
slater_kernel()
Definition: smooth.h:136
double thresh_
Definition: smooth.h:159
slater_kernel(const double thresh)
Definition: smooth.h:138
double pre
Definition: smooth.h:160
inv_mask_functor(const double &factor, const double &cutoff, const Vector< double, NDIM > shift)
Definition: smooth.h:370
const double factor_
Definition: smooth.h:380
double operator()(const Vector< double, NDIM > &x) const
Definition: smooth.h:373
const Vector< double, NDIM > shift_
Definition: smooth.h:382
inv_mask_functor(const double &factor, const double &cutoff)
Definition: smooth.h:367
const double cutoff_radius_
Definition: smooth.h:381
mask_functor(const double &factor, const double &cutoff)
Definition: smooth.h:343
const double factor_
Definition: smooth.h:360
const Vector< double, NDIM > shift_
Definition: smooth.h:362
const double cutoff_radius_
Definition: smooth.h:361
mask_functor(const double &factor, const double &cutoff, const Vector< double, NDIM > shift)
Definition: smooth.h:346
double operator()(const Vector< double, NDIM > &x) const
Definition: smooth.h:353
#define ITERATOR(t, exp)
Definition: tensor_macros.h:249
#define IND
Definition: tensor_macros.h:204
void d()
Definition: test_sig.cc:79
static const std::size_t NDIM
Definition: testpdiff.cc:42