|
ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
Helpers for writing structure (STRU/CIF) files during relaxation. More...
Functions | |
| std::string | build_stru_header (const int istep, const double etot, const ModuleBase::matrix &stress, const Input_para &inp, const bool is_final, const bool geometry_evaluated) |
| Build the header comment for a structure file. | |
| bool | need_orbital (const Input_para &inp) |
| Whether orbital output is required in the structure file. | |
| void | write_stru (UnitCell &ucell, const Input_para &inp, const std::string &filename, const std::string &header, const ModuleBase::matrix &force, const bool need_orb, const bool deepks_setorb, const int my_rank, const bool has_force, const bool append) |
| Write one structure file in STRU (out_stru == 1) or CIF (out_stru == 2) format. | |
Helpers for writing structure (STRU/CIF) files during relaxation.
These free functions extract the file-writing logic shared by Relax_Driver::stru_out and Relax_Driver::final_out so that the two call sites only orchestrate when and which files to write.
| std::string relax_stru_io::build_stru_header | ( | const int | istep, |
| const double | etot, | ||
| const ModuleBase::matrix & | stress, | ||
| const Input_para & | inp, | ||
| const bool | is_final, | ||
| const bool | geometry_evaluated ) |
Build the header comment for a structure file.
Contains the ABACUS version, a timestamp, the relaxation step number, the total energy in eV, the 3x3 stress tensor in kbar and a trailing NOTE line. The header is always exactly 7 lines so that downstream parsers can skip a fixed-size comment block.
| istep | Current (zero-based) relaxation step; printed as istep + 1. |
| etot | Total energy in Ry. |
| stress | Stress tensor (3x3) in Ry/Bohr^3. |
| inp | Input parameters (cal_force, cal_stress select the NOTE text). |
| is_final | If true, the step label is marked "(FINAL)". |
| geometry_evaluated | false when the geometry was proposed by the optimizer but never evaluated; the energy and stress are then marked N/A and the NOTE explains that forces are omitted. |
| bool relax_stru_io::need_orbital | ( | const Input_para & | inp | ) |
Whether orbital output is required in the structure file.
True for lcao / lcao_in_pw bases, and for pw with nao-initialized wavefunctions.
| void relax_stru_io::write_stru | ( | UnitCell & | ucell, |
| const Input_para & | inp, | ||
| const std::string & | filename, | ||
| const std::string & | header, | ||
| const ModuleBase::matrix & | force, | ||
| const bool | need_orb, | ||
| const bool | deepks_setorb, | ||
| const int | my_rank, | ||
| const bool | has_force, | ||
| const bool | append ) |
Write one structure file in STRU (out_stru == 1) or CIF (out_stru == 2) format.
| ucell | Unit cell to write. |
| inp | Input parameters (nspin, out_mul, calculation). |
| filename | Output file path. |
| header | Header comment built by build_stru_header. |
| force | Atomic forces (used for STRU output when has_force is true). |
| need_orb | Whether to write orbitals (from need_orbital). |
| deepks_setorb | DeePKS setorb flag forwarded to the STRU writer. |
| my_rank | MPI rank of the calling process. |
| has_force | true to emit per-atom f fields; forwarded to print_stru_file. Callers must pass false when the forces do not belong to the geometry being written (e.g. early relax exit). |
| append | true to append the structure block (STRU format only, for out_app_flag == 1 multi-step runs); CIF always truncates. |