DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
force.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (c) 2017-2025 The Regents of the University of Michigan and DFT-FE
4// authors.
5//
6// This file is part of the DFT-FE code.
7//
8// The DFT-FE code is free software; you can use it, redistribute
9// it, and/or modify it under the terms of the GNU Lesser General
10// Public License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12// The full text of the license can be found in the file LICENSE at
13// the top level of the DFT-FE distribution.
14//
15// ---------------------------------------------------------------------
16
17
18#ifndef force_H_
19#define force_H_
20#include "vselfBinsManager.h"
21#include "dftParameters.h"
22
23#include "constants.h"
24#include "headers.h"
26#include <dftd.h>
27#include <oncvClass.h>
29
30
31namespace dftfe
32{
33 // forward declaration
34 template <unsigned int T1, unsigned int T2, dftfe::utils::MemorySpace memory>
35 class dftClass;
36
37 /**
38 * @brief computes configurational forces in KSDFT
39 *
40 * This class computes and stores the configurational forces corresponding to
41 * geometry optimization. It uses the formulation in the paper by Motamarri
42 * et.al. (https://link.aps.org/doi/10.1103/PhysRevB.97.165132) which provides
43 * an unified approach to atomic forces corresponding to internal atomic
44 * relaxation and cell stress corresponding to cell relaxation.
45 *
46 * @author Sambit Das
47 */
48 template <unsigned int FEOrder,
49 unsigned int FEOrderElectro,
50 dftfe::utils::MemorySpace memorySpace>
52 {
53 friend class dftClass<FEOrder, FEOrderElectro, memorySpace>;
54
55 public:
56 /** @brief Constructor.
57 *
58 * @param _dftPtr pointer to dftClass
59 * @param mpi_comm_parent parent mpi_communicator
60 * @param mpi_comm_domain domain decomposition mpi_communicator
61 */
63 const MPI_Comm & mpi_comm_parent,
64 const MPI_Comm & mpi_comm_domain,
65 const dftParameters & dftParams);
66
67 /** @brief initializes data structures inside forceClass assuming unmoved triangulation.
68 *
69 * initUnmoved is the first step of the initialization/reinitialization of
70 * force class when starting from a new unmoved triangulation. It creates
71 * the dofHandler with linear finite elements and three components
72 * corresponding to the three force components. It also creates the
73 * corresponding constraint matrices which is why an unmoved triangulation
74 * is necessary. Finally this function also initializes the gaussianMovePar
75 * data member.
76 *
77 * @param triangulation reference to unmoved triangulation where the mesh nodes have not
78 * been manually moved.
79 * @param isElectrostaticsMesh boolean parameter specifying whether this triangulatio is to be used for
80 * for the electrostatics part of the configurational force.
81 * @return void.
82 */
83 void
84 initUnmoved(const dealii::Triangulation<3, 3> & triangulation,
85 const dealii::Triangulation<3, 3> & serialTriangulation,
86 const std::vector<std::vector<double>> &domainBoundingVectors,
87 const bool isElectrostaticsMesh);
88
89 /** @brief initializes data structures inside forceClass which depend on the moved mesh.
90 *
91 * initMoved is the second step (first step call initUnmoved) of the
92 * initialization/reinitialization of force class when starting from a new
93 * mesh, and the first step when recomputing forces on a perturbed mesh.
94 * initMoved assumes that the triangulation whose reference was passed to
95 * the forceClass object in the initUnmoved call now has its nodes moved
96 * such that all atomic positions lie on nodes.
97 *
98 * @return void.
99 */
100 void
102 std::vector<const dealii::DoFHandler<3> *> &dofHandlerVectorMatrixFree,
103 std::vector<const dealii::AffineConstraints<double> *>
104 & constraintsVectorMatrixFree,
105 const bool isElectrostaticsMesh);
106
107 /** @brief initializes and precomputes pseudopotential related data structuers required for configurational force
108 * and stress computation.
109 *
110 * This function is only activated for pseudopotential calculations and is
111 * currently called when initializing/reinitializing the dftClass object.
112 * This function initializes and precomputes the pseudopotential
113 * datastructures for local and non-local parts. Separate internal function
114 * calls are made for KB and ONCV projectors.
115 *
116 * @return void.
117 */
118 void
120
121 /** @brief computes the configurational force on all atoms corresponding to a Gaussian generator,
122 * which represents perturbation of the underlying space.
123 *
124 * The Gaussian generator is taken to be exp(-d_gaussianConstant*r^2), r
125 * being the distance from the atom. Currently d_gaussianConstant is
126 * hardcoded to be 4.0. To get the computed atomic forces use getAtomsForces
127 *
128 * @return void.
129 */
130 void
132 const dealii::MatrixFree<3, double> &matrixFreeData,
133 const dispersionCorrection & dispersionCorr,
134 const unsigned int eigenDofHandlerIndex,
135 const unsigned int smearedChargeQuadratureId,
136 const unsigned int lpspQuadratureIdElectro,
137 const dealii::MatrixFree<3, double> &matrixFreeDataElectro,
138 const unsigned int phiTotDofHandlerIndexElectro,
139 const distributedCPUVec<double> & phiTotRhoOutElectro,
140 const std::vector<
142 &rhoOutValues,
143 const std::vector<
145 &gradRhoOutValues,
147 &rhoTotalOutValuesLpsp,
149 &gradRhoTotalOutValuesLpsp,
150 const std::map<dealii::CellId, std::vector<double>> &rhoCoreValues,
151 const std::map<dealii::CellId, std::vector<double>> &gradRhoCoreValues,
152 const std::map<dealii::CellId, std::vector<double>> &hessianRhoCoreValues,
153 const std::map<unsigned int,
154 std::map<dealii::CellId, std::vector<double>>>
155 &gradRhoCoreAtoms,
156 const std::map<unsigned int,
157 std::map<dealii::CellId, std::vector<double>>>
158 & hessianRhoCoreAtoms,
159 const std::map<dealii::CellId, std::vector<double>> &pseudoVLocElectro,
160 const std::map<unsigned int,
161 std::map<dealii::CellId, std::vector<double>>>
162 & pseudoVLocAtomsElectro,
163 const dealii::AffineConstraints<double> &hangingPlusPBCConstraintsElectro,
164 const vselfBinsManager<FEOrder, FEOrderElectro> &vselfBinsManagerElectro);
165
166 /** @brief returns a copy of the configurational force on all global atoms.
167 *
168 * computeAtomsForces must be called prior to this function call.
169 *
170 * @return std::vector<double> flattened array of the configurational force on all atoms,
171 * the three force components on each atom being the leading dimension.
172 * Units- Hartree/Bohr
173 */
174 std::vector<double> &
176
177 /** @brief prints the currently stored configurational forces on atoms and the Gaussian generator constant
178 * used to compute them.
179 *
180 * @return void.
181 */
182 void
184
185 /** @brief Update force generator Gaussian constant.
186 *
187 * @return void.
188 */
189 // void updateGaussianConstant(const double newGaussianConstant);
190
191 /** @brief computes the configurational stress on the domain corresponding to
192 * affine deformation of the periodic cell.
193 *
194 * This function cannot be called for fully non-periodic calculations.
195 *
196 * @return void.
197 */
198 void
200 const dealii::MatrixFree<3, double> &matrixFreeData,
201 const dispersionCorrection & dispersionCorr,
202 const unsigned int eigenDofHandlerIndex,
203 const unsigned int smearedChargeQuadratureId,
204 const unsigned int lpspQuadratureIdElectro,
205 const dealii::MatrixFree<3, double> &matrixFreeDataElectro,
206 const unsigned int phiTotDofHandlerIndexElectro,
207 const distributedCPUVec<double> & phiTotRhoOutElectro,
208 const std::vector<
210 &rhoOutValues,
211 const std::vector<
213 &gradRhoOutValues,
215 &rhoTotalOutValuesLpsp,
217 &gradRhoTotalOutValuesLpsp,
218 const std::map<dealii::CellId, std::vector<double>> &pseudoVLocElectro,
219 const std::map<unsigned int,
220 std::map<dealii::CellId, std::vector<double>>>
221 &pseudoVLocAtomsElectro,
222 const std::map<dealii::CellId, std::vector<double>> &rhoCoreValues,
223 const std::map<dealii::CellId, std::vector<double>> &gradRhoCoreValues,
224 const std::map<dealii::CellId, std::vector<double>> &hessianRhoCoreValues,
225 const std::map<unsigned int,
226 std::map<dealii::CellId, std::vector<double>>>
227 &gradRhoCoreAtoms,
228 const std::map<unsigned int,
229 std::map<dealii::CellId, std::vector<double>>>
230 & hessianRhoCoreAtoms,
231 const dealii::AffineConstraints<double> &hangingPlusPBCConstraintsElectro,
232 const vselfBinsManager<FEOrder, FEOrderElectro> &vselfBinsManagerElectro);
233
234 /** @brief prints the currently stored configurational stress tensor.
235 *
236 * @return void.
237 */
238 void
240
241 /** @brief returns a copy of the current stress tensor value.
242 *
243 * computeStress must be call prior to this function call.
244 *
245 * @return dealii::Tensor<2,3,double> second order stress Tensor in Hartree/Bohr^3
246 */
247 dealii::Tensor<2, 3, double> &
249
250 /** @brief get the value of Gaussian generator parameter (d_gaussianConstant).
251 * Gaussian generator: Gamma(r)= exp(-d_gaussianConstant*r^2).
252 *
253 */
254 // double getGaussianGeneratorParameter() const;
255
256 private:
257 /** @brief Locates and stores the global dof indices of d_dofHandlerForce whose cooridinates match
258 * with the atomic positions.
259 *
260 * @return void.
261 */
262 void
263 locateAtomCoreNodesForce(const dealii::DoFHandler<3> &dofHandlerForce,
264 const dealii::IndexSet &locally_owned_dofsForce,
265 std::map<std::pair<unsigned int, unsigned int>,
266 unsigned int> &atomsForceDofs);
267
268 void
270 const dealii::DoFHandler<3> & dofHandler,
271 const dealii::DoFHandler<3> & dofHandlerForce,
272 const dealii::AffineConstraints<double> &hangingPlusPBCConstraints,
274 std::vector<std::vector<dealii::DoFHandler<3>::active_cell_iterator>>
275 &cellsVselfBallsDofHandler,
276 std::vector<std::vector<dealii::DoFHandler<3>::active_cell_iterator>>
277 &cellsVselfBallsDofHandlerForce,
278 std::vector<std::map<dealii::CellId, unsigned int>>
279 &cellsVselfBallsClosestAtomIdDofHandler,
280 std::map<unsigned int, unsigned int> &AtomIdBinIdLocalDofHandler,
281 std::vector<std::map<dealii::DoFHandler<3>::active_cell_iterator,
282 std::vector<unsigned int>>>
283 &cellFacesVselfBallSurfacesDofHandler,
284 std::vector<std::map<dealii::DoFHandler<3>::active_cell_iterator,
285 std::vector<unsigned int>>>
286 &cellFacesVselfBallSurfacesDofHandlerForce);
287
288 void
290 const dealii::MatrixFree<3, double> &matrixFreeData,
291 const dealii::MatrixFree<3, double> &matrixFreeDataElectro);
292
293 void
295
296 void
298 const dealii::MatrixFree<3, double> &matrixFreeData,
299 const unsigned int eigenDofHandlerIndex,
300 const unsigned int smearedChargeQuadratureId,
301 const unsigned int lpspQuadratureIdElectro,
302 const dealii::MatrixFree<3, double> &matrixFreeDataElectro,
303 const unsigned int phiTotDofHandlerIndexElectro,
304 const distributedCPUVec<double> & phiTotRhoOutElectro,
305 const std::vector<
307 &rhoOutValues,
308 const std::vector<
310 &gradRhoOutValues,
312 &rhoTotalOutValuesLpsp,
314 &gradRhoTotalOutValuesLpsp,
315 const std::map<dealii::CellId, std::vector<double>> &rhoCoreValues,
316 const std::map<dealii::CellId, std::vector<double>> &gradRhoCoreValues,
317 const std::map<dealii::CellId, std::vector<double>> &hessianRhoCoreValues,
318 const std::map<unsigned int,
319 std::map<dealii::CellId, std::vector<double>>>
320 &gradRhoCoreAtoms,
321 const std::map<unsigned int,
322 std::map<dealii::CellId, std::vector<double>>>
323 & hessianRhoCoreAtoms,
324 const std::map<dealii::CellId, std::vector<double>> &pseudoVLocElectro,
325 const std::map<unsigned int,
326 std::map<dealii::CellId, std::vector<double>>>
327 & pseudoVLocAtomsElectro,
328 const vselfBinsManager<FEOrder, FEOrderElectro> &vselfBinsManagerElectro);
329
330 void
332 const dealii::MatrixFree<3, double> &matrixFreeDataElectro,
333 const unsigned int phiTotDofHandlerIndexElectro,
334 const unsigned int smearedChargeQuadratureId,
335 const unsigned int lpspQuadratureIdElectro,
336 const distributedCPUVec<double> & phiTotRhoOutElectro,
338 &rhoTotalOutValues,
340 &rhoTotalOutValuesLpsp,
342 &gradRhoTotalOutValues,
344 &gradRhoTotalOutValuesLpsp,
345 const std::map<dealii::CellId, std::vector<double>> &pseudoVLocElectro,
346 const std::map<unsigned int,
347 std::map<dealii::CellId, std::vector<double>>>
348 & pseudoVLocAtomsElectro,
349 const vselfBinsManager<FEOrder, FEOrderElectro> &vselfBinsManagerElectro);
350
351 void
353
354 void
356 const dealii::DoFHandler<3> & dofHandlerElectro,
357 const vselfBinsManager<FEOrder, FEOrderElectro> &vselfBinsManagerElectro,
358 const dealii::MatrixFree<3, double> & matrixFreeDataElectro,
359 const unsigned int smearedChargeQuadratureId);
360
361 void
363
364 void
366 const dealii::MatrixFree<3, double> &matrixFreeData,
367 const unsigned int eigenDofHandlerIndex,
368 const unsigned int smearedChargeQuadratureId,
369 const unsigned int lpspQuadratureIdElectro,
370 const dealii::MatrixFree<3, double> &matrixFreeDataElectro,
371 const unsigned int phiTotDofHandlerIndexElectro,
372 const distributedCPUVec<double> & phiTotRhoOutElectro,
373 const std::vector<
375 &rhoOutValues,
376 const std::vector<
378 &gradRhoOutValues,
380 &rhoTotalOutValuesLpsp,
382 &gradRhoTotalOutValuesLpsp,
383 const std::map<dealii::CellId, std::vector<double>> &rhoCoreValues,
384 const std::map<dealii::CellId, std::vector<double>> &gradRhoCoreValues,
385 const std::map<dealii::CellId, std::vector<double>> &hessianRhoCoreValues,
386 const std::map<unsigned int,
387 std::map<dealii::CellId, std::vector<double>>>
388 &gradRhoCoreAtoms,
389 const std::map<unsigned int,
390 std::map<dealii::CellId, std::vector<double>>>
391 & hessianRhoCoreAtoms,
392 const std::map<dealii::CellId, std::vector<double>> &pseudoVLocElectro,
393 const std::map<unsigned int,
394 std::map<dealii::CellId, std::vector<double>>>
395 & pseudoVLocAtomsElectro,
396 const vselfBinsManager<FEOrder, FEOrderElectro> &vselfBinsManagerElectro);
397
398 void
400 std::map<unsigned int, std::vector<double>>
401 & forceContributionFPSPLocalGammaAtoms,
402 dealii::FEValues<3> & feValues,
403 dealii::FEFaceValues<3> & feFaceValues,
404 dealii::FEEvaluation<3,
405 1,
407 3> & forceEval,
408 const dealii::MatrixFree<3, double> &matrixFreeData,
409 const unsigned int phiTotDofHandlerIndexElectro,
410 const unsigned int cell,
411 const dealii::AlignedVector<dealii::VectorizedArray<double>> &rhoQuads,
412 const dealii::AlignedVector<
413 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>> &gradRhoQuads,
414 const std::map<unsigned int,
415 std::map<dealii::CellId, std::vector<double>>>
416 & pseudoVLocAtoms,
418 const std::vector<std::map<dealii::CellId, unsigned int>>
419 &cellsVselfBallsClosestAtomIdDofHandler);
420
421 void
423 std::map<unsigned int, std::vector<double>>
424 &forceContributionSmearedChargesGammaAtoms,
425 dealii::FEEvaluation<3, -1, 1, 3> & forceEval,
426 const dealii::MatrixFree<3, double> &matrixFreeData,
427 const unsigned int cell,
428 const dealii::AlignedVector<
429 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>> &gradPhiTotQuads,
430 const std::vector<unsigned int> &nonTrivialAtomIdsMacroCell,
431 const std::map<dealii::CellId, std::vector<int>> &bQuadAtomIdsAllAtoms,
432 const dealii::AlignedVector<dealii::VectorizedArray<double>>
433 &smearedbQuads);
434
435 void
437 std::map<unsigned int, std::vector<double>>
438 &forceContributionSmearedChargesGammaAtoms,
439 dealii::FEEvaluation<3, -1, 1, 3> & forceEval,
440 const dealii::MatrixFree<3, double> &matrixFreeData,
441 const unsigned int cell,
442 const dealii::AlignedVector<
443 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>>
444 & gradVselfBinQuads,
445 const std::vector<unsigned int> &nonTrivialAtomIdsMacroCell,
446 const std::map<dealii::CellId, std::vector<int>> &bQuadAtomIdsAllAtoms,
447 const dealii::AlignedVector<dealii::VectorizedArray<double>>
448 &smearedbQuads);
449
450 void
452 std::map<unsigned int, std::vector<double>>
453 &forceContributionFNonlinearCoreCorrectionGammaAtoms,
454 dealii::FEEvaluation<
455 3,
456 1,
458 3> & forceEval,
459 const dealii::MatrixFree<3, double> &matrixFreeData,
460 const unsigned int cell,
461 const dealii::AlignedVector<dealii::VectorizedArray<double>> &vxcQuads,
462 const std::map<unsigned int,
463 std::map<dealii::CellId, std::vector<double>>>
464 &gradRhoCoreAtoms);
465
466
467 void
469 std::map<unsigned int, std::vector<double>>
470 &forceContributionFNonlinearCoreCorrectionGammaAtoms,
471 dealii::FEEvaluation<
472 3,
473 1,
475 3> & forceEval,
476 const dealii::MatrixFree<3, double> &matrixFreeData,
477 const unsigned int cell,
478 const dealii::AlignedVector<
479 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>> &derExcGradRho,
480 const std::map<unsigned int,
481 std::map<dealii::CellId, std::vector<double>>>
482 &hessianRhoCoreAtoms);
483
484 void
486 std::map<unsigned int, std::vector<double>>
487 &forceContributionFNonlinearCoreCorrectionGammaAtoms,
488 dealii::FEEvaluation<
489 3,
490 1,
492 3> & forceEval,
493 const dealii::MatrixFree<3, double> &matrixFreeData,
494 const unsigned int cell,
495 const dealii::AlignedVector<dealii::VectorizedArray<double>>
496 &vxcQuadsSpin0,
497 const dealii::AlignedVector<dealii::VectorizedArray<double>>
498 &vxcQuadsSpin1,
499 const dealii::AlignedVector<
500 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>>
501 &derExcGradRhoSpin0,
502 const dealii::AlignedVector<
503 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>>
504 &derExcGradRhoSpin1,
505 const std::map<unsigned int,
506 std::map<dealii::CellId, std::vector<double>>>
507 &gradRhoCoreAtoms,
508 const std::map<unsigned int,
509 std::map<dealii::CellId, std::vector<double>>>
510 & hessianRhoCoreAtoms,
511 const bool isXCGGA = false);
512
513 void
515 const std::map<unsigned int, std::vector<double>>
516 &forceContributionFPSPLocalGammaAtoms,
517 const std::map<std::pair<unsigned int, unsigned int>, unsigned int>
518 & atomsForceDofs,
519 const dealii::AffineConstraints<double> &constraintsNoneForce,
520 distributedCPUVec<double> & configForceVectorLinFE);
521
522 void
524 const std::map<unsigned int, std::vector<double>>
525 & forceContributionLocalGammaAtoms,
526 std::vector<double> &accumForcesVector);
527
528
529 void
531 std::map<unsigned int, std::vector<double>>
532 & forceContributionFnlGammaAtoms,
533 const dealii::MatrixFree<3, double> &matrixFreeData,
534 dealii::FEEvaluation<3,
535 1,
538 3> & forceEvalNLP,
539 const std::shared_ptr<
541 nonLocalOp,
542 unsigned int numNonLocalAtomsCurrentProcess,
543 const std::vector<int> & globalChargeIdNonLocalAtoms,
544 const std::vector<unsigned int> &numberPseudoWaveFunctionsPerAtom,
545 const unsigned int cell,
546 const std::map<dealii::CellId, unsigned int> &cellIdToCellNumberMap,
547#ifdef USE_COMPLEX
548 const std::vector<dataTypes::number>
549 &projectorKetTimesPsiTimesVTimesPartOccContractionPsiQuadsFlattened,
550#endif
551 const std::vector<dataTypes::number> &zetaDeltaVQuadsFlattened,
552 const std::vector<dataTypes::number> &
553 projectorKetTimesPsiTimesVTimesPartOccContractionGradPsiQuadsFlattened);
554
555
557 dealii::AlignedVector<
558 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>> &FVectQuads,
559 const dealii::MatrixFree<3, double> & matrixFreeData,
560 const unsigned int numQuadPoints,
561 const std::shared_ptr<
563 nonLocalOp,
564 const unsigned int numNonLocalAtomsCurrentProcess,
565 const std::vector<int> & globalChargeIdNonLocalAtoms,
566 const std::vector<unsigned int> &numberPseudoWaveFunctionsPerAtom,
567 const unsigned int cell,
568 const std::map<dealii::CellId, unsigned int> &cellIdToCellNumberMap,
569 const std::vector<dataTypes::number> & zetaDeltaVQuadsFlattened,
570 const std::vector<dataTypes::number> &
571 projectorKetTimesPsiTimesVTimesPartOccContractionGradPsiQuadsFlattened);
572
573 void
575 const std::map<unsigned int, std::vector<double>>
576 &forceContributionFnlGammaAtoms);
577
579 dealii::Tensor<2, 3, double> & stressContribution,
580 const dealii::MatrixFree<3, double> &matrixFreeData,
581 const unsigned int numQuadPoints,
582 const std::vector<double> & jxwQuadsSubCells,
583 const unsigned int cell,
584 const unsigned int numNonLocalAtomsCurrentProcess,
585 const std::shared_ptr<
587 nonLocalOp,
588 const std::vector<unsigned int> &numberPseudoWaveFunctionsPerAtom,
589 const std::map<dealii::CellId, unsigned int> &cellIdToCellNumberMap,
590 const std::vector<dataTypes::number> &zetalmDeltaVlProductDistImageAtoms,
591#ifdef USE_COMPLEX
592 const std::vector<dataTypes::number>
593 &projectorKetTimesPsiTimesVTimesPartOccContractionPsiQuadsFlattened,
594#endif
595 const std::vector<dataTypes::number>
596 &projectorKetTimesPsiTimesVTimesPartOccContractionGradPsiQuadsFlattened,
597 const bool isSpinPolarized);
598
599 void
601 bool allowGaussianOverlapOnAtoms = false);
602
603 void
605
606 void
608 const dealii::DoFHandler<3> & dofHandlerElectro,
609 const vselfBinsManager<FEOrder, FEOrderElectro> &vselfBinsManagerElectro,
610 const dealii::MatrixFree<3, double> & matrixFreeDataElectro,
611 const unsigned int smearedChargeQuadratureId);
612
613 void
615 const dealii::MatrixFree<3, double> &matrixFreeData,
616 const unsigned int eigenDofHandlerIndex,
617 const unsigned int smearedChargeQuadratureId,
618 const unsigned int lpspQuadratureIdElectro,
619 const dealii::MatrixFree<3, double> &matrixFreeDataElectro,
620 const unsigned int phiTotDofHandlerIndexElectro,
621 const distributedCPUVec<double> & phiTotRhoOutElectro,
622 const std::vector<
624 &rhoOutValues,
625 const std::vector<
627 &gradRhoOutValues,
629 &rhoTotalOutValuesLpsp,
631 &gradRhoTotalOutValuesLpsp,
632 const std::map<dealii::CellId, std::vector<double>> &pseudoVLocElectro,
633 const std::map<unsigned int,
634 std::map<dealii::CellId, std::vector<double>>>
635 &pseudoVLocAtomsElectro,
636 const std::map<dealii::CellId, std::vector<double>> &rhoCoreValues,
637 const std::map<dealii::CellId, std::vector<double>> &gradRhoCoreValues,
638 const std::map<dealii::CellId, std::vector<double>> &hessianRhoCoreValues,
639 const std::map<unsigned int,
640 std::map<dealii::CellId, std::vector<double>>>
641 &gradRhoCoreAtoms,
642 const std::map<unsigned int,
643 std::map<dealii::CellId, std::vector<double>>>
644 & hessianRhoCoreAtoms,
645 const vselfBinsManager<FEOrder, FEOrderElectro> &vselfBinsManagerElectro);
646
647 void
649 const dealii::MatrixFree<3, double> &matrixFreeDataElectro,
650 const unsigned int phiTotDofHandlerIndexElectro,
651 const unsigned int smearedChargeQuadratureId,
652 const unsigned int lpspQuadratureIdElectro,
653 const distributedCPUVec<double> & phiTotRhoOutElectro,
655 &rhoTotalOutValues,
657 &rhoTotalOutValuesLpsp,
659 &gradRhoTotalOutValuesElectro,
661 &gradRhoTotalOutValuesElectroLpsp,
662 const std::map<dealii::CellId, std::vector<double>> &pseudoVLocElectro,
663 const std::map<unsigned int,
664 std::map<dealii::CellId, std::vector<double>>>
665 & pseudoVLocAtomsElectro,
666 const vselfBinsManager<FEOrder, FEOrderElectro> &vselfBinsManagerElectro);
667
669 dealii::FEValues<3> & feValues,
670 dealii::FEFaceValues<3> & feFaceValues,
671 dealii::FEEvaluation<3,
672 1,
674 3> & forceEval,
675 const dealii::MatrixFree<3, double> &matrixFreeData,
676 const unsigned int phiTotDofHandlerIndexElectro,
677 const unsigned int cell,
678 const dealii::AlignedVector<dealii::VectorizedArray<double>> &rhoQuads,
679 const dealii::AlignedVector<
680 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>> &gradRhoQuads,
681 const std::map<unsigned int,
682 std::map<dealii::CellId, std::vector<double>>>
683 & pseudoVLocAtoms,
685 const std::vector<std::map<dealii::CellId, unsigned int>>
686 &cellsVselfBallsClosestAtomIdDofHandler);
687
689 dealii::FEEvaluation<
690 3,
691 1,
693 3> & forceEval,
694 const dealii::MatrixFree<3, double> &matrixFreeData,
695 const unsigned int cell,
696 const dealii::AlignedVector<dealii::VectorizedArray<double>> &vxcQuads,
697 const dealii::AlignedVector<
698 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>> &derExcGradRho,
699 const std::map<unsigned int,
700 std::map<dealii::CellId, std::vector<double>>>
701 &gradRhoCoreAtoms,
702 const std::map<unsigned int,
703 std::map<dealii::CellId, std::vector<double>>>
704 &hessianRhoCoreAtoms);
705
707 dealii::FEEvaluation<
708 3,
709 1,
711 3> & forceEval,
712 const dealii::MatrixFree<3, double> &matrixFreeData,
713 const unsigned int cell,
714 const dealii::AlignedVector<dealii::VectorizedArray<double>>
715 &vxcQuadsSpin0,
716 const dealii::AlignedVector<dealii::VectorizedArray<double>>
717 &vxcQuadsSpin1,
718 const dealii::AlignedVector<
719 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>>
720 &derExcGradRhoSpin0,
721 const dealii::AlignedVector<
722 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>>
723 &derExcGradRhoSpin1,
724 const std::map<unsigned int,
725 std::map<dealii::CellId, std::vector<double>>>
726 &gradRhoCoreAtoms,
727 const std::map<unsigned int,
728 std::map<dealii::CellId, std::vector<double>>>
729 & hessianRhoCoreAtoms,
730 const bool isXCGGA = false);
731
733 dealii::FEEvaluation<3, -1, 1, 3> & forceEval,
734 const dealii::MatrixFree<3, double> &matrixFreeData,
735 const unsigned int cell,
736 const dealii::AlignedVector<
737 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>> &gradPhiTotQuads,
738 const std::vector<unsigned int> &nonTrivialAtomImageIdsMacroCell,
739 const std::map<dealii::CellId, std::vector<int>>
740 &bQuadAtomIdsAllAtomsImages,
741 const dealii::AlignedVector<dealii::VectorizedArray<double>>
742 &smearedbQuads);
743
745 dealii::FEEvaluation<3, -1, 1, 3> & forceEval,
746 const dealii::MatrixFree<3, double> &matrixFreeData,
747 const unsigned int cell,
748 const dealii::AlignedVector<
749 dealii::Tensor<1, 3, dealii::VectorizedArray<double>>> &gradVselfQuads,
750 const std::vector<unsigned int> &nonTrivialAtomImageIdsMacroCell,
751 const std::map<dealii::CellId, std::vector<int>>
752 &bQuadAtomIdsAllAtomsImages,
753 const dealii::AlignedVector<dealii::VectorizedArray<double>>
754 &smearedbQuads);
755
756 void
758
759
760 /// Parallel distributed vector field which stores the configurational force
761 /// for each fem node corresponding to linear shape function generator (see
762 /// equations 52-53 in
763 /// (https://link.aps.org/doi/10.1103/PhysRevB.97.165132)). This vector
764 /// doesn't contain contribution from terms which have sums over k points.
766
767 /// Parallel distributed vector field which stores the configurational force
768 /// for each fem node corresponding to linear shape function generator (see
769 /// equations 52-53 in
770 /// (https://link.aps.org/doi/10.1103/PhysRevB.97.165132)). This vector only
771 /// containts contribution from the electrostatic part.
773
774#ifdef USE_COMPLEX
775 /// Parallel distributed vector field which stores the configurational force
776 /// for each fem node corresponding to linear shape function generator (see
777 /// equations 52-53 in
778 /// (https://link.aps.org/doi/10.1103/PhysRevB.97.165132)). This vector only
779 /// contains contribution from terms which have sums over k points.
780 distributedCPUVec<double> d_configForceVectorLinFEKPoints;
781#endif
782
783
784 std::vector<double> d_forceAtomsFloating;
785
786#ifdef USE_COMPLEX
787 std::vector<double> d_forceAtomsFloatingKPoints;
788#endif
789
790
791
792 /// Gaussian generator constant. Gaussian generator: Gamma(r)=
793 /// exp(-d_gaussianConstant*r^2)
794 /// FIXME: Until the hanging nodes surface integral issue is fixed use a
795 /// value >=4.0
796 // double d_gaussianConstant;
797
798 /// Storage for configurational force on all global atoms.
799 std::vector<double> d_globalAtomsForces;
800
801 /// Storage for configurational stress tensor
802 dealii::Tensor<2, 3, double> d_stress;
803
804
805
806 /* Part of the stress tensor which is summed over k points.
807 * It is a temporary data structure required for stress evaluation
808 * (d_stress) when parallization over k points is on.
809 */
810 dealii::Tensor<2, 3, double> d_stressKPoints;
811
812 /* Dont use true except for debugging forces only without mesh movement, as
813 * gaussian ovelap on atoms for move mesh is by default set to false
814 */
816
817 /// pointer to dft class
819
820 /// Finite element object for configurational force computation. Linear
821 /// finite elements with three force field components are used.
822 dealii::FESystem<3> FEForce;
823
824 /* DofHandler on which we define the configurational force field. Each
825 * geometric fem node has three dofs corresponding the the three force
826 * components. The generator for the configurational force on the fem node
827 * is the linear shape function attached to it. This DofHandler is based on
828 * the same triangulation on which we solve the dft problem.
829 */
830 dealii::DoFHandler<3> d_dofHandlerForce;
831
832 /* DofHandler on which we define the configurational force field from
833 * electrostatic part (without psp). Each geometric fem node has three dofs
834 * corresponding the the three force components. The generator for the
835 * configurational force on the fem node is the linear shape function
836 * attached to it. This DofHandler is based on the same triangulation on
837 * which we solve the dft problem.
838 */
839 dealii::DoFHandler<3> d_dofHandlerForceElectro;
840
841 /// Index of the d_dofHandlerForce in the MatrixFree object stored in
842 /// dftClass. This is required to correctly use FEEvaluation class.
844
845 /// Index of the d_dofHandlerForceElectro in the MatrixFree object stored in
846 /// dftClass. This is required to correctly use FEEvaluation class.
848
849 /// dealii::IndexSet of locally owned dofs of in d_dofHandlerForce the
850 /// current processor
852
853 /// dealii::IndexSet of locally owned dofs of in d_dofHandlerForceElectro
854 /// the current processor
856
857 /// dealii::IndexSet of locally relevant dofs of in d_dofHandlerForce the
858 /// current processor
860
861 /// dealii::IndexSet of locally relevant dofs of in d_dofHandlerForceElectro
862 /// the current processor
864
865 /// Constraint matrix for hanging node and periodic constaints on
866 /// d_dofHandlerForce.
867 dealii::AffineConstraints<double> d_constraintsNoneForce;
868
869 /// Constraint matrix for hanging node and periodic constaints on
870 /// d_dofHandlerForceElectro.
871 dealii::AffineConstraints<double> d_constraintsNoneForceElectro;
872
873 /// Internal data: map < <atomId,force component>, globaldof in
874 /// d_dofHandlerForce>
875 std::map<std::pair<unsigned int, unsigned int>, unsigned int>
877
878 /// Internal data: map < <atomId,force component>, globaldof in
879 /// d_dofHandlerForceElectro>
880 std::map<std::pair<unsigned int, unsigned int>, unsigned int>
882
883 /// Internal data: stores cell iterators of all cells in
884 /// dftPtr->d_dofHandler which are part of the vself ball. Outer vector is
885 /// over vself bins.
886 std::vector<std::vector<dealii::DoFHandler<3>::active_cell_iterator>>
888
889 /// Internal data: stores cell iterators of all cells in d_dofHandlerForce
890 /// which are part of the vself ball. Outer vector is over vself bins.
891 std::vector<std::vector<dealii::DoFHandler<3>::active_cell_iterator>>
893
894 /// Internal data: stores map of vself ball cell Id to the closest atom Id
895 /// of that cell. Outer vector over vself bins.
896 std::vector<std::map<dealii::CellId, unsigned int>>
898
899 /// Internal data: stores the map of atom Id (only in the local processor)
900 /// to the vself bin Id.
901 std::map<unsigned int, unsigned int> d_AtomIdBinIdLocalDofHandler;
902
903 /* Internal data: stores the face ids of dftPtr->d_dofHandler (single
904 * component field) on which to evaluate the vself ball surface integral in
905 * the configurational force expression. Outer vector is over the vself
906 * bins. Inner map is between the cell iterator and the vector of face ids
907 * to integrate on for that cell iterator.
908 */
909 std::vector<std::map<dealii::DoFHandler<3>::active_cell_iterator,
910 std::vector<unsigned int>>>
912
913 /* Internal data: stores the face ids of d_dofHandlerForce (three component
914 * field) on which to evaluate the vself ball surface integral in the
915 * configurational force expression. Outer vector is over the vself bins.
916 * Inner map is between the cell iterator and the vector of face ids to
917 * integrate on for that cell iterator.
918 */
919 std::vector<std::map<dealii::DoFHandler<3>::active_cell_iterator,
920 std::vector<unsigned int>>>
922
923 /// Internal data: stores cell iterators of all cells in
924 /// dftPtr->d_dofHandler which are part of the vself ball. Outer vector is
925 /// over vself bins.
926 std::vector<std::vector<dealii::DoFHandler<3>::active_cell_iterator>>
928
929 /// Internal data: stores cell iterators of all cells in d_dofHandlerForce
930 /// which are part of the vself ball. Outer vector is over vself bins.
931 std::vector<std::vector<dealii::DoFHandler<3>::active_cell_iterator>>
933
934 /// Internal data: stores map of vself ball cell Id to the closest atom Id
935 /// of that cell. Outer vector over vself bins.
936 std::vector<std::map<dealii::CellId, unsigned int>>
938
939 /// Internal data: stores the map of atom Id (only in the local processor)
940 /// to the vself bin Id.
941 std::map<unsigned int, unsigned int> d_AtomIdBinIdLocalDofHandlerElectro;
942
943 /* Internal data: stores the face ids of dftPtr->d_dofHandler (single
944 * component field) on which to evaluate the vself ball surface integral in
945 * the configurational force expression. Outer vector is over the vself
946 * bins. Inner map is between the cell iterator and the vector of face ids
947 * to integrate on for that cell iterator.
948 */
949 std::vector<std::map<dealii::DoFHandler<3>::active_cell_iterator,
950 std::vector<unsigned int>>>
952
953 /* Internal data: stores the face ids of d_dofHandlerForce (three component
954 * field) on which to evaluate the vself ball surface integral in the
955 * configurational force expression. Outer vector is over the vself bins.
956 * Inner map is between the cell iterator and the vector of face ids to
957 * integrate on for that cell iterator.
958 */
959 std::vector<std::map<dealii::DoFHandler<3>::active_cell_iterator,
960 std::vector<unsigned int>>>
962
963 std::map<dealii::CellId, dealii::DoFHandler<3>::active_cell_iterator>
965
966 std::vector<distributedCPUVec<double>> d_gaussianWeightsVecAtoms;
967
968
969
970 /// domain decomposition mpi_communicator
971 const MPI_Comm d_mpiCommParent;
972
973 /// domain decomposition mpi_communicator
974 const MPI_Comm mpi_communicator;
975
977
978 /// number of mpi processes in the current pool
979 const unsigned int n_mpi_processes;
980
981 /// current mpi process id in the current pool
982 const unsigned int this_mpi_process;
983
984 /// conditional stream object to enable printing only on root processor
985 /// across all pools
986 dealii::ConditionalOStream pcout;
987 };
988
989} // namespace dftfe
990#endif
Definition AtomicCenteredNonLocalOperator.h:58
This class is the primary interface location of all other parts of the DFT-FE code for all steps invo...
Definition dft.h:115
Namespace which declares the input parameters and the functions to parse them from the input paramete...
Definition dftParameters.h:35
Calculates dispersion correction to energy, force and stress.
Definition dftd.h:37
std::map< unsigned int, unsigned int > d_AtomIdBinIdLocalDofHandlerElectro
Definition force.h:941
void addEPSPStressContribution(dealii::FEValues< 3 > &feValues, dealii::FEFaceValues< 3 > &feFaceValues, dealii::FEEvaluation< 3, 1, C_num1DQuadLPSP< FEOrder >() *C_numCopies1DQuadLPSP(), 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int phiTotDofHandlerIndexElectro, const unsigned int cell, const dealii::AlignedVector< dealii::VectorizedArray< double > > &rhoQuads, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &gradRhoQuads, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &pseudoVLocAtoms, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManager, const std::vector< std::map< dealii::CellId, unsigned int > > &cellsVselfBallsClosestAtomIdDofHandler)
unsigned int d_forceDofHandlerIndexElectro
Definition force.h:847
std::vector< std::map< dealii::DoFHandler< 3 >::active_cell_iterator, std::vector< unsigned int > > > d_cellFacesVselfBallSurfacesDofHandlerForce
Definition force.h:921
void computeAtomsForcesGaussianGenerator(bool allowGaussianOverlapOnAtoms=false)
dealii::DoFHandler< 3 > d_dofHandlerForceElectro
Definition force.h:839
forceClass(dftClass< FEOrder, FEOrderElectro, memorySpace > *_dftPtr, const MPI_Comm &mpi_comm_parent, const MPI_Comm &mpi_comm_domain, const dftParameters &dftParams)
Constructor.
void computeConfigurationalForceEEshelbyTensorFPSPFnlLinFE(const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int eigenDofHandlerIndex, const unsigned int smearedChargeQuadratureId, const unsigned int lpspQuadratureIdElectro, const dealii::MatrixFree< 3, double > &matrixFreeDataElectro, const unsigned int phiTotDofHandlerIndexElectro, const distributedCPUVec< double > &phiTotRhoOutElectro, const std::vector< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &rhoOutValues, const std::vector< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &gradRhoOutValues, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &rhoTotalOutValuesLpsp, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &gradRhoTotalOutValuesLpsp, const std::map< dealii::CellId, std::vector< double > > &rhoCoreValues, const std::map< dealii::CellId, std::vector< double > > &gradRhoCoreValues, const std::map< dealii::CellId, std::vector< double > > &hessianRhoCoreValues, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &gradRhoCoreAtoms, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &hessianRhoCoreAtoms, const std::map< dealii::CellId, std::vector< double > > &pseudoVLocElectro, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &pseudoVLocAtomsElectro, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManagerElectro)
const dftParameters & d_dftParams
Definition force.h:976
dealii::Tensor< 2, 3, double > & getStress()
returns a copy of the current stress tensor value.
void createBinObjectsForce(const dealii::DoFHandler< 3 > &dofHandler, const dealii::DoFHandler< 3 > &dofHandlerForce, const dealii::AffineConstraints< double > &hangingPlusPBCConstraints, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManager, std::vector< std::vector< dealii::DoFHandler< 3 >::active_cell_iterator > > &cellsVselfBallsDofHandler, std::vector< std::vector< dealii::DoFHandler< 3 >::active_cell_iterator > > &cellsVselfBallsDofHandlerForce, std::vector< std::map< dealii::CellId, unsigned int > > &cellsVselfBallsClosestAtomIdDofHandler, std::map< unsigned int, unsigned int > &AtomIdBinIdLocalDofHandler, std::vector< std::map< dealii::DoFHandler< 3 >::active_cell_iterator, std::vector< unsigned int > > > &cellFacesVselfBallSurfacesDofHandler, std::vector< std::map< dealii::DoFHandler< 3 >::active_cell_iterator, std::vector< unsigned int > > > &cellFacesVselfBallSurfacesDofHandlerForce)
std::vector< double > d_globalAtomsForces
Storage for configurational force on all global atoms.
Definition force.h:799
dealii::Tensor< 2, 3, double > d_stress
Storage for configurational stress tensor.
Definition force.h:802
std::vector< double > & getAtomsForces()
returns a copy of the configurational force on all global atoms.
void FPhiTotSmearedChargesGammaAtomsElementalContribution(std::map< unsigned int, std::vector< double > > &forceContributionSmearedChargesGammaAtoms, dealii::FEEvaluation< 3, -1, 1, 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int cell, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &gradPhiTotQuads, const std::vector< unsigned int > &nonTrivialAtomIdsMacroCell, const std::map< dealii::CellId, std::vector< int > > &bQuadAtomIdsAllAtoms, const dealii::AlignedVector< dealii::VectorizedArray< double > > &smearedbQuads)
void configForceLinFEInit(const dealii::MatrixFree< 3, double > &matrixFreeData, const dealii::MatrixFree< 3, double > &matrixFreeDataElectro)
void computeAtomsForces(const dealii::MatrixFree< 3, double > &matrixFreeData, const dispersionCorrection &dispersionCorr, const unsigned int eigenDofHandlerIndex, const unsigned int smearedChargeQuadratureId, const unsigned int lpspQuadratureIdElectro, const dealii::MatrixFree< 3, double > &matrixFreeDataElectro, const unsigned int phiTotDofHandlerIndexElectro, const distributedCPUVec< double > &phiTotRhoOutElectro, const std::vector< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &rhoOutValues, const std::vector< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &gradRhoOutValues, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &rhoTotalOutValuesLpsp, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &gradRhoTotalOutValuesLpsp, const std::map< dealii::CellId, std::vector< double > > &rhoCoreValues, const std::map< dealii::CellId, std::vector< double > > &gradRhoCoreValues, const std::map< dealii::CellId, std::vector< double > > &hessianRhoCoreValues, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &gradRhoCoreAtoms, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &hessianRhoCoreAtoms, const std::map< dealii::CellId, std::vector< double > > &pseudoVLocElectro, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &pseudoVLocAtomsElectro, const dealii::AffineConstraints< double > &hangingPlusPBCConstraintsElectro, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManagerElectro)
computes the configurational force on all atoms corresponding to a Gaussian generator,...
void computeConfigurationalForceEselfLinFE(const dealii::DoFHandler< 3 > &dofHandlerElectro, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManagerElectro, const dealii::MatrixFree< 3, double > &matrixFreeDataElectro, const unsigned int smearedChargeQuadratureId)
const bool d_allowGaussianOverlapOnAtoms
Definition force.h:815
void initUnmoved(const dealii::Triangulation< 3, 3 > &triangulation, const dealii::Triangulation< 3, 3 > &serialTriangulation, const std::vector< std::vector< double > > &domainBoundingVectors, const bool isElectrostaticsMesh)
initializes data structures inside forceClass assuming unmoved triangulation.
dealii::ConditionalOStream pcout
Definition force.h:986
const unsigned int this_mpi_process
current mpi process id in the current pool
Definition force.h:982
std::map< std::pair< unsigned int, unsigned int >, unsigned int > d_atomsForceDofs
Definition force.h:876
std::vector< std::map< dealii::DoFHandler< 3 >::active_cell_iterator, std::vector< unsigned int > > > d_cellFacesVselfBallSurfacesDofHandlerElectro
Definition force.h:951
void addENonlinearCoreCorrectionStressContributionSpinPolarized(dealii::FEEvaluation< 3, 1, C_num1DQuad< C_rhoNodalPolyOrder< FEOrder, FEOrderElectro >()>(), 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int cell, const dealii::AlignedVector< dealii::VectorizedArray< double > > &vxcQuadsSpin0, const dealii::AlignedVector< dealii::VectorizedArray< double > > &vxcQuadsSpin1, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &derExcGradRhoSpin0, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &derExcGradRhoSpin1, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &gradRhoCoreAtoms, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &hessianRhoCoreAtoms, const bool isXCGGA=false)
dealii::AffineConstraints< double > d_constraintsNoneForceElectro
Definition force.h:871
void distributeForceContributionFnlGammaAtoms(const std::map< unsigned int, std::vector< double > > &forceContributionFnlGammaAtoms)
void printStress()
prints the currently stored configurational stress tensor.
const unsigned int n_mpi_processes
number of mpi processes in the current pool
Definition force.h:979
std::vector< std::map< dealii::DoFHandler< 3 >::active_cell_iterator, std::vector< unsigned int > > > d_cellFacesVselfBallSurfacesDofHandlerForceElectro
Definition force.h:961
void FNonlinearCoreCorrectionGammaAtomsElementalContribution(std::map< unsigned int, std::vector< double > > &forceContributionFNonlinearCoreCorrectionGammaAtoms, dealii::FEEvaluation< 3, 1, C_num1DQuad< C_rhoNodalPolyOrder< FEOrder, FEOrderElectro >()>(), 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int cell, const dealii::AlignedVector< dealii::VectorizedArray< double > > &vxcQuads, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &gradRhoCoreAtoms)
void FnlGammaAtomsElementalContribution(std::map< unsigned int, std::vector< double > > &forceContributionFnlGammaAtoms, const dealii::MatrixFree< 3, double > &matrixFreeData, dealii::FEEvaluation< 3, 1, C_num1DQuadNLPSP< FEOrder >() *C_numCopies1DQuadNLPSP(), 3 > &forceEvalNLP, const std::shared_ptr< AtomicCenteredNonLocalOperator< dataTypes::number, memorySpace > > nonLocalOp, unsigned int numNonLocalAtomsCurrentProcess, const std::vector< int > &globalChargeIdNonLocalAtoms, const std::vector< unsigned int > &numberPseudoWaveFunctionsPerAtom, const unsigned int cell, const std::map< dealii::CellId, unsigned int > &cellIdToCellNumberMap, const std::vector< dataTypes::number > &zetaDeltaVQuadsFlattened, const std::vector< dataTypes::number > &projectorKetTimesPsiTimesVTimesPartOccContractionGradPsiQuadsFlattened)
void computeConfigurationalForceEEshelbyEElectroPhiTot(const dealii::MatrixFree< 3, double > &matrixFreeDataElectro, const unsigned int phiTotDofHandlerIndexElectro, const unsigned int smearedChargeQuadratureId, const unsigned int lpspQuadratureIdElectro, const distributedCPUVec< double > &phiTotRhoOutElectro, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &rhoTotalOutValues, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &rhoTotalOutValuesLpsp, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &gradRhoTotalOutValues, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &gradRhoTotalOutValuesLpsp, const std::map< dealii::CellId, std::vector< double > > &pseudoVLocElectro, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &pseudoVLocAtomsElectro, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManagerElectro)
void locateAtomCoreNodesForce(const dealii::DoFHandler< 3 > &dofHandlerForce, const dealii::IndexSet &locally_owned_dofsForce, std::map< std::pair< unsigned int, unsigned int >, unsigned int > &atomsForceDofs)
get the value of Gaussian generator parameter (d_gaussianConstant). Gaussian generator: Gamma(r)= exp...
void computeConfigurationalForceEselfNoSurfaceLinFE()
const MPI_Comm mpi_communicator
domain decomposition mpi_communicator
Definition force.h:974
void computeConfigurationalForceTotalLinFE(const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int eigenDofHandlerIndex, const unsigned int smearedChargeQuadratureId, const unsigned int lpspQuadratureIdElectro, const dealii::MatrixFree< 3, double > &matrixFreeDataElectro, const unsigned int phiTotDofHandlerIndexElectro, const distributedCPUVec< double > &phiTotRhoOutElectro, const std::vector< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &rhoOutValues, const std::vector< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &gradRhoOutValues, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &rhoTotalOutValuesLpsp, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &gradRhoTotalOutValuesLpsp, const std::map< dealii::CellId, std::vector< double > > &rhoCoreValues, const std::map< dealii::CellId, std::vector< double > > &gradRhoCoreValues, const std::map< dealii::CellId, std::vector< double > > &hessianRhoCoreValues, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &gradRhoCoreAtoms, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &hessianRhoCoreAtoms, const std::map< dealii::CellId, std::vector< double > > &pseudoVLocElectro, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &pseudoVLocAtomsElectro, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManagerElectro)
void FNonlinearCoreCorrectionGammaAtomsElementalContributionSpinPolarized(std::map< unsigned int, std::vector< double > > &forceContributionFNonlinearCoreCorrectionGammaAtoms, dealii::FEEvaluation< 3, 1, C_num1DQuad< C_rhoNodalPolyOrder< FEOrder, FEOrderElectro >()>(), 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int cell, const dealii::AlignedVector< dealii::VectorizedArray< double > > &vxcQuadsSpin0, const dealii::AlignedVector< dealii::VectorizedArray< double > > &vxcQuadsSpin1, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &derExcGradRhoSpin0, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &derExcGradRhoSpin1, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &gradRhoCoreAtoms, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &hessianRhoCoreAtoms, const bool isXCGGA=false)
std::map< dealii::CellId, dealii::DoFHandler< 3 >::active_cell_iterator > d_cellIdToActiveCellIteratorMapDofHandlerRhoNodalElectro
Definition force.h:964
void addEVselfSmearedStressContribution(dealii::FEEvaluation< 3, -1, 1, 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int cell, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &gradVselfQuads, const std::vector< unsigned int > &nonTrivialAtomImageIdsMacroCell, const std::map< dealii::CellId, std::vector< int > > &bQuadAtomIdsAllAtomsImages, const dealii::AlignedVector< dealii::VectorizedArray< double > > &smearedbQuads)
std::vector< std::map< dealii::CellId, unsigned int > > d_cellsVselfBallsClosestAtomIdDofHandlerElectro
Definition force.h:937
std::vector< std::map< dealii::DoFHandler< 3 >::active_cell_iterator, std::vector< unsigned int > > > d_cellFacesVselfBallSurfacesDofHandler
Definition force.h:911
distributedCPUVec< double > d_configForceVectorLinFEElectro
Definition force.h:772
const MPI_Comm d_mpiCommParent
domain decomposition mpi_communicator
Definition force.h:971
void computeFloatingAtomsForces()
dealii::AffineConstraints< double > d_constraintsNoneForce
Definition force.h:867
std::vector< double > d_forceAtomsFloating
Definition force.h:784
dealii::FESystem< 3 > FEForce
Definition force.h:822
unsigned int d_forceDofHandlerIndex
Definition force.h:843
dealii::IndexSet d_locally_owned_dofsForceElectro
Definition force.h:855
void computeStressEEshelbyEPSPEnlEk(const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int eigenDofHandlerIndex, const unsigned int smearedChargeQuadratureId, const unsigned int lpspQuadratureIdElectro, const dealii::MatrixFree< 3, double > &matrixFreeDataElectro, const unsigned int phiTotDofHandlerIndexElectro, const distributedCPUVec< double > &phiTotRhoOutElectro, const std::vector< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &rhoOutValues, const std::vector< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &gradRhoOutValues, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &rhoTotalOutValuesLpsp, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &gradRhoTotalOutValuesLpsp, const std::map< dealii::CellId, std::vector< double > > &pseudoVLocElectro, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &pseudoVLocAtomsElectro, const std::map< dealii::CellId, std::vector< double > > &rhoCoreValues, const std::map< dealii::CellId, std::vector< double > > &gradRhoCoreValues, const std::map< dealii::CellId, std::vector< double > > &hessianRhoCoreValues, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &gradRhoCoreAtoms, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &hessianRhoCoreAtoms, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManagerElectro)
void accumulateForceContributionGammaAtomsFloating(const std::map< unsigned int, std::vector< double > > &forceContributionLocalGammaAtoms, std::vector< double > &accumForcesVector)
void computeStress(const dealii::MatrixFree< 3, double > &matrixFreeData, const dispersionCorrection &dispersionCorr, const unsigned int eigenDofHandlerIndex, const unsigned int smearedChargeQuadratureId, const unsigned int lpspQuadratureIdElectro, const dealii::MatrixFree< 3, double > &matrixFreeDataElectro, const unsigned int phiTotDofHandlerIndexElectro, const distributedCPUVec< double > &phiTotRhoOutElectro, const std::vector< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &rhoOutValues, const std::vector< dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > > &gradRhoOutValues, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &rhoTotalOutValuesLpsp, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &gradRhoTotalOutValuesLpsp, const std::map< dealii::CellId, std::vector< double > > &pseudoVLocElectro, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &pseudoVLocAtomsElectro, const std::map< dealii::CellId, std::vector< double > > &rhoCoreValues, const std::map< dealii::CellId, std::vector< double > > &gradRhoCoreValues, const std::map< dealii::CellId, std::vector< double > > &hessianRhoCoreValues, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &gradRhoCoreAtoms, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &hessianRhoCoreAtoms, const dealii::AffineConstraints< double > &hangingPlusPBCConstraintsElectro, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManagerElectro)
Update force generator Gaussian constant.
dealii::DoFHandler< 3 > d_dofHandlerForce
Definition force.h:830
dealii::IndexSet d_locally_owned_dofsForce
Definition force.h:851
std::vector< std::vector< dealii::DoFHandler< 3 >::active_cell_iterator > > d_cellsVselfBallsDofHandlerForceElectro
Definition force.h:932
void computeElementalNonLocalPseudoOVDataForce()
void FPSPLocalGammaAtomsElementalContribution(std::map< unsigned int, std::vector< double > > &forceContributionFPSPLocalGammaAtoms, dealii::FEValues< 3 > &feValues, dealii::FEFaceValues< 3 > &feFaceValues, dealii::FEEvaluation< 3, 1, C_num1DQuadLPSP< FEOrder >() *C_numCopies1DQuadLPSP(), 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int phiTotDofHandlerIndexElectro, const unsigned int cell, const dealii::AlignedVector< dealii::VectorizedArray< double > > &rhoQuads, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &gradRhoQuads, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &pseudoVLocAtoms, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManager, const std::vector< std::map< dealii::CellId, unsigned int > > &cellsVselfBallsClosestAtomIdDofHandler)
void FnlGammaxElementalContribution(dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &FVectQuads, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int numQuadPoints, const std::shared_ptr< AtomicCenteredNonLocalOperator< dataTypes::number, memorySpace > > nonLocalOp, const unsigned int numNonLocalAtomsCurrentProcess, const std::vector< int > &globalChargeIdNonLocalAtoms, const std::vector< unsigned int > &numberPseudoWaveFunctionsPerAtom, const unsigned int cell, const std::map< dealii::CellId, unsigned int > &cellIdToCellNumberMap, const std::vector< dataTypes::number > &zetaDeltaVQuadsFlattened, const std::vector< dataTypes::number > &projectorKetTimesPsiTimesVTimesPartOccContractionGradPsiQuadsFlattened)
std::map< unsigned int, unsigned int > d_AtomIdBinIdLocalDofHandler
Definition force.h:901
void computeStressEself(const dealii::DoFHandler< 3 > &dofHandlerElectro, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManagerElectro, const dealii::MatrixFree< 3, double > &matrixFreeDataElectro, const unsigned int smearedChargeQuadratureId)
void computeConfigurationalForcePhiExtLinFE()
void FVselfSmearedChargesGammaAtomsElementalContribution(std::map< unsigned int, std::vector< double > > &forceContributionSmearedChargesGammaAtoms, dealii::FEEvaluation< 3, -1, 1, 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int cell, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &gradVselfBinQuads, const std::vector< unsigned int > &nonTrivialAtomIdsMacroCell, const std::map< dealii::CellId, std::vector< int > > &bQuadAtomIdsAllAtoms, const dealii::AlignedVector< dealii::VectorizedArray< double > > &smearedbQuads)
std::map< std::pair< unsigned int, unsigned int >, unsigned int > d_atomsForceDofsElectro
Definition force.h:881
std::vector< distributedCPUVec< double > > d_gaussianWeightsVecAtoms
Definition force.h:966
void stressEnlElementalContribution(dealii::Tensor< 2, 3, double > &stressContribution, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int numQuadPoints, const std::vector< double > &jxwQuadsSubCells, const unsigned int cell, const unsigned int numNonLocalAtomsCurrentProcess, const std::shared_ptr< AtomicCenteredNonLocalOperator< dataTypes::number, memorySpace > > nonLocalOp, const std::vector< unsigned int > &numberPseudoWaveFunctionsPerAtom, const std::map< dealii::CellId, unsigned int > &cellIdToCellNumberMap, const std::vector< dataTypes::number > &zetalmDeltaVlProductDistImageAtoms, const std::vector< dataTypes::number > &projectorKetTimesPsiTimesVTimesPartOccContractionGradPsiQuadsFlattened, const bool isSpinPolarized)
dftClass< FEOrder, FEOrderElectro, memorySpace > * dftPtr
pointer to dft class
Definition force.h:818
std::vector< std::vector< dealii::DoFHandler< 3 >::active_cell_iterator > > d_cellsVselfBallsDofHandler
Definition force.h:887
dealii::IndexSet d_locally_relevant_dofsForceElectro
Definition force.h:863
void initMoved(std::vector< const dealii::DoFHandler< 3 > * > &dofHandlerVectorMatrixFree, std::vector< const dealii::AffineConstraints< double > * > &constraintsVectorMatrixFree, const bool isElectrostaticsMesh)
initializes data structures inside forceClass which depend on the moved mesh.
void initPseudoData()
initializes and precomputes pseudopotential related data structuers required for configurational forc...
void addEPhiTotSmearedStressContribution(dealii::FEEvaluation< 3, -1, 1, 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int cell, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &gradPhiTotQuads, const std::vector< unsigned int > &nonTrivialAtomImageIdsMacroCell, const std::map< dealii::CellId, std::vector< int > > &bQuadAtomIdsAllAtomsImages, const dealii::AlignedVector< dealii::VectorizedArray< double > > &smearedbQuads)
std::vector< std::vector< dealii::DoFHandler< 3 >::active_cell_iterator > > d_cellsVselfBallsDofHandlerElectro
Definition force.h:927
void FNonlinearCoreCorrectionGammaAtomsElementalContribution(std::map< unsigned int, std::vector< double > > &forceContributionFNonlinearCoreCorrectionGammaAtoms, dealii::FEEvaluation< 3, 1, C_num1DQuad< C_rhoNodalPolyOrder< FEOrder, FEOrderElectro >()>(), 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int cell, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &derExcGradRho, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &hessianRhoCoreAtoms)
dealii::IndexSet d_locally_relevant_dofsForce
Definition force.h:859
void addENonlinearCoreCorrectionStressContribution(dealii::FEEvaluation< 3, 1, C_num1DQuad< C_rhoNodalPolyOrder< FEOrder, FEOrderElectro >()>(), 3 > &forceEval, const dealii::MatrixFree< 3, double > &matrixFreeData, const unsigned int cell, const dealii::AlignedVector< dealii::VectorizedArray< double > > &vxcQuads, const dealii::AlignedVector< dealii::Tensor< 1, 3, dealii::VectorizedArray< double > > > &derExcGradRho, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &gradRhoCoreAtoms, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &hessianRhoCoreAtoms)
std::vector< std::map< dealii::CellId, unsigned int > > d_cellsVselfBallsClosestAtomIdDofHandler
Definition force.h:897
void computeStressEEshelbyEElectroPhiTot(const dealii::MatrixFree< 3, double > &matrixFreeDataElectro, const unsigned int phiTotDofHandlerIndexElectro, const unsigned int smearedChargeQuadratureId, const unsigned int lpspQuadratureIdElectro, const distributedCPUVec< double > &phiTotRhoOutElectro, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &rhoTotalOutValues, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &rhoTotalOutValuesLpsp, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &gradRhoTotalOutValuesElectro, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &gradRhoTotalOutValuesElectroLpsp, const std::map< dealii::CellId, std::vector< double > > &pseudoVLocElectro, const std::map< unsigned int, std::map< dealii::CellId, std::vector< double > > > &pseudoVLocAtomsElectro, const vselfBinsManager< FEOrder, FEOrderElectro > &vselfBinsManagerElectro)
distributedCPUVec< double > d_configForceVectorLinFE
Definition force.h:765
std::vector< std::vector< dealii::DoFHandler< 3 >::active_cell_iterator > > d_cellsVselfBallsDofHandlerForce
Definition force.h:892
dealii::Tensor< 2, 3, double > d_stressKPoints
Definition force.h:810
void distributeForceContributionFPSPLocalGammaAtoms(const std::map< unsigned int, std::vector< double > > &forceContributionFPSPLocalGammaAtoms, const std::map< std::pair< unsigned int, unsigned int >, unsigned int > &atomsForceDofs, const dealii::AffineConstraints< double > &constraintsNoneForce, distributedCPUVec< double > &configForceVectorLinFE)
void configForceLinFEFinalize()
void printAtomsForces()
prints the currently stored configurational forces on atoms and the Gaussian generator constant used ...
Definition MemoryStorage.h:33
Categorizes atoms into bins for efficient solution of nuclear electrostatic self-potential....
Definition vselfBinsManager.h:36
MemorySpace
Definition MemorySpaceType.h:33
Definition pseudoPotentialToDftfeConverter.cc:34
constexpr unsigned int C_num1DQuad()
1d quadrature rule order
Definition constants.h:40
dealii::LinearAlgebra::distributed::Vector< elem_type, dealii::MemorySpace::Host > distributedCPUVec
Definition headers.h:92
constexpr unsigned int C_num1DQuadNLPSP()
1d quadrature rule order for non-local part of pseudopotential
Definition constants.h:141
constexpr unsigned int C_numCopies1DQuadNLPSP()
number of copies 1d quad rule non-local PSP
Definition constants.h:148
constexpr unsigned int C_rhoNodalPolyOrder()
rho nodal polynomial order
Definition constants.h:133
constexpr unsigned int C_numCopies1DQuadLPSP()
number of copies 1d quad rule local PSP
Definition constants.h:163
constexpr unsigned int C_num1DQuadLPSP()
1d quadrature rule order for local part of pseudopotential
Definition constants.h:156