From f22529e147315314c7a98cb9575219683ecaf561 Mon Sep 17 00:00:00 2001 From: Brent Westbrook <36778786+ntBre@users.noreply.github.com> Date: Sun, 1 Dec 2024 22:32:09 -0500 Subject: [PATCH] Print full list of vibrational states (#315) * Bump git2 from 0.18.3 to 0.19.0 Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.18.3 to 0.19.0. - [Changelog](https://github.com/rust-lang/git2-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/git2-rs/compare/git2-0.18.3...git2-0.19.0) --- updated-dependencies: - dependency-name: git2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Bump clap from 4.5.12 to 4.5.20 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.12 to 4.5.20. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.12...clap_complete-v4.5.20) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Bump serde_json from 1.0.121 to 1.0.132 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.121 to 1.0.132. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.121...1.0.132) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Bump nalgebra from 0.33.0 to 0.33.2 Bumps [nalgebra](https://github.com/dimforge/nalgebra) from 0.33.0 to 0.33.2. - [Changelog](https://github.com/dimforge/nalgebra/blob/main/CHANGELOG.md) - [Commits](https://github.com/dimforge/nalgebra/commits/v0.33.2) --- updated-dependencies: - dependency-name: nalgebra dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * bump spectro * set verbose to true to get full vibrational state output * use die macro * add assert_cmd and insta and add basic assert_cmd test for cart * add cart snapshot * update snapshot to ignore PID * redact numerical results from cart snapshot * use insta for config tests * use test_case for config tests * use local queue in normal.toml, set insta suffixes to get reproducible ordering of snapshots * add cart config case, update test.toml description to reflect sic * move sic template to local queue * add norm.toml as copy of normal without resume_hff, parameterize run to cover the other coordinate types * catch missing verbose for normals thanks snapshot tests * add new snapshots * redact version and anpass residuals * handle sic-specific redactions to make sure states are there * set threads to 1 for run tests, debugging github hanging forever * test threads 1 * too many dashes * nocapture for more debugging hang * also copy shared library how has this been working so far?? * suffix * deleted cache, update paths * revert github debugging, mopac path was the problem * give up on caching, download binary release * fix curl flags * set -xe on mopac install * nocapture to debug again * more debugging, can't find libmopac.so.2 * apparently we need even more .so files --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 34 ++- Cargo.lock | 217 ++++++++++++++++-- Cargo.toml | 11 +- ...sts__load_config@testfiles__cart.toml.snap | 27 +++ ...s__load_config@testfiles__normal.toml.snap | 27 +++ ...sts__load_config@testfiles__path.toml.snap | 27 +++ ...sts__load_config@testfiles__test.toml.snap | 27 +++ src/config/tests.rs | 126 +--------- src/coord_type/cart.rs | 1 + src/coord_type/normal.rs | 1 + src/coord_type/sic.rs | 1 + src/main.rs | 11 +- testfiles/cart.toml | 2 +- testfiles/norm.toml | 20 ++ testfiles/normal.toml | 2 +- testfiles/test.toml | 2 +- tests/run.rs | 56 +++++ .../run__run@testfiles__cart.toml.snap | 45 ++++ .../run__run@testfiles__norm.toml.snap | 41 ++++ .../run__run@testfiles__test.toml.snap | 97 ++++++++ 20 files changed, 599 insertions(+), 176 deletions(-) create mode 100644 src/config/snapshots/pbqff__config__tests__load_config@testfiles__cart.toml.snap create mode 100644 src/config/snapshots/pbqff__config__tests__load_config@testfiles__normal.toml.snap create mode 100644 src/config/snapshots/pbqff__config__tests__load_config@testfiles__path.toml.snap create mode 100644 src/config/snapshots/pbqff__config__tests__load_config@testfiles__test.toml.snap create mode 100644 testfiles/norm.toml create mode 100644 tests/run.rs create mode 100644 tests/snapshots/run__run@testfiles__cart.toml.snap create mode 100644 tests/snapshots/run__run@testfiles__norm.toml.snap create mode 100644 tests/snapshots/run__run@testfiles__test.toml.snap diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa35e7d..a9d3f8c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,35 +18,27 @@ jobs: - uses: actions/checkout@v4 with: submodules: true + - name: Install ${{ matrix.toolchain }} uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} + - name: cargo generate-lockfile if: hashFiles('Cargo.lock') == '' run: cargo generate-lockfile - - name: Cache mopac - id: cache-mopac - uses: actions/cache@v4 - with: - path: | - mopac/build/mopac - mopac/build/libmopac.so.1 - key: ${{ runner.os }}-build-mopac + - name: install mopac - if: steps.cache-mopac.outputs.cache-hit != 'true' - run: | - sudo apt install -y python3 python3-numpy - git clone https://github.com/openmopac/mopac.git - cd mopac - mkdir build - cd build - cmake .. - make - - name: copy over mopac run: | + set -xe + curl -OL https://github.com/openmopac/mopac/releases/download/v23.0.2/mopac-23.0.2-linux.tar.gz + gunzip mopac-23.0.2-linux.tar.gz + tar xf mopac-23.0.2-linux.tar mkdir -p /opt/mopac - cp mopac/build/mopac /opt/mopac/. - # https://twitter.com/jonhoo/status/1571290371124260865 + cp mopac-23.0.2-linux/bin/mopac /opt/mopac/. + cp mopac-23.0.2-linux/lib/*.so* /opt/mopac/. + ls /opt/mopac + ldd /opt/mopac/mopac + - name: cargo test --locked - run: cargo test --locked --all-features --all-targets -- --include-ignored + run: cargo test --locked --all-features --all-targets -- --include-ignored --nocapture diff --git a/Cargo.lock b/Cargo.lock index 92d2386..86d1483 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,6 +84,22 @@ dependencies = [ "num-traits", ] +[[package]] +name = "assert_cmd" +version = "2.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1835b7f27878de8525dc71410b5a31cdcc5f230aed5ba5df968e09c201b23d" +dependencies = [ + "anstyle", + "bstr", + "doc-comment", + "libc", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + [[package]] name = "autocfg" version = "1.3.0" @@ -96,6 +112,17 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +[[package]] +name = "bstr" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a68f1f47cdf0ec8ee4b941b2eee2a80cb796db73118c0dd09ac63fbe405be22" +dependencies = [ + "memchr", + "regex-automata", + "serde", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -140,9 +167,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.12" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c53aa12ec67affac065e7c7dd20a42fa2a4094921b655711d5d3107bb3d52bed" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", "clap_derive", @@ -150,9 +177,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.12" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbdf2dd5fe10889e0c61942ff5d948aaf12fd0b4504408ab0cbb1916c2cffa9" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -162,9 +189,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.11" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", @@ -184,6 +211,18 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +[[package]] +name = "console" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "windows-sys", +] + [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -215,12 +254,30 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "either" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + [[package]] name = "env_filter" version = "0.1.2" @@ -262,9 +319,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "form_urlencoded" @@ -277,9 +334,9 @@ dependencies = [ [[package]] name = "git2" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" +checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" dependencies = [ "bitflags", "libc", @@ -351,6 +408,19 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "insta" +version = "1.41.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9ffc4d4892617c50a928c52b2961cb5174b6fc6ebf252b2fac9d21955c48b8" +dependencies = [ + "console", + "lazy_static", + "linked-hash-map", + "regex", + "similar", +] + [[package]] name = "intder" version = "0.1.0" @@ -395,17 +465,23 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + [[package]] name = "libc" -version = "0.2.155" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libgit2-sys" -version = "0.16.2+1.7.2" +version = "0.17.0+1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" +checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" dependencies = [ "cc", "libc", @@ -441,6 +517,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -471,9 +553,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "nalgebra" -version = "0.33.0" +version = "0.33.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c4b5f057b303842cf3262c27e465f4c303572e7f6b0648f60e16248ac3397f4" +checksum = "26aecdf64b707efd1310e3544d709c5c0ac61c13756046aaaba41be5c4f66a3b" dependencies = [ "approx", "matrixmultiply", @@ -595,9 +677,11 @@ name = "pbqff" version = "0.1.0" dependencies = [ "approx", + "assert_cmd", "clap", "env_logger", "git2", + "insta", "intder", "libc", "log", @@ -611,6 +695,7 @@ dependencies = [ "symm", "taylor", "tempfile", + "test-case", "toml", ] @@ -626,6 +711,33 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +[[package]] +name = "predicates" +version = "3.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" +dependencies = [ + "anstyle", + "difflib", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" + +[[package]] +name = "predicates-tree" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -731,9 +843,9 @@ checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags", "errno", @@ -779,9 +891,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.121" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -811,10 +923,16 @@ dependencies = [ "wide", ] +[[package]] +name = "similar" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e" + [[package]] name = "spectro" version = "0.1.0" -source = "git+https://github.com/ntBre/spectro#afc966226d7eb42710865650cf986823646735af" +source = "git+https://github.com/ntBre/spectro#6294c673587cfcb4f4229a64781c1b8b1139a4a1" dependencies = [ "log", "nalgebra", @@ -833,7 +951,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "symm" version = "0.1.0" -source = "git+https://github.com/ntBre/symm#39161c959507d4216967ed85b282c664c88bd19a" +source = "git+https://github.com/ntBre/symm#e87c30859f4fc0d02269330230f39a474235afd2" dependencies = [ "approx", "nalgebra", @@ -864,12 +982,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", "windows-sys", ] @@ -877,11 +996,50 @@ dependencies = [ [[package]] name = "tensor" version = "0.1.0" -source = "git+https://github.com/ntBre/tensor#fa7d3b8f84d6cf5d2b89728de25dc5d8ebe43d12" +source = "git+https://github.com/ntBre/tensor#b7331cbf697d51ce7fbf8d41de55229f0cfeaa77" dependencies = [ "approx", ] +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + +[[package]] +name = "test-case" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2550dd13afcd286853192af8601920d959b14c401fcece38071d53bf0768a8" +dependencies = [ + "test-case-macros", +] + +[[package]] +name = "test-case-core" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcb7fd841cd518e279be3d5a3eb0636409487998a4aff22f3de87b81e88384f" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "test-case-macros" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "test-case-core", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -981,6 +1139,15 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + [[package]] name = "wasm-bindgen" version = "0.2.92" diff --git a/Cargo.toml b/Cargo.toml index ecad2c7..5594694 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] intder = { git = "https://github.com/ntBre/intder" } libc = "0.2.155" -nalgebra = "0.33.0" +nalgebra = "0.33.2" psqs = { git = "https://github.com/ntBre/psqs" } rust-anpass = { git = "https://github.com/ntBre/rust-anpass" } serde_json = "1.0" @@ -18,20 +18,23 @@ symm = { git = "https://github.com/ntBre/symm" } taylor = { git = "https://github.com/ntBre/taylor" } toml = "0.8.10" rustc-hash = "2.0.0" -clap = { version = "4.5.7", features = ["derive"] } +clap = { version = "4.5.20", features = ["derive"] } env_logger = "0.11.3" log = "0.4.22" [dev-dependencies] approx = "0.5.1" -tempfile = "3.10.0" +tempfile = "3.14.0" +assert_cmd = "2.0.16" +insta = { version = "1.41.1", features = ["filters"] } +test-case = "3.3.1" [[bin]] name = "cart" path = "src/bin/cart.rs" [build-dependencies] -git2 = { version = "0.18.2", optional = true } +git2 = { version = "0.19.0", optional = true } [features] vers = ["dep:git2"] diff --git a/src/config/snapshots/pbqff__config__tests__load_config@testfiles__cart.toml.snap b/src/config/snapshots/pbqff__config__tests__load_config@testfiles__cart.toml.snap new file mode 100644 index 0000000..dbd1ba2 --- /dev/null +++ b/src/config/snapshots/pbqff__config__tests__load_config@testfiles__cart.toml.snap @@ -0,0 +1,27 @@ +--- +source: src/config/tests.rs +expression: "Config::load(path)" +snapshot_kind: text +--- +Config { + geometry: Zmat( + "C\nC 1 CC\nC 1 CC 2 CCC\nH 2 CH 1 HCC 3 180.0\nH 3 CH 1 HCC 2 180.0\n\nCC = 1.42101898\nCCC = 55.60133141\nCH = 1.07692776\nHCC = 147.81488230\n", + ), + optimize: true, + charge: 0, + step_size: 0.005, + coord_type: Cart, + template: "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", + hybrid_template: "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", + queue_template: None, + program: Mopac, + queue: Local, + sleep_int: 2, + job_limit: 2048, + chunk_size: 1, + findiff: false, + check_int: 100, + weights: None, + dummy_atoms: None, + norm_resume_hff: false, +} diff --git a/src/config/snapshots/pbqff__config__tests__load_config@testfiles__normal.toml.snap b/src/config/snapshots/pbqff__config__tests__load_config@testfiles__normal.toml.snap new file mode 100644 index 0000000..b6250d9 --- /dev/null +++ b/src/config/snapshots/pbqff__config__tests__load_config@testfiles__normal.toml.snap @@ -0,0 +1,27 @@ +--- +source: src/config/tests.rs +expression: "Config::load(path)" +snapshot_kind: text +--- +Config { + geometry: Zmat( + "O\nH 1 OH\nH 1 OH 2 HOH\n\nOH = 1.0\nHOH = 109.5\n", + ), + optimize: true, + charge: 0, + step_size: 0.005, + coord_type: Normal, + template: "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", + hybrid_template: "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", + queue_template: None, + program: Mopac, + queue: Local, + sleep_int: 2, + job_limit: 2048, + chunk_size: 1, + findiff: false, + check_int: 0, + weights: None, + dummy_atoms: None, + norm_resume_hff: true, +} diff --git a/src/config/snapshots/pbqff__config__tests__load_config@testfiles__path.toml.snap b/src/config/snapshots/pbqff__config__tests__load_config@testfiles__path.toml.snap new file mode 100644 index 0000000..4a96214 --- /dev/null +++ b/src/config/snapshots/pbqff__config__tests__load_config@testfiles__path.toml.snap @@ -0,0 +1,27 @@ +--- +source: src/config/tests.rs +expression: "Config::load(path)" +snapshot_kind: text +--- +Config { + geometry: Zmat( + "C\nC 1 CC\nC 1 CC 2 CCC\nH 2 CH 1 HCC 3 180.0\nH 3 CH 1 HCC 2 180.0\n\nCC = 1.42101898\nCCC = 55.60133141\nCH = 1.07692776\nHCC = 147.81488230\n", + ), + optimize: true, + charge: 0, + step_size: 0.005, + coord_type: Sic, + template: "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", + hybrid_template: "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", + queue_template: None, + program: Mopac, + queue: Slurm, + sleep_int: 2, + job_limit: 2048, + chunk_size: 1, + findiff: false, + check_int: 100, + weights: None, + dummy_atoms: None, + norm_resume_hff: false, +} diff --git a/src/config/snapshots/pbqff__config__tests__load_config@testfiles__test.toml.snap b/src/config/snapshots/pbqff__config__tests__load_config@testfiles__test.toml.snap new file mode 100644 index 0000000..c28ed4b --- /dev/null +++ b/src/config/snapshots/pbqff__config__tests__load_config@testfiles__test.toml.snap @@ -0,0 +1,27 @@ +--- +source: src/config/tests.rs +expression: "Config::load(path)" +snapshot_kind: text +--- +Config { + geometry: Zmat( + "C\nC 1 CC\nC 1 CC 2 CCC\nH 2 CH 1 HCC 3 180.0\nH 3 CH 1 HCC 2 180.0\n\nCC = 1.42101898\nCCC = 55.60133141\nCH = 1.07692776\nHCC = 147.81488230\n", + ), + optimize: true, + charge: 0, + step_size: 0.005, + coord_type: Sic, + template: "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", + hybrid_template: "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", + queue_template: None, + program: Mopac, + queue: Local, + sleep_int: 2, + job_limit: 2048, + chunk_size: 1, + findiff: false, + check_int: 100, + weights: None, + dummy_atoms: None, + norm_resume_hff: false, +} diff --git a/src/config/tests.rs b/src/config/tests.rs index a0bbe75..9f57081 100644 --- a/src/config/tests.rs +++ b/src/config/tests.rs @@ -1,118 +1,14 @@ -use super::*; - -#[test] -fn config() { - let got = Config::load("testfiles/test.toml"); - let want = Config { - geometry: psqs::geom::Geom::Zmat( - "C -C 1 CC -C 1 CC 2 CCC -H 2 CH 1 HCC 3 180.0 -H 3 CH 1 HCC 2 180.0 - -CC = 1.42101898 -CCC = 55.60133141 -CH = 1.07692776 -HCC = 147.81488230 -" - .to_string(), - ), - optimize: true, - charge: 0, - step_size: 0.005, - coord_type: CoordType::Sic, - template: String::from( - "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", - ), - program: Program::Mopac, - sleep_int: 2, - job_limit: 2048, - chunk_size: 1, - queue: Queue::Slurm, - findiff: false, - check_int: 100, - queue_template: None, - hybrid_template: String::from( - "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", - ), - weights: None, - dummy_atoms: None, - norm_resume_hff: false, - }; - assert_eq!(got, want); -} +use insta::{assert_debug_snapshot, with_settings}; +use test_case::test_case; -#[test] -fn path_template() { - let got = Config::load("testfiles/path.toml"); - let want = Config { - geometry: psqs::geom::Geom::Zmat( - "C -C 1 CC -C 1 CC 2 CCC -H 2 CH 1 HCC 3 180.0 -H 3 CH 1 HCC 2 180.0 - -CC = 1.42101898 -CCC = 55.60133141 -CH = 1.07692776 -HCC = 147.81488230 -" - .to_string(), - ), - optimize: true, - charge: 0, - step_size: 0.005, - coord_type: CoordType::Sic, - template: String::from( - "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", - ), - program: Program::Mopac, - sleep_int: 2, - job_limit: 2048, - chunk_size: 1, - queue: Queue::Slurm, - findiff: false, - check_int: 100, - queue_template: None, - hybrid_template: String::from( - "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1", - ), - weights: None, - dummy_atoms: None, - norm_resume_hff: false, - }; - assert_eq!(got, want); -} +use super::*; -#[test] -fn normal() { - let got = Config::load("testfiles/normal.toml"); - let want = Config { - geometry: psqs::geom::Geom::Zmat( - "O\nH 1 OH\nH 1 OH 2 HOH\n\nOH = 1.0\nHOH = 109.5\n".to_string(), - ), - optimize: true, - charge: 0, - step_size: 0.005, - coord_type: CoordType::Normal, - template: "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1" - .to_string(), - hybrid_template: - "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1" - .to_string(), - queue_template: None, - program: Program::Mopac, - queue: Queue::Slurm, - sleep_int: 2, - job_limit: 2048, - chunk_size: 1, - findiff: false, - check_int: 0, - weights: None, - dummy_atoms: None, - norm_resume_hff: true, - }; - assert_eq!(got, want); +#[test_case("testfiles/test.toml" ; "basic sic")] +#[test_case("testfiles/cart.toml" ; "basic cart")] +#[test_case("testfiles/normal.toml" ; "basic norm")] +#[test_case("testfiles/path.toml" ; "path templates")] +fn load_config(path: &str) { + with_settings!({ snapshot_suffix => path }, { + assert_debug_snapshot!(Config::load(path)); + }); } diff --git a/src/coord_type/cart.rs b/src/coord_type/cart.rs index 5f8599d..d877af6 100644 --- a/src/coord_type/cart.rs +++ b/src/coord_type/cart.rs @@ -85,6 +85,7 @@ pub fn freqs( mol.to_bohr(); let mut spectro = Spectro::from(mol); spectro.header = SPECTRO_HEADER.to_vec(); + spectro.verbose = true; // write input if let Some(dir) = dir { diff --git a/src/coord_type/normal.rs b/src/coord_type/normal.rs index f7592a2..d01544e 100644 --- a/src/coord_type/normal.rs +++ b/src/coord_type/normal.rs @@ -893,6 +893,7 @@ impl Normal { mol.to_bohr(); let mut spectro = Spectro::from(mol); spectro.header = SPECTRO_HEADER.to_vec(); + spectro.verbose = true; // write input if let Some(dir) = dir { diff --git a/src/coord_type/sic.rs b/src/coord_type/sic.rs index bb40155..5eda6b5 100644 --- a/src/coord_type/sic.rs +++ b/src/coord_type/sic.rs @@ -502,6 +502,7 @@ impl Sic { // spectro let mut spectro = Spectro::from(mol); spectro.header = SPECTRO_HEADER.to_vec(); + spectro.verbose = true; let fc3 = spectro::new_fc3(spectro.n3n, &f3); let fc4 = spectro::new_fc4(spectro.n3n, &f4); diff --git a/src/main.rs b/src/main.rs index fdc3c35..39a1f96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ use pbqff::{ cleanup, config::{self, Config}, coord_type::{normal::Normal, Cart, CoordType, Load, Sic}, - Intder, + die, Intder, }; use psqs::{ program::{cfour::Cfour, dftbplus::DFTBPlus, molpro::Molpro, mopac::Mopac}, @@ -66,19 +66,14 @@ fn main() -> Result<(), std::io::Error> { match serde_json::to_string(&config) { Ok(s) => println!("{}", s), Err(e) => { - eprintln!( - "failed to deserialize {infile} with {e}", - infile = args.infile - ); - std::process::exit(1); + die!("failed to deserialize {} with {e}", args.infile); } }; return Ok(()); } let path = Path::new("pbqff.out"); if path.exists() && !args.overwrite { - eprintln!("existing pbqff output. overwrite with -o/--overwrite"); - std::process::exit(1); + die!("existing pbqff output. overwrite with -o/--overwrite"); } let outfile = File::create(path).expect("failed to create outfile"); let logfile = File::create("pbqff.log").expect("failed to create log file"); diff --git a/testfiles/cart.toml b/testfiles/cart.toml index 69f6d3b..dc41117 100644 --- a/testfiles/cart.toml +++ b/testfiles/cart.toml @@ -15,7 +15,7 @@ charge = 0 step_size = 0.005 coord_type = "cart" program = "mopac" -queue = "slurm" +queue = "local" sleep_int = 2 job_limit = 2048 chunk_size = 1 diff --git a/testfiles/norm.toml b/testfiles/norm.toml new file mode 100644 index 0000000..3f1de59 --- /dev/null +++ b/testfiles/norm.toml @@ -0,0 +1,20 @@ +geometry = """ +O +H 1 OH +H 1 OH 2 HOH + +OH = 1.0 +HOH = 109.5 +""" +optimize = true +charge = 0 +step_size = 0.005 +coord_type = "norm" +norm_resume_hff = false +program = "mopac" +queue = "local" +sleep_int = 2 +job_limit = 2048 +chunk_size = 1 +template = "scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1" +check_int = 0 \ No newline at end of file diff --git a/testfiles/normal.toml b/testfiles/normal.toml index c55b2d9..fe0b583 100644 --- a/testfiles/normal.toml +++ b/testfiles/normal.toml @@ -12,7 +12,7 @@ step_size = 0.005 coord_type = "norm" norm_resume_hff = true program = "mopac" -queue = "slurm" +queue = "local" sleep_int = 2 job_limit = 2048 chunk_size = 1 diff --git a/testfiles/test.toml b/testfiles/test.toml index c6ce5e3..7ed0a7b 100644 --- a/testfiles/test.toml +++ b/testfiles/test.toml @@ -15,7 +15,7 @@ charge = 0 step_size = 0.005 coord_type = "sic" program = "mopac" -queue = "slurm" +queue = "local" sleep_int = 2 job_limit = 2048 chunk_size = 1 diff --git a/tests/run.rs b/tests/run.rs new file mode 100644 index 0000000..dacc206 --- /dev/null +++ b/tests/run.rs @@ -0,0 +1,56 @@ +use std::{fs::read_to_string, path::Path}; + +use assert_cmd::Command; +use insta::{assert_snapshot, with_settings}; +use tempfile::tempdir; +use test_case::test_case; + +#[test_case("testfiles/test.toml", &["testfiles/intder.in"]; "sic")] +#[test_case("testfiles/cart.toml", &[]; "cart")] +#[test_case("testfiles/norm.toml", &[]; "norm")] +fn run(path: &str, other_files: &[&str]) -> std::io::Result<()> { + let config_file = Path::new(path); + let dir = tempdir()?; + std::fs::copy(config_file, dir.path().join("pbqff.toml"))?; + for file in other_files { + let p = Path::new(file); + let filename = p.file_name().unwrap(); + std::fs::copy(file, dir.path().join(filename))?; + } + let mut cmd = Command::cargo_bin("pbqff").unwrap(); + let assert = cmd.arg("pbqff.toml").current_dir(&dir).assert(); + let output = assert.get_output(); + + assert!( + output.status.success(), + "stderr: {}\nlog: {}", + String::from_utf8_lossy(&output.stderr), + read_to_string(dir.path().join("pbqff.log"))?, + ); + + // filter out essentially all of the numerical results just to check that + // all of the sections are there + with_settings!({ + filters => vec![ + (r"(?m)^PID: \d+$", "PID: [PID]"), + (r"(?m)^version: [a-z0-9]+$", "version: [version]"), + (r"(?si)(normalized geometry:).*(point group)", "$1[Normalized Geometry]\n$2"), + (r"(?ms)^Normal Coordinates:.*?^$", "[Normal Coordinates]"), + (r"(?ms)^STATE NO.*?^$", "[Vibrational States]"), + (r"(?s)(Transformed Geometry \(Å\):).*(Equilibrium)", "$1\n[Transformed Geometry]\n$2"), + (r"(?ms)(Equilibrium Rotational Constants \(cm-1\):).*?^$", "$1\n[Rotational Constants]\n"), + (r"(?ms)(^Optimized Geometry:).*?$^", "$1\n[Optimized Geometry]\n$2"), + (r"(?ms)(^Refit Geometry).*?\d\n$^", "$1\n[Refit Geometry]"), + (r"(?ms)(^Geometry:).*(Vibrational)", "$1\n[Geometry]\n$2"), + (r"(?s)(Vibrational Frequencies \(cm-1\):).*?(ZPT)", "$1\n[Freqs]\n$2"), + (r"(?ms)(^Rotational Constants \(cm-1\):).*?(Coriolis Resonances)", "$1\n[Rotational Constants]\n$2"), + (r"(?m)^(anpass sum of squared residuals):(.+)$", "$1: [residual]"), + ], + snapshot_suffix => path + + }, { + assert_snapshot!(read_to_string(dir.path().join("pbqff.out")).unwrap()); + }); + + Ok(()) +} diff --git a/tests/snapshots/run__run@testfiles__cart.toml.snap b/tests/snapshots/run__run@testfiles__cart.toml.snap new file mode 100644 index 0000000..2f7b2ac --- /dev/null +++ b/tests/snapshots/run__run@testfiles__cart.toml.snap @@ -0,0 +1,45 @@ +--- +source: tests/run.rs +expression: "read_to_string(dir.path().join(\"pbqff.out\")).unwrap()" +snapshot_kind: text +--- +PID: [PID] +version: [version] +normalized geometry:[Normalized Geometry] +point group:C2v(Axis(Y), Plane(Axis(Y), Axis(Z)), Plane(Axis(X), Axis(Y))) +15 Cartesian coordinates requires 11952 points +[Vibrational States] +Transformed Geometry (Å): +[Transformed Geometry] +Equilibrium Rotational Constants (cm-1): +[Rotational Constants] + +Geometry: +[Geometry] +Vibrational Frequencies (cm-1): +[Freqs] +ZPT = 6675.1 + +Rotational Constants (cm-1): +[Rotational Constants] +Coriolis Resonances: + 4 3 C + 5 4 A + 6 5 A + 7 6 B + 8 5 B + 8 7 A + +Type 1 Fermi Resonances: + 5 2 + 6 2 + 7 2 + 8 2 + +Type 2 Fermi Resonances: + 4 2 1 + 6 2 1 + 6 4 2 + 8 2 0 + +normal termination of pbqff diff --git a/tests/snapshots/run__run@testfiles__norm.toml.snap b/tests/snapshots/run__run@testfiles__norm.toml.snap new file mode 100644 index 0000000..4dfe796 --- /dev/null +++ b/tests/snapshots/run__run@testfiles__norm.toml.snap @@ -0,0 +1,41 @@ +--- +source: tests/run.rs +expression: "read_to_string(dir.path().join(\"pbqff.out\")).unwrap()" +snapshot_kind: text +--- +PID: [PID] +version: [version] +normalized geometry:[Normalized Geometry] +point group:C2v(Axis(Y), Plane(Axis(Y), Axis(Z)), Plane(Axis(X), Axis(Y))) +9 Cartesian coordinates requires 64 points +[Normal Coordinates] + +Harmonic Frequencies: + 0 A1 2602.7 + 1 B2 2523.5 + 2 A1 1315.5 +3 normal coordinates require 69 points +anpass sum of squared residuals: [residual] +[Vibrational States] +Transformed Geometry (Å): +[Transformed Geometry] +Equilibrium Rotational Constants (cm-1): +[Rotational Constants] + +Geometry: +[Geometry] +Vibrational Frequencies (cm-1): +[Freqs] +ZPT = 3158.7 + +Rotational Constants (cm-1): +[Rotational Constants] +Coriolis Resonances: + 1 0 C + +Type 1 Fermi Resonances: + 2 0 + +Type 2 Fermi Resonances: + +normal termination of pbqff diff --git a/tests/snapshots/run__run@testfiles__test.toml.snap b/tests/snapshots/run__run@testfiles__test.toml.snap new file mode 100644 index 0000000..61830d2 --- /dev/null +++ b/tests/snapshots/run__run@testfiles__test.toml.snap @@ -0,0 +1,97 @@ +--- +source: tests/run.rs +expression: "read_to_string(dir.path().join(\"pbqff.out\")).unwrap()" +snapshot_kind: text +--- +PID: [PID] +version: [version] + +Configuration Options: +geometry = { +C +C 1 CC +C 1 CC 2 CCC +H 2 CH 1 HCC 3 180.0 +H 3 CH 1 HCC 2 180.0 + +CC = 1.42101898 +CCC = 55.60133141 +CH = 1.07692776 +HCC = 147.81488230 + +} +optimize = true +charge = 0 +step_size = 0.005 +coord_type = sic +template = scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1 +hybrid_template = scfcrt=1.D-21 aux(precision=14 comp xp xs xw) PM6 THREADS=1 +queue_template = +program = mopac +queue = local +sleep_int = 2 +job_limit = 2048 +chunk_size = 1 +findiff = false +check_int = 100 +dummy_atoms = None +norm_resume_hff = false + +Optimized Geometry: +[Optimized Geometry] + +Normalized Geometry:[Normalized Geometry] +Point Group = C2v(Axis(Y), Plane(Axis(Y), Axis(Z)), Plane(Axis(X), Axis(Y))) + +Symmetry Internal Coordinates: +S0 (A1) = r(2-3) +S1 (A1) = r(1-2) + r(1-3) +S2 (A1) = r(2-4) + r(3-5) +S3 (A1) = ∠(4-2-1) + ∠(5-3-1) +S4 (B2) = r(1-2) - r(1-3) +S5 (B2) = r(2-4) - r(3-5) +S6 (B2) = ∠(4-2-1) - ∠(5-3-1) +S7 (B1) = τ(4-2-1-3) - τ(5-3-1-2) +S8 (A2) = τ(4-2-1-3) + τ(5-3-1-2) + +5 atoms require 1585 jobs +anpass sum of squared residuals: [residual] + +Refit Geometry +[Refit Geometry] +[Vibrational States] +Transformed Geometry (Å): +[Transformed Geometry] +Equilibrium Rotational Constants (cm-1): +[Rotational Constants] + +Geometry: +[Geometry] +Vibrational Frequencies (cm-1): +[Freqs] +ZPT = 6673.9 + +Rotational Constants (cm-1): +[Rotational Constants] +Coriolis Resonances: + 4 3 C + 5 4 A + 6 5 A + 7 6 B + 8 5 B + 8 7 A + +Type 1 Fermi Resonances: + 5 2 + 6 2 + 7 2 + 8 2 + +Type 2 Fermi Resonances: + 3 2 0 + 4 2 1 + 6 2 1 + 6 4 2 + 8 2 0 + +normal termination of pbqff