DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
geoOptCell.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#ifndef geoOptCell_H_
18#define geoOptCell_H_
19#include "constants.h"
21#include "nonLinearSolver.h"
22#include "dftBase.h"
23#include "dftfeWrapper.h"
24
25namespace dftfe
26{
27 /**
28 * @brief problem class for cell stress relaxation solver.
29 *
30 * @author Sambit Das
31 */
33 {
34 public:
35 /** @brief Constructor.
36 *
37 * @param _dftPtr pointer to dftClass
38 * @param mpi_comm_parent parent mpi_communicator
39 */
41 const MPI_Comm &mpi_comm_parent,
42 const bool restart = false);
43
44 /**
45 * @brief initializes the data member d_relaxationFlags.
46 *
47 */
48 void
49 init(const std::string &restartPath);
50
51 /**
52 * @brief calls the cell stress relaxation solver.
53 *
54 * The Polak–Ribière nonlinear CG solver with secant based line search
55 * is used for the stress relaxation.
56 *
57 * @return int total geometry update calls
58 */
59 int
60 run();
61
62 /**
63 * @brief writes the current fem mesh.
64 *
65 */
66 void
67 writeMesh(std::string meshFileName);
68
69 /**
70 * @brief Obtain number of unknowns (depends on the stress relaxation constraint type).
71 *
72 * @return int Number of unknowns.
73 */
74 unsigned int
76
77 /**
78 * @brief Compute function gradient (stress).
79 *
80 * @param gradient STL vector for gradient values.
81 */
82 void
83 gradient(std::vector<double> &gradient);
84
85 /**
86 * @brief Update the strain tensor epsilon.
87 *
88 * The new strain tensor is epsilonNew= epsilon+ delta(epsilon). Since
89 * epsilon strain is already applied to the domain. The new strain to be
90 * applied to the domain is epsilonNew*inv(epsilon)
91 *
92 * @param solution delta(epsilon).
93 */
94 void
95 update(const std::vector<double> &solution,
96 const bool computeStress = true,
97 const bool useSingleAtomSolutionsInitialGuess = false);
98
99 /**
100 * @brief create checkpoint file for current domain bounding vectors and atomic coordinates.
101 *
102 */
103 void
105
106 /**
107 * @brief check for convergence.
108 *
109 */
110 bool
111 isConverged() const;
112
113 const MPI_Comm &
115
116 /// Not implemented
117 void
118 value(std::vector<double> &functionValue);
119
120 /// Not implemented
121 void
122 precondition(std::vector<double> &s, const std::vector<double> &gradient);
123
124 /// Not implemented
125 void
126 solution(std::vector<double> &solution);
127
128 /// Not implemented
129 std::vector<unsigned int>
131
132 private:
133 /// Relaxation flags which determine whether a particular stress component
134 /// is to be relaxed or not.
135 // The relaxation flags are determined based on the stress relaxation
136 // constraint type.
137 std::vector<unsigned int> d_relaxationFlags;
138
139 std::string d_restartPath;
145 /// total number of calls to update()
148 /// current strain tensor applied on the domain
149 dealii::Tensor<2, 3, double> d_strainEpsilon;
150
151 /// pointer to dft class
153 std::unique_ptr<nonLinearSolver> d_nonLinearSolverPtr;
154
155 /// parallel communication objects
156 const MPI_Comm mpi_communicator;
157 const unsigned int n_mpi_processes;
158 const unsigned int this_mpi_process;
159
160 /// conditional stream object
161 dealii::ConditionalOStream pcout;
162 };
163
164} // namespace dftfe
165
166#endif
abstract base class for dft
Definition dftBase.h:34
bool d_solverRestart
Definition geoOptCell.h:142
void solution(std::vector< double > &solution)
Not implemented.
double d_domainVolumeInitial
Definition geoOptCell.h:147
bool d_isScfRestart
Definition geoOptCell.h:143
std::vector< unsigned int > d_relaxationFlags
Definition geoOptCell.h:137
void value(std::vector< double > &functionValue)
Not implemented.
int run()
calls the cell stress relaxation solver.
dftBase * d_dftPtr
pointer to dft class
Definition geoOptCell.h:152
std::string d_solverRestartPath
Definition geoOptCell.h:140
int d_solver
Definition geoOptCell.h:144
bool d_isRestart
Definition geoOptCell.h:141
bool isConverged() const
check for convergence.
void save()
create checkpoint file for current domain bounding vectors and atomic coordinates.
dealii::Tensor< 2, 3, double > d_strainEpsilon
current strain tensor applied on the domain
Definition geoOptCell.h:149
geoOptCell(dftBase *dftPtr, const MPI_Comm &mpi_comm_parent, const bool restart=false)
Constructor.
dealii::ConditionalOStream pcout
conditional stream object
Definition geoOptCell.h:161
std::vector< unsigned int > getUnknownCountFlag() const
Not implemented.
const MPI_Comm & getMPICommunicator()
get MPI communicator.
std::string d_restartPath
Definition geoOptCell.h:139
int d_totalUpdateCalls
total number of calls to update()
Definition geoOptCell.h:146
unsigned int getNumberUnknowns() const
Obtain number of unknowns (depends on the stress relaxation constraint type).
void precondition(std::vector< double > &s, const std::vector< double > &gradient)
Not implemented.
void writeMesh(std::string meshFileName)
writes the current fem mesh.
std::unique_ptr< nonLinearSolver > d_nonLinearSolverPtr
Definition geoOptCell.h:153
const MPI_Comm mpi_communicator
parallel communication objects
Definition geoOptCell.h:156
void gradient(std::vector< double > &gradient)
Compute function gradient (stress).
void init(const std::string &restartPath)
initializes the data member d_relaxationFlags.
void update(const std::vector< double > &solution, const bool computeStress=true, const bool useSingleAtomSolutionsInitialGuess=false)
Update the strain tensor epsilon.
const unsigned int this_mpi_process
Definition geoOptCell.h:158
const unsigned int n_mpi_processes
Definition geoOptCell.h:157
nonlinearSolverProblem()
Constructor.
Definition pseudoPotentialToDftfeConverter.cc:34