source: src/Jobs/ChargeSmearer.hpp@ cceb8c

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since cceb8c was cceb8c, checked in by Frederik Heber <heber@…>, 9 years ago

Added ChargeSmearer that is only compiled for CONDVMG.

  • we store the spline values in a singleton such that they are calculated only once.
  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 * ChargeSmearer.hpp
3 *
4 * Created on: Sep 2, 2015
5 * Author: heber
6 */
7
8#ifndef CHARGESMEARER_HPP_
9#define CHARGESMEARER_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include "CodePatterns/Singleton.hpp"
17
18namespace VMG {
19 class Grid;
20 class GridIterator;
21
22 namespace Particle {
23 class BSpline;
24 }
25}
26
27/** This class smears out a given (peak-like) charge value by using a radial
28 * b-spline of compile-defined degree and runtime-defined width ("near field
29 * cells").
30 *
31 * This is used to smear out the electronic charge distribution in the same
32 * way as is done with the (point-like) nuclei charge distribution to increase
33 * accuracy for the long-range calculations.
34 *
35 * The trick relies on two distant and non-overlapping charge distributions
36 * behave actually as two point charges and vice versa. Core electron charge
37 * distributions are strongly peaked and hence almost appear like the point-like
38 * nuclei charge distributions. Hence, we perform the same trick as is done
39 * with the nuclei. The charges are smeared out to such a degree that charge
40 * distributions do not overlap except within a single fragment. Within
41 * fragments the short-range Coulomb energy and forces is calculated accurately.
42 * In between fragments the long-range calculations via vmg is used and hence
43 * charges there may not overlap. The maximum distance allowed and hence the
44 * maximum near field cells can be obtained from the Interfragmenter class.
45 *
46 * This class is a singleton as we only need to precalculate the spline values
47 * for a given nfc once and then may use of all FragmentJobs.
48 *
49 * The code here is taken from vmg's units/particles/bspline.cpp::SetSpline().
50 */
51class ChargeSmearer : public Singleton<ChargeSmearer>
52{
53 friend class Singleton<ChargeSmearer>;
54
55private:
56 /** Private cstor for ChargeSmearer.
57 *
58 * Must be private as is singleton.
59 *
60 */
61 ChargeSmearer();
62
63 /** Dstor for ChargeSmearer.
64 *
65 */
66 ~ChargeSmearer();
67
68public:
69 /** Setter for the values defining the grid and the spline extent.
70 *
71 * This function recalculates the spline values but only if the
72 * values have changed with respect to the old ones.
73 *
74 * \param _spl spline to evaluate
75 * \param _nfc near field cells
76 * \param _meshwdith mesh spacing
77 */
78 void initializeSplineArray(
79 const VMG::Particle::BSpline &_spl,
80 const unsigned int _nfc,
81 const double _meshwidth);
82
83 /** Getter for the width of the smearing area, i.e. number of near field
84 * cells.
85 *
86 * \return number of near field cells, i.e. 2nfc+1 equals width of array
87 */
88 unsigned int getNearFielCells() const
89 { return nfc; }
90
91 /** Getter for the meshwidth.
92 *
93 * \return meshwidth
94 */
95 unsigned int getMeshwidth() const
96 { return meshwidth; }
97
98 /** Smears out the given charge \a _value with the current \a nfc and bspline
99 * on the \a _grid.
100 *
101 * \param _grid grid to smear out charge on
102 * \param _iter central node on grid where to add smearing
103 * \param _charge charge to smear out
104 */
105 void operator()(
106 VMG::Grid& _grid,
107 const VMG::GridIterator &_iter,
108 const double _charge) const;
109
110private:
111 //!> near field radius for bspline
112 unsigned int nfc;
113
114 //!> mesh width of the grid
115 double meshwidth;
116
117 //!> contains the array of pre-compiled spline values
118 double *vals;
119
120 //!> integrated value of spline array for normalization
121 double int_val;
122};
123
124
125#endif /* CHARGESMEARER_HPP_ */
Note: See TracBrowser for help on using the repository browser.