Skip to content

Commit 40bad36

Browse files
feat: added gear-mesh physics + GearProvider (cross-domain: SEU gearb… (#12)
* feat: added gear-mesh physics + GearProvider (cross-domain: SEU gearbox), engine left unchanged. * docs: add EXPERIMENTS.md to log SEU validation failure * chore: gitignore bytecode, drop tracked artifacts and handoff note * chore: stop tracking bytecode and build artifacts * test: consolidate gear tests into test/, remove root duplicate * Delete __pycache__/validate_run.cpython-313.pyc Signed-off-by: Abhimanyu Prasad <8292aniarc@gmail.com> --------- Signed-off-by: Abhimanyu Prasad <8292aniarc@gmail.com> Co-authored-by: Tasfin Mahmud <tasfinmahmud1@gmail.com>
1 parent cd7771a commit 40bad36

9 files changed

Lines changed: 731 additions & 2 deletions

File tree

.gitignore

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[codz]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py.cover
50+
*.lcov
51+
.hypothesis/
52+
.pytest_cache/
53+
cover/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
db.sqlite3-journal
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
.pybuilder/
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# IPython
83+
profile_default/
84+
ipython_config.py
85+
86+
# pyenv
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
89+
# .python-version
90+
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
# Pipfile.lock
97+
98+
# UV
99+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
100+
# This is especially recommended for binary packages to ensure reproducibility, and is more
101+
# commonly ignored for libraries.
102+
# uv.lock
103+
104+
# poetry
105+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
106+
# This is especially recommended for binary packages to ensure reproducibility, and is more
107+
# commonly ignored for libraries.
108+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
109+
# poetry.lock
110+
# poetry.toml
111+
112+
# pdm
113+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
114+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
115+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
116+
# pdm.lock
117+
# pdm.toml
118+
.pdm-python
119+
.pdm-build/
120+
121+
# pixi
122+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
123+
# pixi.lock
124+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
125+
# in the .venv directory. It is recommended not to include this directory in version control.
126+
.pixi/*
127+
!.pixi/config.toml
128+
129+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130+
__pypackages__/
131+
132+
# Celery stuff
133+
celerybeat-schedule*
134+
celerybeat.pid
135+
136+
# Redis
137+
*.rdb
138+
*.aof
139+
*.pid
140+
141+
# RabbitMQ
142+
mnesia/
143+
rabbitmq/
144+
rabbitmq-data/
145+
146+
# ActiveMQ
147+
activemq-data/
148+
149+
# SageMath parsed files
150+
*.sage.py
151+
152+
# Environments
153+
.env
154+
.envrc
155+
.venv
156+
env/
157+
venv/
158+
ENV/
159+
env.bak/
160+
venv.bak/
161+
162+
# Spyder project settings
163+
.spyderproject
164+
.spyproject
165+
166+
# Rope project settings
167+
.ropeproject
168+
169+
# mkdocs documentation
170+
/site
171+
172+
# mypy
173+
.mypy_cache/
174+
.dmypy.json
175+
dmypy.json
176+
177+
# Pyre type checker
178+
.pyre/
179+
180+
# pytype static type analyzer
181+
.pytype/
182+
183+
# Cython debug symbols
184+
cython_debug/
185+
186+
# PyCharm
187+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
188+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
189+
# and can be added to the global gitignore or merged into this file. For a more nuclear
190+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
191+
# .idea/
192+
193+
# Abstra
194+
# Abstra is an AI-powered process automation framework.
195+
# Ignore directories containing user credentials, local state, and settings.
196+
# Learn more at https://abstra.io/docs
197+
.abstra/
198+
199+
# Visual Studio Code
200+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
201+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
202+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
203+
# you could uncomment the following to ignore the entire vscode folder
204+
# .vscode/
205+
# Temporary file for partial code execution
206+
tempCodeRunnerFile.py
207+
208+
# Ruff stuff:
209+
.ruff_cache/
210+
211+
# PyPI configuration file
212+
.pypirc
213+
214+
# Marimo
215+
marimo/_static/
216+
marimo/_lsp/
217+
__marimo__/
218+
219+
# Streamlit
220+
.streamlit/secrets.toml

EXPERIMENTS.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Experiments
2+
A running log of every validation run, benchmark, and cross-domain test for CNSD.
3+
4+
**Discipline for this file** (so it stays a record, not a trophy case):
5+
- Every entry is tied to a **commit** and a **fixed seed**. The commit's git timestamp is the authoritative date — no manually entered dates.
6+
- The **run record** (command, commit, environment, config, sample counts) is **auto-generated by the run script** and pasted in verbatim — not transcribed by hand.
7+
- The experiment and its purpose are stated *before* the result.
8+
- Null, weak, and unflattering results (abstention rates, accuracy drops, limitations) are recorded alongside the headline numbers.
9+
- Each entry carries a status: `planned` · `running` · `preliminary` · `validated` · `superseded`.
10+
11+
**How to reproduce any entry**: check out the commit in its run record, prepare the dataset as described in `data/README` (layout + expected sample count / checksum), install the pinned environment (`requirements.txt`), and run the exact command shown in the run record. Numbers should match within run-to-run noise (seeds are fixed; minor GPU nondeterminism is expected).
12+
13+
---
14+
15+
## Index
16+
17+
| # | Experiment | Domain | Status |
18+
|---|------------|--------|--------|
19+
| 1 | CWRU baseline (Protocol B) | Bearing (CWRU) | preliminary |
20+
| 2 | Threshold sweep | Bearing (CWRU) | preliminary |
21+
| 3 | Cross-condition robustness (AWGN) | Bearing (CWRU) | preliminary |
22+
| 4 | Multi-seed headline | Bearing (CWRU) | planned |
23+
| 5 | Cross-domain: SEU gearbox | Gear (SEU) | preliminary (failed) |
24+
25+
---
26+
27+
## 1. CWRU baseline — Protocol B (cross-load)
28+
29+
* **Status:** preliminary
30+
* **Purpose:** confirm the full five-layer pipeline runs end-to-end on real CWRU and establish the baseline diagnosis result.
31+
* **Setup:** train loads 0–2, test load 3. All 10 classes. 12 kHz, window 1024.
32+
33+
**Run record**
34+
```text
35+
commit: cd7771ab3668caf9b33109c3a0a9d89f24fd111c
36+
command: python validate_run.py --seed 42
37+
data: 5806 train / 2019 test samples
38+
```
39+
40+
**Layer-2 physics verification rate**
41+
| Verdict | Rate |
42+
|---------|------|
43+
| CONFIRMED | TBD |
44+
| CONFLICT | TBD |
45+
| INCONCLUSIVE | TBD |
46+
47+
**Headline — CNN accuracy by physics verdict**
48+
| Verdict | n | CNN accuracy |
49+
|---------|---|--------------|
50+
| CONFIRMED | TBD | TBD |
51+
| CONFLICT | TBD | TBD |
52+
| INCONCLUSIVE | TBD | TBD |
53+
| **Gap (CONFIRMED - CONFLICT)** | | **TBD** |
54+
55+
* **Causal (Layer 3)**`do(Z)`: rung *TBD*, max_contrast *TBD*, p *TBD*
56+
* **Counterfactual (Layer 3B)**: DoWhy available *TBD*; method *TBD*
57+
* **Notes / limitations**: record the INCONCLUSIVE rate and any seed drift.
58+
59+
---
60+
61+
## 5. Cross-domain — SEU gearbox (GearProvider)
62+
63+
* **Status:** preliminary (failed validation)
64+
* **Purpose:** demonstrate the framework is genuinely domain-agnostic — same engine, different machine class, only the provider changes.
65+
* **Setup:** full pipeline on SEU gearset using `GearProvider` (gear-mesh physics). `N_TEETH_INPUT` confirmed against rig spec; fixed channel chosen up front; threshold tuned on a held-out split.
66+
67+
**Run record**
68+
```text
69+
commit: <PENDING PR 12 MERGE>
70+
command: python validate_seu.py
71+
data: 5115 train / 5115 test samples
72+
n_teeth_input: 20 | channel: 2 (planetary x-axis)
73+
```
74+
75+
**Layer-2 physics verification rate**
76+
| Verdict | Rate |
77+
|---------|------|
78+
| CONFIRMED | 0.2% |
79+
| CONFLICT | 0.3% |
80+
| INCONCLUSIVE | 99.5% |
81+
82+
**Headline — CNN accuracy by physics verdict**
83+
| Verdict | n | CNN accuracy |
84+
|---------|---|--------------|
85+
| CONFIRMED | 9 | 0.333 |
86+
| CONFLICT | 17 | 0.824 |
87+
| INCONCLUSIVE | 5089 | 0.514 |
88+
| **Gap (CONFIRMED - CONFLICT)** | | **-0.491 (FAILED)** |
89+
90+
* **Known caveats to report honestly:** The accuracy gap is currently backwards and practically noise due to a 99.5% inconclusive rate. This is pending a strict `tau` threshold calibration sweep for gear physics, as well as confirming that GMF strength aligns with the same numerical scale as bearing physics.

cnsd/builder.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ def build_provider(config):
9393
cond_to_rpm = _coerce_int_keys(params.get('motor_load_rpm', {0: 1797}))
9494
return provider_cls(bearing=geometry, cond_to_rpm=cond_to_rpm, fs=fs)
9595

96+
if domain_type == 'gear':
97+
cond_to_rpm = _coerce_int_keys(params.get('motor_load_rpm', {0: 1800}))
98+
return provider_cls(
99+
n_teeth_input=params['n_teeth_input'],
100+
n_teeth_output=params.get('n_teeth_output'),
101+
cond_to_rpm=cond_to_rpm,
102+
fs=fs,
103+
)
104+
96105
# other registered domains: pass parameters through + fs
97106
try:
98107
return provider_cls(fs=fs, **params)

cnsd/physics/configs.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
@dataclass
77
class PhysicsConfig:
8-
bearing: dict[str, float]
98
cond_to_rpm: dict
109
fs: int
10+
bearing: dict[str, float] | None = None
1111
name: str = 'custom'
1212

1313

@@ -25,4 +25,9 @@ class PhysicsConfig:
2525
name='JNU-N205',
2626
)
2727

28-
SEU_PHYSICS = None
28+
SEU_PHYSICS = PhysicsConfig(
29+
bearing=None,
30+
cond_to_rpm={0: 1200, 1: 1800},
31+
fs=20000,
32+
name='SEU-Gearbox',
33+
)

0 commit comments

Comments
 (0)