修改拉曼输出文件布局
This commit is contained in:
@@ -13,6 +13,7 @@ find_package(TBB REQUIRED)
|
||||
find_package(Matplot++ REQUIRED)
|
||||
find_package(biu REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
message("biu dir: ${biu_DIR}")
|
||||
|
||||
add_executable(ufo src/fold.cpp src/unfold.cpp src/project-to-mode.cpp
|
||||
src/plot.cpp src/raman.cpp src/project-to-atom.cpp src/main.cpp)
|
||||
@@ -42,11 +43,7 @@ add_test(NAME project-to-mode WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/proje
|
||||
COMMAND ufo project-to-mode config.yaml)
|
||||
add_test(NAME raman-create-displacement WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/raman-create-displacement
|
||||
COMMAND ufo raman-create-displacement config.yaml)
|
||||
set(OUTCAR_FILES)
|
||||
foreach(i RANGE 0 23)
|
||||
list(APPEND OUTCAR_FILES job/${i}/OUTCAR)
|
||||
endforeach()
|
||||
add_test(NAME raman-extract WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/raman-extract
|
||||
COMMAND ufo raman-extract ${OUTCAR_FILES} job/origin/OUTCAR)
|
||||
COMMAND ufo raman-extract .)
|
||||
add_test(NAME raman-apply-contribution WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/raman-apply-contribution
|
||||
COMMAND ufo raman-apply-contribution config.yaml)
|
||||
|
||||
@@ -99,6 +99,6 @@ namespace ufo
|
||||
void plot_band(std::string config_file);
|
||||
void plot_point(std::string config_file);
|
||||
void raman_create_displacement(std::string config_file);
|
||||
void raman_extract(std::vector<std::string> files);
|
||||
void raman_extract(std::string path);
|
||||
void raman_apply_contribution(std::string config_file);
|
||||
}
|
||||
|
||||
@@ -10,13 +10,7 @@ int main(int argc, const char** argv)
|
||||
else if (argv[1] == "project-to-atom"s) ufo::project_to_atom(argv[2]);
|
||||
else if (argv[1] == "project-to-mode"s) ufo::project_to_mode(argv[2]);
|
||||
else if (argv[1] == "raman-create-displacement"s) ufo::raman_create_displacement(argv[2]);
|
||||
else if (argv[1] == "raman-extract"s) ufo::raman_extract
|
||||
(
|
||||
std::vector<const char*>(argv + 2, argv + argc)
|
||||
| biu::toLvalue
|
||||
| ranges::views::transform([](const char* arg) { return std::string(arg); })
|
||||
| ranges::to_vector
|
||||
);
|
||||
else if (argv[1] == "raman-extract"s) ufo::raman_extract(argv[2]);
|
||||
else if (argv[1] == "raman-apply-contribution"s) ufo::raman_apply_contribution(argv[2]);
|
||||
else if (argv[1] == "plot-band"s) ufo::plot_band(argv[2]);
|
||||
else if (argv[1] == "plot-point"s) ufo::plot_point(argv[2]);
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
|
||||
# include <ufo.hpp>
|
||||
|
||||
namespace ufo
|
||||
{
|
||||
struct RamanData
|
||||
{
|
||||
struct ModeType
|
||||
{
|
||||
std::size_t QpointIndex;
|
||||
std::size_t ModeIndex;
|
||||
double Ratio;
|
||||
using serialize = zpp::bits::members<3>;
|
||||
};
|
||||
std::vector<ModeType> Mode;
|
||||
std::map<std::pair<std::size_t, std::size_t>, double> ModeRatio;
|
||||
double MaxDisplacement;
|
||||
enum { Primative, Super } Cell;
|
||||
using serialize = zpp::bits::members<3>;
|
||||
@@ -77,7 +69,6 @@ namespace ufo
|
||||
|
||||
auto process = [&](auto& cell)
|
||||
{
|
||||
std::size_t i_of_poscar = 0;
|
||||
auto mass = cell.AtomType
|
||||
| ranges::views::transform([&](auto&& atom)
|
||||
{ return ranges::views::repeat_n(input.AtomMass[atom.first], atom.second); })
|
||||
@@ -92,7 +83,7 @@ namespace ufo
|
||||
auto ratio = config.MaxDisplacement / atom_movement.rowwise().norm().maxCoeff();
|
||||
atom_movement *= ratio;
|
||||
// 输出
|
||||
auto path = "{}/{}"_f(config.OutputPoscarDirectory, i_of_poscar);
|
||||
auto path = "{}/{}/{}"_f(config.OutputPoscarDirectory, i_of_qpoint, i_of_mode);
|
||||
std::filesystem::create_directories(path);
|
||||
std::ofstream("{}/POSCAR"_f(path)) << generate_poscar
|
||||
(
|
||||
@@ -100,9 +91,8 @@ namespace ufo
|
||||
cell.AtomPosition + atom_movement * cell.Cell.inverse(),
|
||||
cell.AtomType
|
||||
);
|
||||
output.Mode.push_back({i_of_qpoint, i_of_mode, ratio});
|
||||
output.ModeRatio[{i_of_qpoint, i_of_mode}] = ratio;
|
||||
log.debug("Write mode {} {} {}"_f(i_of_qpoint, i_of_mode, atom_movement.rowwise().norm().eval()));
|
||||
i_of_poscar++;
|
||||
}
|
||||
};
|
||||
if (config.Cell == RamanData::Primative) process(input.Primative);
|
||||
@@ -114,13 +104,12 @@ namespace ufo
|
||||
std::ofstream(config.OutputDataFile, std::ios::binary) << biu::serialize<char>(output);
|
||||
}
|
||||
|
||||
void raman_extract(std::vector<std::string> files)
|
||||
void raman_extract(std::string path)
|
||||
{
|
||||
biu::Logger::Guard log(files);
|
||||
std::vector<Eigen::Matrix3d> electricity_tensors;
|
||||
|
||||
for (const auto& file : files)
|
||||
biu::Logger::Guard log(path);
|
||||
auto get_dielectric_tensor = [](std::filesystem::path file)
|
||||
{
|
||||
biu::Logger::Guard log(file);
|
||||
auto in_stream = std::ifstream(file);
|
||||
std::string line;
|
||||
// search line containing: MACROSCOPIC STATIC DIELECTRIC TENSOR
|
||||
@@ -131,28 +120,31 @@ namespace ufo
|
||||
log.debug("find in {}"_f(file));
|
||||
// skip 1 line
|
||||
std::getline(in_stream, line);
|
||||
electricity_tensors.emplace_back();
|
||||
Eigen::Matrix3d dielectric_tensor;
|
||||
for (std::size_t i = 0; i < 3; i++) for (std::size_t j = 0; j < 3; j++)
|
||||
in_stream >> electricity_tensors.back()(i, j);
|
||||
log.debug("read tensor {}"_f(electricity_tensors.back()));
|
||||
break;
|
||||
in_stream >> dielectric_tensor(i, j);
|
||||
log.debug("read tensor {}"_f(dielectric_tensor));
|
||||
return dielectric_tensor;
|
||||
}
|
||||
}
|
||||
// test if the file is read correctly
|
||||
if (!in_stream) throw std::runtime_error("Error reading file: {}"_f(file));
|
||||
}
|
||||
|
||||
// output the result
|
||||
for (auto e: electricity_tensors) std::cout <<
|
||||
R"(- - [ {}, {}, {} ]
|
||||
- [ {}, {}, {} ]
|
||||
- [ {}, {}, {} ]
|
||||
)"_f
|
||||
(
|
||||
e(0, 0), e(0, 1), e(0, 2),
|
||||
e(1, 0), e(1, 1), e(1, 2),
|
||||
e(2, 0), e(2, 1), e(2, 2)
|
||||
);
|
||||
throw std::runtime_error("Error reading file: {}"_f(file));
|
||||
};
|
||||
auto search_path = [&](this auto self, std::size_t indent, std::string path) -> void
|
||||
{
|
||||
if (std::filesystem::exists(path + "/OUTCAR"))
|
||||
{
|
||||
auto e = get_dielectric_tensor(path + "/OUTCAR");
|
||||
for (std::size_t i = 0; i < 3; i++) std::cout << "{}- [ {}, {}, {} ]\n"_f
|
||||
(std::string(indent * 2, ' '), e(i, 0), e(i, 1), e(i, 2));
|
||||
}
|
||||
else for (auto entry : std::filesystem::directory_iterator(path)) if (entry.is_directory())
|
||||
{
|
||||
std::cout << "{}{}:\n"_f(std::string(indent * 2, ' '), entry.path().filename());
|
||||
self(indent + 1, entry.path());
|
||||
}
|
||||
};
|
||||
search_path(0, path);
|
||||
}
|
||||
|
||||
void raman_apply_contribution(std::string config_file)
|
||||
@@ -160,7 +152,7 @@ R"(- - [ {}, {}, {} ]
|
||||
struct Config
|
||||
{
|
||||
Eigen::Matrix3d OriginalSusceptibility;
|
||||
std::vector<Eigen::Matrix3d> Susceptibility;
|
||||
std::map<std::size_t, std::map<std::size_t, Eigen::Matrix3d>> Susceptibility;
|
||||
std::array<Eigen::Vector3d, 2> Polarization;
|
||||
std::string InputDataFile;
|
||||
std::string RamanInputDataFile;
|
||||
@@ -177,17 +169,18 @@ R"(- - [ {}, {}, {} ]
|
||||
input.RamanPolarization = config.Polarization;
|
||||
auto process = [&](auto& cell)
|
||||
{
|
||||
for (auto&& [i_of_mode, mode] : ranges::views::enumerate(raman_input.Mode))
|
||||
for (auto&& [i, ratio] : raman_input.ModeRatio)
|
||||
{
|
||||
auto&& _ = cell.Qpoint[mode.QpointIndex].Mode[mode.ModeIndex];
|
||||
Eigen::Matrix3d raman_tensor = (config.Susceptibility[i_of_mode] - config.OriginalSusceptibility)
|
||||
/ mode.Ratio / raman_input.MaxDisplacement;
|
||||
auto&& [i_of_qpoint, i_of_mode] = i;
|
||||
auto&& _ = cell.Qpoint[i_of_qpoint].Mode[i_of_mode];
|
||||
Eigen::Matrix3d raman_tensor = (config.Susceptibility[i_of_qpoint][i_of_mode] - config.OriginalSusceptibility)
|
||||
/ ratio / raman_input.MaxDisplacement;
|
||||
_.RamanTensor = raman_tensor | biu::fromEigen;
|
||||
_.WeightOnRaman = config.Polarization[0].transpose() * raman_tensor * config.Polarization[1];
|
||||
log.info("{}:{:.2f}:{}:{:.2f} {}"_f
|
||||
(
|
||||
mode.QpointIndex, fmt::join(cell.Qpoint[mode.QpointIndex].Qpoint, ", "),
|
||||
mode.ModeIndex, _.Frequency, *_.WeightOnRaman
|
||||
i_of_qpoint, fmt::join(cell.Qpoint[i_of_qpoint].Qpoint, ", "),
|
||||
i_of_mode, _.Frequency, *_.WeightOnRaman
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,78 +3,107 @@ OriginalSusceptibility:
|
||||
- [ -3.4e-05, 7.002539, -2.4e-05 ]
|
||||
- [ -3e-06, -1.2e-05, 7.303458 ]
|
||||
Susceptibility:
|
||||
- - [ 7.006379, -5e-06, -2e-06 ]
|
||||
- [ -1.6e-05, 7.002547, -3e-05 ]
|
||||
- [ -1.1e-05, -6e-06, 7.303627 ]
|
||||
- - [ 7.007683, 5e-06, -5.3e-05 ]
|
||||
- [ -0, 7.003913, 5e-06 ]
|
||||
- [ -4e-05, 2.8e-05, 7.307388 ]
|
||||
- - [ 7.018886, 1.8e-05, -5e-05 ]
|
||||
- [ 2.7e-05, 7.015141, -3e-05 ]
|
||||
- [ -5e-05, -1.7e-05, 7.307471 ]
|
||||
- - [ 7.008862, 4.9e-05, -8.8e-05 ]
|
||||
- [ 4.8e-05, 7.011172, -0.00086 ]
|
||||
- [ -7.8e-05, -0.000845, 7.305162 ]
|
||||
- - [ 7.015066, -4.3e-05, -0.000838 ]
|
||||
- [ -4.5e-05, 7.005147, -2.9e-05 ]
|
||||
- [ -0.000841, -9e-06, 7.305197 ]
|
||||
- - [ 6.981143, 1.4e-05, -5.8e-05 ]
|
||||
- [ 1.1e-05, 7.038724, 4.3e-05 ]
|
||||
- [ -5.7e-05, 5.9e-05, 7.306158 ]
|
||||
- - [ 7.014582, -0.027613, 1.6e-05 ]
|
||||
- [ -0.027632, 7.005279, -7.1e-05 ]
|
||||
- [ 4e-06, -6.7e-05, 7.306158 ]
|
||||
- - [ 7.032791, 2.6e-05, -4.1e-05 ]
|
||||
- [ 3.2e-05, 7.028882, -1.7e-05 ]
|
||||
- [ -3.6e-05, -2e-06, 7.250185 ]
|
||||
- - [ 7.007262, 1.3e-05, 1.3e-05 ]
|
||||
- [ 9e-06, 7.013971, -5.9e-05 ]
|
||||
- [ 7e-06, -4.6e-05, 7.305084 ]
|
||||
- - [ 7.015281, 0.002384, -0 ]
|
||||
- [ 0.002373, 7.005685, -4.4e-05 ]
|
||||
- [ -4e-06, -2.8e-05, 7.3058 ]
|
||||
- - [ 7.017108, 0.000122, -0.023832 ]
|
||||
- [ 0.00013, 7.006382, -5.6e-05 ]
|
||||
- [ -0.02384, -3.4e-05, 7.306937 ]
|
||||
- - [ 7.006331, 7e-06, 1.6e-05 ]
|
||||
- [ 2e-06, 7.002539, -1.9e-05 ]
|
||||
- [ 1.7e-05, -3e-06, 7.303612 ]
|
||||
- - [ 7.010335, 7.8e-05, -4.6e-05 ]
|
||||
- [ 8.4e-05, 7.013598, 0.023664 ]
|
||||
- [ -4.1e-05, 0.023683, 7.307236 ]
|
||||
- - [ 7.008517, 2.9e-05, -1.6e-05 ]
|
||||
- [ 2.5e-05, 7.004613, -9.3e-05 ]
|
||||
- [ -1.8e-05, -7.1e-05, 7.324773 ]
|
||||
- - [ 7.012128, 1e-05, 1.8e-05 ]
|
||||
- [ 1e-06, 7.008401, -1e-05 ]
|
||||
- [ 1.3e-05, -1e-06, 7.322152 ]
|
||||
- - [ 7.010873, -5.9e-05, -3.8e-05 ]
|
||||
- [ -7.8e-05, 7.007166, -3.6e-05 ]
|
||||
- [ -4.3e-05, -2.5e-05, 7.319279 ]
|
||||
- - [ 7.006421, -8e-06, -4e-05 ]
|
||||
- [ -1.5e-05, 7.002682, -6.7e-05 ]
|
||||
- [ -3.9e-05, -4.5e-05, 7.303477 ]
|
||||
- - [ 7.007563, -0.001516, 5e-06 ]
|
||||
- [ -0.001515, 7.00316, -5.5e-05 ]
|
||||
- [ 0, -2.9e-05, 7.305665 ]
|
||||
- - [ 7.005528, 1.8e-05, 4.1e-05 ]
|
||||
- [ 1.2e-05, 7.005511, -3.7e-05 ]
|
||||
- [ 3.7e-05, -1.5e-05, 7.30606 ]
|
||||
- - [ 7.011048, 8e-05, -2.7e-05 ]
|
||||
- [ 8.6e-05, 7.000001, 6e-06 ]
|
||||
- [ -2.6e-05, 4.1e-05, 7.30555 ]
|
||||
- - [ 7.00768, 0.004054, 1e-06 ]
|
||||
- [ 0.004046, 7.003291, -4e-05 ]
|
||||
- [ -1e-06, -1.7e-05, 7.305554 ]
|
||||
- - [ 7.010948, -8.3e-05, -0.007718 ]
|
||||
- [ -8e-05, 7.004814, -3.4e-05 ]
|
||||
- [ -0.00772, -1.5e-05, 7.3101 ]
|
||||
- - [ 7.008787, 7.2e-05, -1.8e-05 ]
|
||||
- [ 7.4e-05, 7.007313, 0.007694 ]
|
||||
- [ -2.4e-05, 0.007696, 7.310191 ]
|
||||
- - [ 7.007532, -4.7e-05, -6e-06 ]
|
||||
- [ -4.8e-05, 7.003828, -9e-06 ]
|
||||
- [ -4e-06, 4e-06, 7.307759 ]
|
||||
0:
|
||||
0:
|
||||
- [ 7.006379, -5e-06, -2e-06 ]
|
||||
- [ -1.6e-05, 7.002547, -3e-05 ]
|
||||
- [ -1.1e-05, -6e-06, 7.303627 ]
|
||||
1:
|
||||
- [ 7.006331, 7e-06, 1.6e-05 ]
|
||||
- [ 2e-06, 7.002539, -1.9e-05 ]
|
||||
- [ 1.7e-05, -3e-06, 7.303612 ]
|
||||
10:
|
||||
- [ 7.00768, 0.004054, 1e-06 ]
|
||||
- [ 0.004046, 7.003291, -4e-05 ]
|
||||
- [ -1e-06, -1.7e-05, 7.305554 ]
|
||||
107:
|
||||
- [ 7.007532, -4.7e-05, -6e-06 ]
|
||||
- [ -4.8e-05, 7.003828, -9e-06 ]
|
||||
- [ -4e-06, 4e-06, 7.307759 ]
|
||||
115:
|
||||
- [ 7.007683, 5e-06, -5.3e-05 ]
|
||||
- [ -0, 7.003913, 5e-06 ]
|
||||
- [ -4e-05, 2.8e-05, 7.307388 ]
|
||||
15:
|
||||
- [ 7.010948, -8.3e-05, -0.007718 ]
|
||||
- [ -8e-05, 7.004814, -3.4e-05 ]
|
||||
- [ -0.00772, -1.5e-05, 7.3101 ]
|
||||
16:
|
||||
- [ 7.008787, 7.2e-05, -1.8e-05 ]
|
||||
- [ 7.4e-05, 7.007313, 0.007694 ]
|
||||
- [ -2.4e-05, 0.007696, 7.310191 ]
|
||||
185:
|
||||
- [ 7.018886, 1.8e-05, -5e-05 ]
|
||||
- [ 2.7e-05, 7.015141, -3e-05 ]
|
||||
- [ -5e-05, -1.7e-05, 7.307471 ]
|
||||
2:
|
||||
- [ 7.006421, -8e-06, -4e-05 ]
|
||||
- [ -1.5e-05, 7.002682, -6.7e-05 ]
|
||||
- [ -3.9e-05, -4.5e-05, 7.303477 ]
|
||||
251:
|
||||
- [ 7.008862, 4.9e-05, -8.8e-05 ]
|
||||
- [ 4.8e-05, 7.011172, -0.00086 ]
|
||||
- [ -7.8e-05, -0.000845, 7.305162 ]
|
||||
252:
|
||||
- [ 7.015066, -4.3e-05, -0.000838 ]
|
||||
- [ -4.5e-05, 7.005147, -2.9e-05 ]
|
||||
- [ -0.000841, -9e-06, 7.305197 ]
|
||||
281:
|
||||
- [ 6.981143, 1.4e-05, -5.8e-05 ]
|
||||
- [ 1.1e-05, 7.038724, 4.3e-05 ]
|
||||
- [ -5.7e-05, 5.9e-05, 7.306158 ]
|
||||
282:
|
||||
- [ 7.014582, -0.027613, 1.6e-05 ]
|
||||
- [ -0.027632, 7.005279, -7.1e-05 ]
|
||||
- [ 4e-06, -6.7e-05, 7.306158 ]
|
||||
287:
|
||||
- [ 7.032791, 2.6e-05, -4.1e-05 ]
|
||||
- [ 3.2e-05, 7.028882, -1.7e-05 ]
|
||||
- [ -3.6e-05, -2e-06, 7.250185 ]
|
||||
292:
|
||||
- [ 7.007262, 1.3e-05, 1.3e-05 ]
|
||||
- [ 9e-06, 7.013971, -5.9e-05 ]
|
||||
- [ 7e-06, -4.6e-05, 7.305084 ]
|
||||
293:
|
||||
- [ 7.015281, 0.002384, -0 ]
|
||||
- [ 0.002373, 7.005685, -4.4e-05 ]
|
||||
- [ -4e-06, -2.8e-05, 7.3058 ]
|
||||
311:
|
||||
- [ 7.017108, 0.000122, -0.023832 ]
|
||||
- [ 0.00013, 7.006382, -5.6e-05 ]
|
||||
- [ -0.02384, -3.4e-05, 7.306937 ]
|
||||
312:
|
||||
- [ 7.010335, 7.8e-05, -4.6e-05 ]
|
||||
- [ 8.4e-05, 7.013598, 0.023664 ]
|
||||
- [ -4.1e-05, 0.023683, 7.307236 ]
|
||||
327:
|
||||
- [ 7.008517, 2.9e-05, -1.6e-05 ]
|
||||
- [ 2.5e-05, 7.004613, -9.3e-05 ]
|
||||
- [ -1.8e-05, -7.1e-05, 7.324773 ]
|
||||
378:
|
||||
- [ 7.012128, 1e-05, 1.8e-05 ]
|
||||
- [ 1e-06, 7.008401, -1e-05 ]
|
||||
- [ 1.3e-05, -1e-06, 7.322152 ]
|
||||
379:
|
||||
- [ 7.010873, -5.9e-05, -3.8e-05 ]
|
||||
- [ -7.8e-05, 7.007166, -3.6e-05 ]
|
||||
- [ -4.3e-05, -2.5e-05, 7.319279 ]
|
||||
5:
|
||||
- [ 7.007563, -0.001516, 5e-06 ]
|
||||
- [ -0.001515, 7.00316, -5.5e-05 ]
|
||||
- [ 0, -2.9e-05, 7.305665 ]
|
||||
6:
|
||||
- [ 7.005528, 1.8e-05, 4.1e-05 ]
|
||||
- [ 1.2e-05, 7.005511, -3.7e-05 ]
|
||||
- [ 3.7e-05, -1.5e-05, 7.30606 ]
|
||||
9:
|
||||
- [ 7.011048, 8e-05, -2.7e-05 ]
|
||||
- [ 8.6e-05, 7.000001, 6e-06 ]
|
||||
- [ -2.6e-05, 4.1e-05, 7.30555 ]
|
||||
origin:
|
||||
- [ 7.006328, -3.3e-05, -2e-06 ]
|
||||
- [ -3.4e-05, 7.002539, -2.4e-05 ]
|
||||
- [ -3e-06, -1.2e-05, 7.303458 ]
|
||||
Polarization:
|
||||
- [ 0, 1, 0 ]
|
||||
- [ 0, 1, 0 ]
|
||||
|
||||
Reference in New Issue
Block a user