diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..0820b3d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.hdf5 filter=lfs diff=lfs merge=lfs -text diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f05f91..f1eed6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,5 +32,5 @@ message("List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}") message("CMake build type: ${CMAKE_BUILD_TYPE}") 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) diff --git a/src/unfold.cpp b/src/unfold.cpp index bd3128c..f0767df 100644 --- a/src/unfold.cpp +++ b/src/unfold.cpp @@ -27,8 +27,8 @@ void ufo::unfold(std::string config_file) // PositionToSuperCell(line vector) * SuperCell = PositionToPrimativeCell(line vector) * PrimativeCell // ReciprocalPositionToSuperCell(line vector) * ReciprocalSuperCell // = ReciprocalPositionToPrimativeCell(line vector) * ReciprocalPrimativeCell - Eigen::Matrix3d SuperCellDeformation; Eigen::Vector3i SuperCellMultiplier; + Eigen::Matrix3d SuperCellDeformation; // 在单胞内取几个平面波的基矢 Eigen::Vector 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) { + biu::Logger::Guard log(phonopy_file, qpoint_file, data); + // phonopy 的输出有两种可能。 // 直接指定计算的 q 点时,frequency 是 2 维,这时第一个维度是 q 点,第二个维度是不同模式。 // 计算能带时,frequency 是 3 维,相比于二维的情况多了第一个维度,表示 q 点所在路径。 @@ -100,8 +102,8 @@ void ufo::unfold(std::string config_file) // 读取并写入其它数据 YAML::Node phonopy = YAML::LoadFile(phonopy_file); - data.Cell = phonopy["unit_cell"]["lattice"].as, 3>>() | biu::toEigen<>; - auto points = phonopy["points"].as>(); + data.Cell = phonopy["unit_cell"]["lattice"].as(); + auto points = phonopy["unit_cell"]["points"].as>(); data.AtomType = points | ranges::views::transform([](const YAML::Node& point) { return point["symbol"].as(); }) | ranges::views::chunk_by(std::ranges::equal_to{}) diff --git a/test/unfold/.gitattributes b/test/unfold/.gitattributes new file mode 100644 index 0000000..15f4758 --- /dev/null +++ b/test/unfold/.gitattributes @@ -0,0 +1 @@ +*phonopy.yaml filter=lfs diff=lfs merge=lfs -text diff --git a/test/unfold/.gitignore b/test/unfold/.gitignore new file mode 100644 index 0000000..03d5ccf --- /dev/null +++ b/test/unfold/.gitignore @@ -0,0 +1 @@ +unfold-output.zpp \ No newline at end of file diff --git a/test/unfold/config.yaml b/test/unfold/config.yaml new file mode 100644 index 0000000..e6e2ef4 --- /dev/null +++ b/test/unfold/config.yaml @@ -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 + diff --git a/test/unfold/primitive-band.hdf5 b/test/unfold/primitive-band.hdf5 new file mode 100644 index 0000000..730cc36 --- /dev/null +++ b/test/unfold/primitive-band.hdf5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef2ef96ef3ee206f207f12b806576e2849cbe16a5d22ab6953448234160df8d5 +size 489680 diff --git a/test/unfold/primitive-phonopy.yaml b/test/unfold/primitive-phonopy.yaml new file mode 100644 index 0000000..30baceb --- /dev/null +++ b/test/unfold/primitive-phonopy.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c63b83fc670851ddc81c6e8472d899ac0bd12e2de1054f90855f40287dd31321 +size 12575 diff --git a/test/unfold/super-phonopy.yaml b/test/unfold/super-phonopy.yaml new file mode 100644 index 0000000..3734268 --- /dev/null +++ b/test/unfold/super-phonopy.yaml @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:09182492273390c4e3085ee57147f55a9e3d938d221cca5e7ab03b0ab976e621 +size 52474 diff --git a/test/unfold/super-qpoints.hdf5 b/test/unfold/super-qpoints.hdf5 new file mode 100644 index 0000000..2b87f74 --- /dev/null +++ b/test/unfold/super-qpoints.hdf5 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:762a81b4ac321b39253105e691d26b19ba98dd3c7069637c368a51a41ef85f2b +size 2364440