10 Star 12 Fork 9

DeepModeling/abacus-develop

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
relax_data.h 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
Mohan Chen 提交于 2026-06-17 08:27 +08:00 . Refactor the relax module (#7456)
#ifndef RELAX_DATA_H
#define RELAX_DATA_H
#include <vector>
/**
* @brief Unified data structure for geometry optimization algorithms.
*
* This class provides a common data container for all relaxation methods
* (BFGS, CG, SD, etc.) to share and reuse key variables like positions,
* gradients, and move vectors. It serves as the single source of truth
* for optimization state across different algorithms.
*/
class Relax_Data {
public:
/**
* @brief Default constructor.
*/
Relax_Data() = default;
/**
* @brief Default destructor.
*/
~Relax_Data() = default;
/**
* @brief Allocate memory for data vectors.
* @param dim_in Dimension of the optimization problem (3 * number of atoms).
*/
void allocate(const int dim_in);
// Static members - shared global state across all relaxation instances
static int dim; ///< Dimension of free variables (3 * number of atoms) for ion movement
static int dim_lattice; ///< Dimension of free variables (9) for lattice change
static double largest_grad; ///< Largest gradient component (force) in current step
// Instance members - per-iteration data
std::vector<double> pos; ///< Current atomic positions in Bohr
std::vector<double> grad; ///< Current gradient (negative force) in Ry/Bohr
std::vector<double> move; ///< Displacement vector for next step
std::vector<double> pos_p; ///< Previous atomic positions
std::vector<double> grad_p; ///< Previous gradient
std::vector<double> move_p; ///< Previous displacement
};
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/deepmodeling/abacus-develop.git
git@gitee.com:deepmodeling/abacus-develop.git
deepmodeling
abacus-develop
abacus-develop
develop

搜索帮助