add unfold test

This commit is contained in:
2024-12-02 18:27:40 +08:00
parent db1d3befd6
commit 7b4ea3bbf3
10 changed files with 34 additions and 5 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*.hdf5 filter=lfs diff=lfs merge=lfs -text

View File

@@ -32,5 +32,5 @@ message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}")
message("CMake build type: ${CMAKE_BUILD_TYPE}") message("CMake build type: ${CMAKE_BUILD_TYPE}")
include(CTest) include(CTest)
add_test(NAME fold COMMAND ufo fold ${PROJECT_SOURCE_DIR}/test/fold/config.yaml) add_test(NAME fold WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/fold COMMAND ufo fold config.yaml)
add_test(NAME unfold WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test/unfold COMMAND ufo unfold config.yaml)

View File

@@ -27,8 +27,8 @@ void ufo::unfold(std::string config_file)
// PositionToSuperCell(line vector) * SuperCell = PositionToPrimativeCell(line vector) * PrimativeCell // PositionToSuperCell(line vector) * SuperCell = PositionToPrimativeCell(line vector) * PrimativeCell
// ReciprocalPositionToSuperCell(line vector) * ReciprocalSuperCell // ReciprocalPositionToSuperCell(line vector) * ReciprocalSuperCell
// = ReciprocalPositionToPrimativeCell(line vector) * ReciprocalPrimativeCell // = ReciprocalPositionToPrimativeCell(line vector) * ReciprocalPrimativeCell
Eigen::Matrix3d SuperCellDeformation;
Eigen::Vector3i SuperCellMultiplier; Eigen::Vector3i SuperCellMultiplier;
Eigen::Matrix3d SuperCellDeformation;
// 在单胞内取几个平面波的基矢 // 在单胞内取几个平面波的基矢
Eigen::Vector<std::size_t, 3> PrimativeCellBasisNumber; Eigen::Vector<std::size_t, 3> PrimativeCellBasisNumber;
@@ -49,6 +49,8 @@ void ufo::unfold(std::string config_file)
// 返回值为原子类型和原子质量的对应关系 // 返回值为原子类型和原子质量的对应关系
auto read_qpoint = [](std::string phonopy_file, std::string qpoint_file, auto& data) auto read_qpoint = [](std::string phonopy_file, std::string qpoint_file, auto& data)
{ {
biu::Logger::Guard log(phonopy_file, qpoint_file, data);
// phonopy 的输出有两种可能。 // phonopy 的输出有两种可能。
// 直接指定计算的 q 点时frequency 是 2 维,这时第一个维度是 q 点,第二个维度是不同模式。 // 直接指定计算的 q 点时frequency 是 2 维,这时第一个维度是 q 点,第二个维度是不同模式。
// 计算能带时frequency 是 3 维,相比于二维的情况多了第一个维度,表示 q 点所在路径。 // 计算能带时frequency 是 3 维,相比于二维的情况多了第一个维度,表示 q 点所在路径。
@@ -100,8 +102,8 @@ void ufo::unfold(std::string config_file)
// 读取并写入其它数据 // 读取并写入其它数据
YAML::Node phonopy = YAML::LoadFile(phonopy_file); YAML::Node phonopy = YAML::LoadFile(phonopy_file);
data.Cell = phonopy["unit_cell"]["lattice"].as<std::array<std::array<double, 3>, 3>>() | biu::toEigen<>; data.Cell = phonopy["unit_cell"]["lattice"].as<Eigen::Matrix3d>();
auto points = phonopy["points"].as<std::vector<YAML::Node>>(); auto points = phonopy["unit_cell"]["points"].as<std::vector<YAML::Node>>();
data.AtomType = points data.AtomType = points
| ranges::views::transform([](const YAML::Node& point) { return point["symbol"].as<std::string>(); }) | ranges::views::transform([](const YAML::Node& point) { return point["symbol"].as<std::string>(); })
| ranges::views::chunk_by(std::ranges::equal_to{}) | ranges::views::chunk_by(std::ranges::equal_to{})

1
test/unfold/.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
*phonopy.yaml filter=lfs diff=lfs merge=lfs -text

1
test/unfold/.gitignore vendored Normal file
View File

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

12
test/unfold/config.yaml Normal file
View File

@@ -0,0 +1,12 @@
SuperCellMultiplier: [4, 4, 1]
SuperCellDeformation:
- [ 1, 0, 0 ]
- [ 0.5, 1, 0 ]
- [ 0, 0, 1 ]
PrimativeCellBasisNumber: [ 8, 8, 8 ]
PrimativePhonopy: primitive-phonopy.yaml
PrimativeQpoint: primitive-band.hdf5
SuperPhonopy: super-phonopy.yaml
SuperQpoint: super-qpoints.hdf5
OutputFile: unfold-output.zpp

BIN
test/unfold/primitive-band.hdf5 LFS Normal file

Binary file not shown.

Binary file not shown.

BIN
test/unfold/super-phonopy.yaml LFS Normal file

Binary file not shown.

BIN
test/unfold/super-qpoints.hdf5 LFS Normal file

Binary file not shown.