fix raman, add test

This commit is contained in:
2024-12-04 15:16:49 +08:00
parent 6e64054ffc
commit d584951fd7
35 changed files with 192 additions and 4 deletions

View File

@@ -40,3 +40,13 @@ add_test(NAME zpp-to-yaml WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/zpp-to-ya
COMMAND sh -c "${CMAKE_BINARY_DIR}/ufo zpp-to-yaml < data.zpp > data.yaml")
add_test(NAME project-to-mode WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/project-to-mode
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)
add_test(NAME raman-apply-contribution WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/raman-apply-contribution
COMMAND ufo raman-apply-contribution config.yaml)

View File

@@ -24,7 +24,7 @@ namespace ufo
{
// 要计算的是原胞还是超胞
decltype(RamanData::Cell) Cell;
// 要计算模式,总是假定是 gamma 点的模式
// 要计算哪个 q 点的哪些模式,总是假定是 gamma 点的模式
std::map<std::size_t, std::set<std::size_t>> SelectedModes;
// 原子最大位移大小,单位为埃
double MaxDisplacement;
@@ -109,7 +109,7 @@ namespace ufo
else process(input.Super);
std::filesystem::create_directories("{}/{}"_f(config.OutputPoscarDirectory, "origin"));
std::ofstream("{}/origin/POSCAR"_f(config.OutputDataFile)) << generate_poscar
std::ofstream("{}/origin/POSCAR"_f(config.OutputPoscarDirectory)) << generate_poscar
(input.Super.Cell, input.Super.AtomPosition, input.Super.AtomType);
std::ofstream(config.OutputDataFile, std::ios::binary) << biu::serialize<char>(output);
}
@@ -160,7 +160,7 @@ R"(- - [ {}, {}, {} ]
struct Config
{
Eigen::Matrix3d OriginalSusceptibility;
std::vector<Eigen::Matrix3d> Susceptibilities;
std::vector<Eigen::Matrix3d> Susceptibility;
std::array<Eigen::Vector3d, 2> Polarization;
std::string InputDataFile;
std::string RamanInputDataFile;
@@ -180,7 +180,7 @@ R"(- - [ {}, {}, {} ]
for (auto&& [i_of_mode, mode] : ranges::views::enumerate(raman_input.Mode))
{
auto&& _ = cell.Qpoint[mode.QpointIndex].Mode[mode.ModeIndex];
Eigen::Matrix3d raman_tensor = (config.Susceptibilities[i_of_mode] - config.OriginalSusceptibility)
Eigen::Matrix3d raman_tensor = (config.Susceptibility[i_of_mode] - config.OriginalSusceptibility)
/ mode.Ratio / raman_input.MaxDisplacement;
_.RamanTensor = raman_tensor | biu::fromEigen;
_.WeightOnRaman = config.Polarization[0].transpose() * raman_tensor * config.Polarization[1];

View File

@@ -0,0 +1 @@
output.zpp

View File

@@ -0,0 +1,83 @@
OriginalSusceptibility:
- [ 7.006328, -3.3e-05, -2e-06 ]
- [ -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 ]
Polarization:
- [ 0, 1, 0 ]
- [ 0, 1, 0 ]
InputDataFile: data.zpp
RamanInputDataFile: raman.zpp
OutputDataFile: output.zpp

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,2 @@
POSCAR
output.zpp

View File

@@ -0,0 +1,7 @@
Cell: Super
SelectedModes:
0: [ 0, 1, 2, 5, 6, 9, 10, 15, 16, 107, 115, 185, 251, 252, 281, 282, 287, 292, 293, 311, 312, 327, 378, 379 ]
MaxDisplacement: 0.02
OutputPoscarDirectory: POSCAR
InputDataFile: data.zpp
OutputDataFile: output.zpp

Binary file not shown.

1
test/raman-extract/job/.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
OUTCAR filter=lfs diff=lfs merge=lfs -text

BIN
test/raman-extract/job/0/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/1/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/10/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/11/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/12/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/13/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/14/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/15/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/16/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/17/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/18/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/19/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/2/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/20/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/21/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/22/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/23/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/3/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/4/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/5/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/6/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/7/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/8/OUTCAR LFS Normal file

Binary file not shown.

BIN
test/raman-extract/job/9/OUTCAR LFS Normal file

Binary file not shown.

Binary file not shown.