Skip to content

Commit

Permalink
document code path in logs
Browse files Browse the repository at this point in the history
improve docs
  • Loading branch information
meisam committed May 29, 2023
1 parent 2973f78 commit ff1d72f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/general_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ void cli_params::parse(int argc, char *argv[]) {
"To calculate the charge correction, slabcc needs the following "
"files:\n"
" 1. Input parameters file (default: slabcc.in)\n"
" 2. CHGCAR of the neutral system\n"
" 3. CHGCAR of the charged system\n"
" 4. LOCPOT of the neutral system\n"
" 5. LOCPOT of the charged system\n\n"
" 2. CHGCAR of the neutral system (default: CHGCAR.N)\n"
" 3. CHGCAR of the charged system (default: CHGCAR.C)\n"
" 4. LOCPOT of the neutral system (default: LOCPOT.N)\n"
" 5. LOCPOT of the charged system (default: LOCPOT.C)\n\n"
"The input parameters file for a slab should minimally include:\n"
" - charge_position : approximate position of the localized charge "
"center\n"
Expand Down
19 changes: 11 additions & 8 deletions src/slabcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int main(int argc, char *argv[]) {
}
log->debug("Slab normal direction index (0-2): {}", model.normal_direction);
log->trace("Shift to center done!");

log->trace("----calculating difference of input files---");
supercell Defect_supercell = Neutral_supercell;
Defect_supercell.potential =
Charged_supercell.potential - Neutral_supercell.potential;
Expand All @@ -186,7 +186,7 @@ int main(int argc, char *argv[]) {
model.POT_target_on_input_grid = Defect_supercell.potential;

if (output_diffs_only) {
log->debug("Only the extra charge and the potential difference calculation "
log->trace("Only the extra charge and the potential difference calculation "
"have been requested!");
write_planar_avg(Defect_supercell.potential,
Defect_supercell.charge * model.voxel_vol, "D",
Expand Down Expand Up @@ -214,7 +214,7 @@ int main(int argc, char *argv[]) {
model.defect_charge = accu(Defect_supercell.charge) * model.voxel_vol;

if (std::abs(model.defect_charge) < 0.001) {
log->debug("Total extra charge: {}", model.defect_charge);
log->trace("Total extra charge: {}", model.defect_charge);
log->warn("Total extra charge seems to be very small. Please make sure the "
"path to the input CHGCAR files are "
"set properly!");
Expand All @@ -227,6 +227,8 @@ int main(int argc, char *argv[]) {
optimize_charge_fraction || optimize_interfaces;

if (optimize_any) {
log->info("--------------------optimizing model "
"parameters------------------------");
const arma::rowvec2 shifted_interfaces0 = model.interfaces;
const arma::mat charge_position0 = model.charge_position;
const arma::urowvec3 cell_grid0 = model.cell_grid;
Expand Down Expand Up @@ -314,17 +316,17 @@ int main(int argc, char *argv[]) {
model.update_V_target();
}
}

log->info("--------Calculating periodic energy---------");
model.gaussian_charges_gen();
model.dielectric_profiles_gen();
auto local_param = model.data_packer();
std::vector<double> gradients = {};
model.potential_RMSE =
potential_error(std::get<0>(local_param), gradients, &model);

log->debug("Cell dimensions (bohr): " +
log->trace("Cell dimensions (bohr): " +
to_string(model.cell_vectors_lengths));
log->debug("Volume (bohr^3): {}", model.cell_volume);
log->trace("Volume (bohr^3): {}", model.cell_volume);

if (is_active(verbosity::write_defect_file)) {
supercell Model_supercell = Neutral_supercell;
Expand Down Expand Up @@ -403,11 +405,12 @@ int main(int argc, char *argv[]) {
log->debug("Difference of the charge in the input files: {}",
to_string(model.defect_charge));
log->debug("Total charge of the model: {}", to_string(model.total_charge));

log->info("-------calculating isolated energy----------");
double E_isolated = 0;
double E_correction = 0;
if (extrapolate) {

log->debug("extrapolation steps size: {}", extrapol_steps_size);
log->debug("extrapolation steps number: {}", extrapol_steps_num);
const arma::rowvec3 extrapolation_grid_size =
extrapol_grid_x * arma::conv_to<arma::rowvec>::from(model.cell_grid);
const arma::urowvec3 extrapolation_grid = {
Expand Down
1 change: 1 addition & 0 deletions src/slabcc_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

void input_data::verify() const {
auto log = spdlog::get("loggers");
log->debug("----------verifying input parameters--------");
charge_sigma = arma::abs(charge_sigma);
max_eval = std::abs(max_eval);
max_time = std::abs(max_time);
Expand Down
6 changes: 4 additions & 2 deletions src/slabcc_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "slabcc_model.hpp"

void slabcc_model::set_input_variables(const input_data &inputfile_variables) {
auto log = spdlog::get("loggers");
log->debug("-------------initializing model-------------");
normal_direction = inputfile_variables.normal_direction;
interfaces = inputfile_variables.interfaces;
diel_in = inputfile_variables.diel_in;
Expand Down Expand Up @@ -472,10 +474,11 @@ void slabcc_model::update_V_target() {
const arma::rowvec new_grid_z = arma::linspace<arma::rowvec>(
1.0, POT_target_on_input_grid.n_slices, cell_grid(2));

log->debug("Calculating target potential on grid size: " +
to_string(SizeVec(POT_target)));
POT_target =
interp3(POT_target_on_input_grid, new_grid_x, new_grid_y, new_grid_z);
POT_target -= arma::accu(POT_target) / POT_target.n_elem;
log->debug("New potential grid size: " + to_string(SizeVec(POT_target)));
}
}

Expand Down Expand Up @@ -681,7 +684,6 @@ double slabcc_model::potential_error(const std::vector<double> &x,
initial_potential_RMSE = potential_RMSE;
}

log->debug("-----------------------------------------");
if (this->type != model_type::bulk) {
const arma::rowvec2 unshifted_interfaces =
fmod_p(interfaces - rounded_relative_shift(normal_direction), 1);
Expand Down
6 changes: 3 additions & 3 deletions utils/build_pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ if [ -z "$STAGE_PATH" ]; then
fi

mkdir -p "$STAGE_PATH"

SOURCE_LINK="${CI_COMMIT_LINK/%commit\/${CI_COMMIT_SHA}/src\/commit\/${CI_COMMIT_SHA}\/docs/manual.rst}"
INDEX_HTML=docs/manual.rst
SOURCE_LINK="https://codeberg.org/meisam/slabcc/src/commit/${CI_COMMIT_SHA}/${INDEX_HTML}"

echo "SOURCE LINK: $SOURCE_LINK"
tail -n +2 < docs/manual.rst | rst2html.py --title="SLABCC" -g --source-url="$SOURCE_LINK" > "$STAGE_PATH"/index.html
tail -n +2 < "$INDEX_HTML" | rst2html.py --title="SLABCC" -g --source-url="$SOURCE_LINK" > "$STAGE_PATH"/index.html
2 changes: 1 addition & 1 deletion utils/git_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ if [ "$GITHASH" = "?" ]; then
fi


echo "$GITHASH (status: $GIT_STATE)"
echo "$GITHASH (repo status: $GIT_STATE)"

0 comments on commit ff1d72f

Please sign in to comment.