【发布时间】:2021-09-24 16:59:10
【问题描述】:
这是我正在处理的代码:
#include <inq/inq.hpp>
#include <iostream>
#include <fstream>
#include <input/parse_xyz.hpp>
int main(int argc, char **argv) {
using namespace inq;
using namespace inq::magnitude;
input::environment env(argc, argv);
auto comm = boost::mpi3::environment::get_world_instance();
auto atoms = input::parse_xyz("zr.xyz");
//atoms.push_back("Zr" | input::coord(4.8585, 7.01264, 5.172));
auto box = input::cell::orthorhombic(9.717_A, 11.22023_A, 5.172_A);
systems::ions ions(box, atoms);
systems::electrons electrons(comm, ions, input::basis::cutoff_energy(30.0_Ha));
ground_state::initial_guess(ions, electrons);
auto result = ground_state::calculate(ions, electrons, input::interaction::pbe(), input::scf::scf_steps(200));
double const d_0 = 9.77366;
double const del = 0.3257886667;
int const n_max = 30;
std::ofstream ofs{"Zr_e_vs_d5.dat"};
for(int n = 0; n != n_max; ++n){
double const distance = d_0 - n*del;
atoms.push_back("Zr" | input::coord(9.18123, 13.2519, distance));
auto result = ground_state::calculate(ions, electrons, input::interaction::pbe(), input::scf::scf_steps(15));
//ofs << distance << '\t' << zr_energy(distance) << '\n';
ofs << distance << '\t' << result.energy.total() << '\n';
}
}
我从 .xyz 文件中读取了 50 个原子坐标。然后我在下面的循环中将一个额外的原子推入向量中。我想改变原子的最后一个坐标(Z坐标),从而模拟原子在Z方向移动。我对 C++ 很陌生,不知道如何更改该特定坐标。请帮忙
这是供参考的输入 .xyz 文件:
Zr 0.000000 1.870038 2.586000
Zr 9.717000 1.870038 2.586000
Zr 1.619500 4.675094 2.586000
Zr 0.000000 0.000000 0.000000
【问题讨论】: