ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
relax_stru_io Namespace Reference

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.

Detailed Description

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.

Function Documentation

◆ build_stru_header()

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.

Parameters
istepCurrent (zero-based) relaxation step; printed as istep + 1.
etotTotal energy in Ry.
stressStress tensor (3x3) in Ry/Bohr^3.
inpInput parameters (cal_force, cal_stress select the NOTE text).
is_finalIf true, the step label is marked "(FINAL)".
geometry_evaluatedfalse 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.
Returns
The formatted header string.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ need_orbital()

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.

Here is the caller graph for this function:

◆ write_stru()

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.

Parameters
ucellUnit cell to write.
inpInput parameters (nspin, out_mul, calculation).
filenameOutput file path.
headerHeader comment built by build_stru_header.
forceAtomic forces (used for STRU output when has_force is true).
need_orbWhether to write orbitals (from need_orbital).
deepks_setorbDeePKS setorb flag forwarded to the STRU writer.
my_rankMPI rank of the calling process.
has_forcetrue 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).
appendtrue to append the structure block (STRU format only, for out_app_flag == 1 multi-step runs); CIF always truncates.
Here is the call graph for this function:
Here is the caller graph for this function: