Skip to content

Commit

Permalink
cleanup extrapolation table
Browse files Browse the repository at this point in the history
  • Loading branch information
meisam committed May 30, 2023
1 parent 00d6b6d commit 6c8fa90
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 deletions.
30 changes: 19 additions & 11 deletions src/slabcc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,25 +446,33 @@ int main(int argc, char *argv[]) {
}

log->debug("--------------------------------------------------------");
std::string extrapolation_header = "Scaling\tE_periodic\t\tmodel's charge";
std::stringstream extrapolation_outputstream;
extrapolation_outputstream << std::left << std::setw(10) << "Scaling"
<< std::setw(20) << "E_periodic" << std::setw(20)
<< "model's charge";
if (model.type != model_type::bulk) {
extrapolation_header += "\t\tinterfaces";
extrapolation_outputstream << std::setw(40) << "interfaces";
}
extrapolation_header += "\t\tcharge position";
log->debug(extrapolation_header);
extrapolation_outputstream << std::setw(20) << "charge position";
log->debug(extrapolation_outputstream.str());
extrapolation_outputstream.str(std::string());

const arma::rowvec2 interface_pos =
model.interfaces * model.cell_vectors_lengths(model.normal_direction);
std::string extrapolation_info = "1.000\t\t" + to_string(EperModel0) +
"\t" + to_string(model.total_charge);
extrapolation_outputstream << std::left << std::setw(10)
<< std::to_string(1.0) << std::setw(20)
<< to_string(EperModel0) << std::setw(20)
<< to_string(model.total_charge);
if (model.type != model_type::bulk) {
extrapolation_info += "\t" + to_string(interface_pos);
extrapolation_outputstream << std::setw(40) << to_string(interface_pos);
}
for (arma::uword i = 0; i < model.charge_position.n_rows; ++i) {
extrapolation_info +=
"\t" + to_string(model.charge_position(i, model.normal_direction) *
model.cell_vectors_lengths(model.normal_direction));
extrapolation_outputstream
<< std::setw(20)
<< to_string(model.charge_position(i, model.normal_direction) *
model.cell_vectors_lengths(model.normal_direction));
}
log->debug(extrapolation_info);
log->debug(extrapolation_outputstream.str());
arma::rowvec Es = arma::zeros<arma::rowvec>(extrapol_steps_num - 1),
sizes = Es;
std::tie(Es, sizes) =
Expand Down
21 changes: 13 additions & 8 deletions src/slabcc_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,18 +551,23 @@ slabcc_model::extrapolate(int extrapol_steps_num, double extrapol_steps_size) {
voxel_vol * Hartree_to_eV;
const arma::rowvec2 interface_pos =
interfaces * cell_vectors_lengths(normal_direction);
std::string extrapolation_info = ::to_string(extrapol_factor) + "\t\t" +
to_string(EperModel) + "\t" +
::to_string(total_charge);

std::stringstream extrapolation_outputstream;
extrapolation_outputstream
<< std::left << std::setw(10) << std::to_string(extrapol_factor)
<< std::setw(20) << to_string(EperModel) << std::setw(20)
<< to_string(total_charge);
if (this->type != model_type::bulk) {
extrapolation_info += "\t" + to_string(interface_pos);
extrapolation_outputstream << std::setw(40) << to_string(interface_pos);
}
for (arma::uword i = 0; i < charge_position.n_rows; ++i) {
extrapolation_info +=
"\t" + to_string(charge_position(i, normal_direction) *
cell_vectors_lengths(normal_direction));
extrapolation_outputstream
<< std::setw(20)
<< to_string(charge_position(i, normal_direction) *
cell_vectors_lengths(normal_direction));
}
log->debug(extrapolation_info);
log->debug(extrapolation_outputstream.str());
extrapolation_outputstream.str(std::string());
Es(step - 1) = EperModel;
sizes(step - 1) = 1.0 / extrapol_factor;
}
Expand Down

0 comments on commit 6c8fa90

Please sign in to comment.