MADNESS  0.10.1
smooth.h
Go to the documentation of this file.
1 /*
2  * smooth.h
3  *
4  * Created on: Nov 25, 2015
5  * Author: kottmanj
6  */
7 
8 #ifndef SRC_EXAMPLES_SMOOTH_H_
9 #define SRC_EXAMPLES_SMOOTH_H_
10 
11 #include <iostream>
12 #include <string>
13 #include<madness/chem/nemo.h>
14 #include <madness/mra/funcplot.h>
15 #include <cmath>
18 
19 static double RHOMIN = 1.e-20;
20 
21 namespace madness {
22 double make_log(double x) {
23  if (x < 0.0) return log(RHOMIN);
24  return log(x);
25 }
26 
27 double make_exp(double x) {
28  return exp(x);
29 }
30 
31 double estimate_area(double x) {
33  if (fabs(x) < thresh) return 0.0;
34  else return 1.0;
35 }
36 
37 static double test_1d_functor(const coord_1d& x) {
38  return exp(-fabs(x[0])) + 0.1 * sin(30.0 * x[0]);
39 }
40 
41 static double xf(const coord_3d& x) {
42  return x[1];
43 }
44 
45 static double r2(const coord_3d& x) {
46  return x[0] * x[0] + x[1] * x[1] + x[2] * x[2];
47 }
48 
49 static double slater_functor(const coord_3d& x) {
50  double rsq = r2(x);
51  double r = sqrt(rsq);
52  return exp(-r);
53 }
54 
55 static double mask_factor = 5.0;
56 static double cutoff_radius = 5.0;
57 
58 //static double mask_functor(const coord_3d &x){
59 // double r = sqrt(r2(x));
60 // //return 1-erf(mask_factor*r);
61 // return 0.5*(1.0 - tanh(mask_factor*(r-cutoff_radius)));
62 //}
63 static double mask_functor_box(const coord_3d& x) {
64  double r = sqrt(r2(x));
65  //return 1-erf(mask_factor*r);
66  return 0.5 * (1.0 - tanh(1.0 * (r - 15)));
67 }
68 //static double inv_mask_functor(const coord_3d &x){
69 // double r = sqrt(r2(x));
70 // return 0.5*(1.0 + tanh(mask_factor*(r-cutoff_radius)));
71 //}
72 
74  munging_operator() : thresh_(FunctionDefaults<3>::get_thresh()) {}
75 
76  munging_operator(const double thresh) : thresh_(thresh) {}
77 
78  void operator()(const Key<3>& key,
79  real_tensor U,
80  const real_tensor& function,
81  const real_tensor& smoothed_function) const {
82  ITERATOR(U,
83  double f = function(IND);
84  //double sf = smoothed_function(IND);
85  if (fabs(f) < thresh_)
86  U(IND) = 0.0;
87  else
88  U(IND) = f;
89  );
90  }
91 
92  template<typename Archive>
93  void serialize(Archive& ar) {}
94 
95  double thresh_;
96 };
97 
99 public:
100  asymptotic_density(const double& ie) : ionization_energy_(ie), center_of_charge_(0.0) {}
101 
102  asymptotic_density(const double& ie, const coord_3d& coc) : ionization_energy_(ie), center_of_charge_(coc) {}
103 
104  double operator()(const coord_3d& x1) const {
105  coord_3d x;
106  x[0] = x1[0] - center_of_charge_[0];
107  x[1] = x1[1] - center_of_charge_[1];
108  x[2] = x1[2] - center_of_charge_[2];
109  double r = sqrt((x[0] * x[0] + x[1] * x[1] + x[2] * x[2]));
110  double result = exp(-2.0 * sqrt(2.0 * fabs(ionization_energy_)) * r);
111  return result;
112  }
113 
114  const double ionization_energy_;
116 };
117 
119 public:
121 
122  double operator()(const coord_3d& x) const {
123  double prefactor = 1.0 / M_PI;
124  double r = sqrt((x[0] * x[0] + x[1] * x[1] + x[2] * x[2]));
125  double kernel = prefactor * exp(2.0 / 3.0 * 2.0 * sqrt(2.0 * fabs(asymptotic_rho_.ionization_energy_)) *
126  r);//pow(rho,2.0/3.0);
127  double rho = asymptotic_rho_(x);
128  return kernel * rho;
129  }
130 
131 private:
133 };
134 
136  slater_kernel() : thresh_(FunctionDefaults<3>::get_thresh()) {}
137 
138  slater_kernel(const double thresh) : thresh_(thresh) {}
139 
140  void operator()(const Key<3>& key,
141  real_tensor U,
142  const real_tensor& rho,
143  const real_tensor& pt_rho) const {
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);
147  ITERATOR(U,
148  double d = rho(IND);
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;
152  else U(IND) = pre * pow(d, -2.0 / 3.0) * pd;
153  );
154  }
155 
156  template<typename Archive>
157  void serialize(Archive& ar) {}
158 
159  double thresh_;
160  double pre = 1.0 / M_PI;
161 };
162 
163 static double analytical_slater_functor(double rho) {
164  double tmp;
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;
169 }
170 
171 struct asymptotic_slater : public FunctionFunctorInterface<double, 3> {
172 public:
173  asymptotic_slater(const double& ipot_) : ipot(ipot_) {}
174 
175  const double ipot;
176  const double prefactor = 1.0 / M_PI;
177 
178  double operator()(const coord_3d& x) const {
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);
181  return kernel;
182  }
183 };
184 
186 
187 public:
188  apply_kernel_helper(const double& ipot_) : ipot(ipot_), asl(ipot_) {}
189 
190  struct slater_kernel {
191  double operator()(const double& rho) const {
192  double tmp = rho;
193  if (tmp < 0.0) tmp = 1.e-10;
194  return prefactor * pow(tmp, -2.0 / 3.0);
195  }
196 
197  const double prefactor = 1.0 / M_PI;
198  };
199 
200 
202  const FunctionCommonData<double, 3> cdata) const {
203  madness::Tensor<double> rho = t.front();
204  madness::Tensor<double> pt_rho = t.back();
205  const long k = FunctionDefaults<3>::get_k();
206  const Tensor<double>& quad_x = cdata.quad_x;
207 
208  // if all points of the perturbed density are below the threshold: Set the result to zero
209  bool pt_zero = true;
210  if (pt_rho.absmax() > safety_thresh_ptrho) pt_zero = false;
211 
212  // fast return if pt_rho is zero
213  if (pt_zero) {
214  std::vector<long> kdims(3, k);
215  Tensor<double> zero_result(kdims, true);
216  return zero_result;
217  }
218 
219  // if all points of the unperturbed density are below the threshold: Use asymptotical density
220  bool rho_ana = true;
221  //if(rho.absmax()>safety_thresh_rho) rho_ana = false;
222 
223  // analytical kernel based on asymptotical density
224  Tensor<double> kernel_val(k, k, k);
225  if (rho_ana) {
226  madness::fcube<double, 3>(key, asl, quad_x, kernel_val);
227  } else {
228  kernel_val = copy(rho);
229  slater_kernel slater_tmp;
230  kernel_val.unaryop<slater_kernel>(slater_tmp);
231  }
232 
233  // multiply kernel values with pt_rho values
234  Tensor<double> result = kernel_val.emul(pt_rho);
235  return result;
236 
237  }
238 
239  const double prefactor = 1.0 / M_PI;
240  const double ipot;
244 };
245 
247 
249 
251 
253  FunctionCommonData<double, 3>::get(FunctionDefaults<3>::get_k())), xc(&xc_) {}
254 
256  const std::vector<madness::Tensor<double> >& t) const {
258  return r;
259  }
260 };
261 
263 
265 
267  const std::vector<madness::Tensor<double> >& t) const {
268 
269  const madness::Tensor<double>& rho = t.front();
270  // set result to zero
271  const long& k = FunctionDefaults<3>::get_k();
272  std::vector<long> kdims(3, k);
273  madness::Tensor<double> result(kdims, true);
274  result = 3.0;
275  if (rho.absmax() < safety) {
276  result = 0.0;
277  } else {
278  result = 1.0;
279  }
280  return result;
281  }
282 
283  const double safety;
284 };
285 
287 
288  merging_operator(const double c) : cutoff(c) {}
289 
291  const std::vector<madness::Tensor<double> >& t) const {
292 
293  const madness::Tensor<double>& f = t.front();
294  const madness::Tensor<double>& sf = t.back();
295  if (f.absmax() > cutoff) {
296  return f;
297  } else {
298  return sf;
299  }
300  }
301 
302  const double cutoff;
303 };
304 
305 
306 template<std::size_t NDIM>
307 static double make_radius(const Vector<double, NDIM>& x) {
308  double r2 = 0.0;
309  for (double xi: x) r2 += xi * xi;
310  return sqrt(r2);
311 }
312 
313 template<std::size_t NDIM>
314 static double mask_munging(const double x) {
315  if (fabs(x) < 0.1 * FunctionDefaults<NDIM>::get_thresh()) return 0.0;
316  else return x;
317 }
318 
319 template<std::size_t NDIM>
320 static double unitfunctor(const Vector<double, NDIM>& x) {
321  return 1.0;
322 }
323 
324 template<std::size_t NDIM>
325 static double munge(const double x) {
326  if (fabs(x) < FunctionDefaults<NDIM>::get_thresh() * 0.001) return 1.e-20;
327  else return x;
328 }
329 
330 template<typename T, std::size_t NDIM>
331 class smooth {
332 public:
334  world(world) {
335  }
336 
337  smooth(World& world, const double& box_mask_factor, const double box_mask_cutoff) :
338  world(world) {
339  }
340 
341  struct mask_functor {
342  public:
343  mask_functor(const double& factor, const double& cutoff) : factor_(factor), cutoff_radius_(cutoff),
344  shift_(0.0) {}
345 
346  mask_functor(const double& factor, const double& cutoff, const Vector<double, NDIM> shift) : factor_(factor),
348  cutoff),
349  shift_(shift) {
350  std::cout << "shift is " << shift_ << std::endl;
351  }
352 
353  double operator()(const Vector<double, NDIM>& x) const {
354  const Vector<double, 3> shifted_x = x - shift_;
355  const double r = make_radius<NDIM>(shifted_x);
356  return (1.0 - tanh(r));
357  }
358 
359  private:
360  const double factor_;
361  const double cutoff_radius_;
363  };
364 
366  public:
367  inv_mask_functor(const double& factor, const double& cutoff) : factor_(factor), cutoff_radius_(cutoff),
368  shift_(0.0) {}
369 
370  inv_mask_functor(const double& factor, const double& cutoff, const Vector<double, NDIM> shift) : factor_(
371  factor), cutoff_radius_(cutoff), shift_(shift) {}
372 
373  double operator()(const Vector<double, NDIM>& x) const {
374  const Vector<double, 3> shifted_x = x - shift_;
375  const double r = make_radius<NDIM>(shifted_x);
376  return 0.5 * (1.0 + tanh(factor_ * (r - cutoff_radius_)));
377  }
378 
379  private:
380  const double factor_;
381  const double cutoff_radius_;
383  };
384 
385 
387  MADNESS_ASSERT(NDIM == 3);
388  std::cout << "Make Sigma\n";
389  real_function_3d sigma = make_sigma(density);
390  make_plots(density, "density");
391  make_plots(sigma, "sigma");
392 
393  const double cutoff = get_density_thresh();
394 
395  std::cout << "Make Smooth Density\n";
396  real_function_3d smooth_rho = cut_oscillations(density, cutoff);
397 
398  std::cout << "Make Smooth Sigma\n";
400  make_plots(smooth_sigma, "smooth_sigma");
401  sigma.print_size("sigma");
402  smooth_sigma.print_size("smooth_sigma");
403  make_plots(smooth_rho, "smooth_density");
404 
405 
406  return sigma;
407  }
408 
412  for (size_t i = 0; i < orbitals.size(); i++) {
413  Function<T, NDIM> orb = orbitals[i];
414  orb.refine();
415  Function<T, NDIM> boxes = cut_oscillations(orb, 1000.0, 1);
416  make_plots(boxes, "orbital_sceleton");
417  Function<T, NDIM> sf = cut_oscillations(orbitals[i], thresh, 1);
418  make_plots(sf, "smooth_orbital_1_" + stringify(i));
419  sf = cut_oscillations(sf, thresh * 0.1, 1);
420  make_plots(sf, "smooth_orbital_2_" + stringify(i));
421  sf = cut_oscillations(sf, thresh * 0.01, 1);
422  Function<T, NDIM> sf_squared = sf * sf;
423  density += sf_squared;
424  make_plots(sf, "smooth_orbital_3_" + stringify(i));
425  make_plots(sf_squared, "smooth_squared_orbital_" + stringify(i));
426  }
427  make_plots(density, "smooth_density");
428  return density;
429  }
430 
431  // Function gets linearized if it falls below certain threshold
432  Function<T, NDIM> cut_oscillations(const Function<T, NDIM>& f, const double& cutoff, const size_t order) const {
433  // project the function to linear scaling functions
434  Function<T, NDIM> lf = project(f, order);
436  // merge
437  const Function<T, NDIM> sf = merge_functions(f, lf, cutoff);
438  return sf;
439  }
440 
442  MADNESS_ASSERT(NDIM == 3);
443  std::vector<std::shared_ptr<real_derivative_3d> > gradop;
444  gradop = gradient_operator<double, 3>(world);
446  for (auto d: gradop) {
447  density.autorefine();
448  real_function_3d drho = (*d)(density);
449  drho.autorefine();
450  sigma += drho * drho;
451  }
452  return sigma;
453  }
454 
455  Function<T, NDIM> smooth_density(const Function<T, NDIM>& density, const std::string& msg = "function") {
456  make_plots(density, "density");
457  // if thresh is 1.e-x then density thresh is 1.e-2x
458  const double density_thresh = get_density_thresh();
459  std::cout << "Density thresh is " << density_thresh << std::endl;
460  Function<T, NDIM> ln_density = copy(density);
461  ln_density.unaryop(make_log);
462  make_plots(ln_density, "ln_density");
463  Function<T, NDIM> linearized_ln_density = linearize(ln_density);
464  linearized_ln_density = gaussian_smoothing(linearized_ln_density, 0.5, "linearized_ln_density");
465  Function<T, NDIM> smooth_density = copy(linearized_ln_density);
466  smooth_density.refine();
467  smooth_density.unaryop(make_exp);
469  return munged_density;
470  }
471 
473  Function<T, NDIM> linear_ln_rho = project(ln_rho, 2);
474  make_plots(linear_ln_rho, "linear_ln_rho");
475  Function<T, NDIM> result = project(linear_ln_rho, FunctionDefaults<NDIM>::get_k());
476  make_plots(result, "linear_ln_rho_backprojected");
477  return result;
478  }
479 
481  Function<T, NDIM> munged_density = copy(density);
482  munged_density.unaryop(munge<NDIM>);
483  return munged_density;
484  }
485 
487  vecfuncT density_wrapper;
488  density.reconstruct();
489  density_wrapper.push_back(density);
491  real_function_3d density_mask = multiop_values<double, density_mask_operator, 3>(op_tmp, density_wrapper);
492  make_plots(density_mask, "density_mask");
493  return density_mask;
494  }
495 
496  double get_density_thresh() const {
497  const double& thresh = FunctionDefaults<NDIM>::get_thresh();
498  double density_thresh = thresh;
499  for (size_t i = 0; i < 10; i++) {
500  double di = (double) i;
501  if (thresh > pow(10.0, -di)) break;
502  else density_thresh = pow(10.0, -2.0 * di);
503  }
504  return density_thresh;
505  }
506 
507  Function<T, NDIM> make_mask(const Function<T, NDIM>& samplef, const double& thresh) const {
508  vecfuncT sample_wrapper;
509  samplef.reconstruct();
510  sample_wrapper.push_back(samplef);
512  real_function_3d mask = multiop_values<double, density_mask_operator, 3>(op_tmp, sample_wrapper);
513  // The mask is constant on each box so make shure this will be the case (avoid flutuations)
514  real_function_3d const_mask = project(mask, 1);
515  mask = project(const_mask, FunctionDefaults<NDIM>::get_k());
516  make_plots(mask, "mask");
517  return mask;
518  }
519 
522  real_function_3d inv = unit - mask;
523  real_function_3d const_inv = project(inv, 1);
524  inv = project(const_inv, FunctionDefaults<NDIM>::get_k());
525  return inv;
526  }
527 
528  Function<T, NDIM> make_explog(const Function<T, NDIM>& f, const std::string& msg = "function") const {
529  // make logf
530  Function<T, NDIM> logf = copy(f);
531  logf.unaryop(make_log);
532 
533  // smooth logf
534  Function<T, NDIM> smoothed_logf = gaussian_smoothing(logf, 0.5);
535 
536  // reconstruct f via f=exp^(log(f));
537  Function<T, NDIM> explogf = copy(smoothed_logf);
538  explogf.unaryop(make_exp);
539 
540  // apply the box_mask to eliminate weird boundary effects
541  //explogf = box_mask_*explogf;
542 
543  // make some plots
544  make_plots(f, msg);
545  make_plots(smoothed_logf, "smoothed_log" + msg);
546  make_plots(logf, "log" + msg);
547  make_plots(explogf, "explog_" + msg);
548  return explogf;
549  }
550 
551  Function<T, NDIM> gaussian_smoothing(const Function<T, NDIM>& f, const double& eps = 0.04,
552  const std::string& name = "nooutput") const {
553  if (name != "noputput") output("\nSmoothing " + name + " with eps " + stringify(eps));
554  double exponent = 1.0 / (2.0 * eps);
555  Tensor<double> coeffs(1), exponents(1);
556  exponents(0L) = exponent;
557  coeffs(0L) = gauss_norm(exponent);
558  SeparatedConvolution<T, NDIM> op(world, coeffs, exponents);
559  Function<T, NDIM> smoothed_f = apply(op, f);
560  make_plots(smoothed_f, "smoothed_" + name);
561  return smoothed_f;
562 
563  }
564 
567  const std::string& name = "f") const {
569  Function<T, NDIM> part1 = mask * f;
570  Function<T, NDIM> part2 = inv_mask * sf;
571  Function<T, NDIM> result = part1 + part2;
572  make_plots(mask, "mask_" + name);
573  make_plots(inv_mask, "inv_mask_" + name);
574  make_plots(part1, "masked_" + name);
575  make_plots(part2, "masked_s" + name);
576  return result;
577  }
578 
580  merge_functions(const Function<T, NDIM>& f, const Function<T, NDIM>& sf, const double& thresh) const {
581  MADNESS_ASSERT(NDIM == 3);
582  vecfuncT wrapper;
583  wrapper.push_back(f);
584  wrapper.push_back(sf);
585  refine_to_common_level(world, wrapper);
586  merging_operator op_tmp(thresh);
587  real_function_3d merged_f = multiop_values<double, merging_operator, 3>(op_tmp, wrapper);
588  return merged_f;
589  }
590 
591  void make_plots(const Function<T, NDIM>& f, const std::string& name = "function") const {
592  double width = FunctionDefaults<3>::get_cell_min_width() / 2.0 - 1.e-3;
593  plot_plane(world, f, name);
594  coord_3d start(0.0);
595  start[0] = -width;
596  coord_3d end(0.0);
597  end[0] = width;
598  plot_line(("line_" + name).c_str(), 1000, start, end, f);
599  }
600 
601 
602  void test_1d() const {
607  Tensor<double> coeffs(1), exponents(1);
608  exponents(0L) = 1.0 / (2.0 * 0.04);
609  coeffs(0L) = pow((1.0 / (2.0 * 0.04)) / M_PI, 0.5);
610  SeparatedConvolution<double, 1> op(world, coeffs, exponents,1.e-5,1.e-5);
611  real_function_1d sf = apply(op, f);
612  double diff = (f - sf).norm2();
613  output("||f - smoothed_f||_1D=" + stringify(diff));
614  coord_1d start;
615  start[0] = -10.0;
616  coord_1d end;
617  end[0] = 10.0;
618  plot_line("smoothed_1d", 1000, start, end, sf);
619  plot_line("noise_1d", 1000, start, end, f);
620  }
621 
622  double gauss_norm(const double& exponent) const {
623  return pow(exponent / M_PI, 0.5 * 3.0);
624  }
625 
626  void output(const std::string& msg) const {
627  if (world.rank() == 0) std::cout << msg << std::endl;
628  }
629 
630 private:
635 };
636 
637 } // namespace madness
638 
639 
640 #endif /* SRC_EXAMPLES_SMOOTH_H_ */
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
Definition: smooth.h:331
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
Definition: smooth.h:185
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
Definition: smooth.h:98
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
Definition: smooth.h:118
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
Definition: smooth.h:171
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
Definition: smooth.h:262
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
Definition: smooth.h:286
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
Definition: smooth.h:73
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
Definition: smooth.h:246
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
Definition: smooth.h:135
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
Definition: smooth.h:365
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
Definition: smooth.h:341
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