Skip to content

Commit 29fc855

Browse files
committed
debug(regression): dump vibrational matrices and eigenvalues
1 parent 0b3c33d commit 29fc855

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/pr.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ jobs:
9696
python -m pip install -e .[testing]
9797
9898
- name: Run fast regression tests (per system)
99+
env:
100+
CODEENTROPY_DEBUG_REGRESSION: "1"
101+
CODEENTROPY_DEBUG_DIR: regression-debug
99102
run: |
100103
python -m pytest tests/regression \
101104
-m "not slow" \
@@ -112,6 +115,7 @@ jobs:
112115
name: quick-regression-failure-${{ matrix.system }}
113116
path: |
114117
.testdata/**
118+
regression-debug/**
115119
/tmp/pytest-of-*/pytest-*/**
116120
117121
docs:

CodeEntropy/entropy/nodes/vibrational.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
from __future__ import annotations
44

55
import logging
6+
import os
67
from collections.abc import Mapping, MutableMapping
78
from dataclasses import dataclass
9+
from pathlib import Path
810
from typing import Any
911

1012
import numpy as np
@@ -264,6 +266,19 @@ def _compute_united_atom_entropy(
264266
tmat = torque_ua.get(key)
265267
flexible = flexible_ua.get(key)
266268

269+
if os.getenv("CODEENTROPY_DEBUG_REGRESSION") == "1":
270+
debug_dir = Path(os.getenv("CODEENTROPY_DEBUG_DIR", "regression-debug"))
271+
debug_dir.mkdir(parents=True, exist_ok=True)
272+
273+
np.save(
274+
debug_dir / f"ua_force_group{group_id}_res{res_id}.npy",
275+
np.asarray(fmat),
276+
)
277+
np.save(
278+
debug_dir / f"ua_torque_group{group_id}_res{res_id}.npy",
279+
np.asarray(tmat),
280+
)
281+
267282
pair = self._compute_force_torque_entropy(
268283
ve=ve,
269284
temp=temp,

CodeEntropy/entropy/vibrational.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
from __future__ import annotations
1414

1515
import logging
16+
import os
1617
from dataclasses import dataclass
18+
from pathlib import Path
1719
from typing import Any, Literal
1820

1921
import numpy as np
@@ -123,6 +125,15 @@ def _entropy_components(
123125
Array of entropy components (J/mol/K) for each valid mode.
124126
"""
125127
lambdas = self._matrix_eigenvalues(matrix)
128+
if os.getenv("CODEENTROPY_DEBUG_REGRESSION") == "1":
129+
debug_dir = Path(os.getenv("CODEENTROPY_DEBUG_DIR", "regression-debug"))
130+
debug_dir.mkdir(parents=True, exist_ok=True)
131+
132+
idx = len(list(debug_dir.glob("eigenvalues_*.npy")))
133+
np.save(
134+
debug_dir / f"eigenvalues_{idx}_{matrix_type}.npy", np.asarray(lambdas)
135+
)
136+
np.save(debug_dir / f"matrix_{idx}_{matrix_type}.npy", np.asarray(matrix))
126137
logger.debug("lambdas: %s", lambdas)
127138
lambdas = self._convert_lambda_units(lambdas)
128139
logger.debug("lambdas converted units: %s", lambdas)

0 commit comments

Comments
 (0)