Skip to content

Commit 480a5f3

Browse files
kewh5868KWWyatt
andauthored
Model test continuation (#130)
* fix(saxs): harden experimental data loading on Windows Incorporate the safe parts of PR #125 onto the up-to-date continuation branch. Preserve comment-header column detection for metadata-heavy experimental files and constrain the experimental data header dialog so long Windows paths do not oversized-crash the UI. Co-authored-by: KWWyatt <117381914+KWWyatt@users.noreply.github.com> * feat(bondanalysis): expand analysis outputs and controls Add dihedral and coordination-number analysis support, richer GDS-oriented statistics, updated plotting/export behavior, and focused UI/CLI coverage for the bond analysis workflow. * feat(clusterdynamics): improve plotting and project startup Add project-aware defaults, richer trajectory plotting/export behavior, startup progress handling, and updated cluster dynamics prediction workflows with focused tests and docs. * feat(saxs): add project tooling and EXAFS workflows Add project layout/memory support, Direct Frame SAXS, EXAFS GDS mapping workflows, shared plotting/editor improvements, DREAM/project UI refinements, and tests for the updated SAXSShell tool surface. * docs: refresh SAXSShell user guide navigation Update general user-guide pages and navigation for the current project workflow, cluster dynamics organization, output locations, and tool behavior without including the spectroscopy mapping or geometric model reference files. --------- Co-authored-by: KWWyatt <117381914+KWWyatt@users.noreply.github.com>
2 parents 5152977 + fe75286 commit 480a5f3

97 files changed

Lines changed: 33315 additions & 1610 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ site/
8484
tests/born_vs_debye_backend_debug_*/
8585
tests/contrast_fft_backend_debug_*/
8686
tests/edm_contiguous_mode_report/
87+
tests/direct_frame_saxs_beta/
8788
tests/representativefinder_performance/output_results/
8889
tests/smearing_analysis_*/
8990
tests/CsPbI3_SAXS_fit/
@@ -92,6 +93,10 @@ tests/CsPbI3_SAXS_fit.zip
9293
# Generated reports
9394
docs/reports/
9495

96+
# Generated direct-frame SAXS beta outputs
97+
direct_frame_saxs_runs/
98+
examples/direct_frame_saxs_runs/
99+
95100
# PyBuilder
96101
target/
97102

README.rst

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -607,15 +607,16 @@ new, resumed, or already complete.
607607
``bondanalysis``
608608
~~~~~~~~~~~~~~~~
609609

610-
The ``bondanalysis`` application is designed for bond-pair and
611-
angle-triplet distribution analysis on the stoichiometry-level cluster
612-
folders produced by ``clusters``. A typical workflow is:
610+
The ``bondanalysis`` application is designed for bond-pair,
611+
angle-triplet, dihedral-quartet, and coordination-number distribution
612+
analysis on the stoichiometry-level cluster folders produced by
613+
``clusters``. A typical workflow is:
613614

614615
1. Use ``mdtrajectory`` to export frames.
615616
2. Use ``clusters`` to sort those frames into stoichiometry folders.
616617
3. Open ``bondanalysis`` on the cluster-output folder.
617-
4. Choose the bond pairs and angle triplets to measure, along with
618-
their cutoff distances.
618+
4. Choose the bond pairs, angle triplets, dihedral quartets, and
619+
coordination rules to measure, along with their cutoff distances.
619620
5. Run the analysis to write CSVs, histograms, comparison plots, and a
620621
JSON manifest into a sibling ``bondanalysis_*`` folder.
621622

@@ -632,10 +633,10 @@ To launch the Qt application from the repository root ::
632633
Bondanalysis UI Use
633634
-------------------
634635

635-
The Qt interface focuses only on bond-pair and angle-distribution
636-
analysis. The legacy displacement-analysis tooling is intentionally not
637-
part of the new window and should be treated as deprecated until it is
638-
updated.
636+
The Qt interface focuses on bond-pair, angle, dihedral, and
637+
coordination-distribution analysis. The legacy displacement-analysis
638+
tooling is intentionally not part of the new window and should be
639+
treated as deprecated until it is updated.
639640

640641
Launch the UI ::
641642

@@ -661,7 +662,12 @@ Inside the window:
661662
distance cutoff in angstrom.
662663
6. Add one or more angle-triplet rows using the vertex atom, the two
663664
arm atoms, and the two vertex-arm cutoffs in angstrom.
664-
7. Click ``Analyze Bond Pairs and Angle Distributions``.
665+
7. Add one or more dihedral-quartet rows using four atoms and the
666+
three adjacent-pair cutoffs in angstrom. For Pb-coordinated DMF,
667+
``Pb-O-C-N`` extracts the signed torsion needed for GDS constraint
668+
setup.
669+
8. Click ``Analyze Bond, Angle, Dihedral, and Coordination
670+
Distributions``.
665671

666672
Each run writes:
667673

@@ -671,8 +677,8 @@ Each run writes:
671677
types
672678
under ``all_clusters/``.
673679
3. Overlay comparison CSVs, NPYs, and PNG plots under ``comparisons/``.
674-
4. A ``bondanalysis_manifest.json`` file describing the run inputs and
675-
outputs.
680+
4. A ``bondanalysis_results_index.json`` file describing the run inputs,
681+
outputs, and GDS variable registry.
676682

677683
Bondanalysis Terminal Use
678684
-------------------------
@@ -681,12 +687,24 @@ Inspect a clusters directory before running analysis ::
681687

682688
PYTHONPATH=src conda run --no-capture-output -n saxshell-py312 python -m saxshell.bondanalysis inspect clusters_splitxyz0001
683689

684-
Run bond-pair and angle analysis headlessly on every cluster type ::
690+
Run bond-pair, angle, and dihedral analysis headlessly on every cluster
691+
type ::
685692

686693
PYTHONPATH=src conda run --no-capture-output -n saxshell-py312 python -m saxshell.bondanalysis run clusters_splitxyz0001 \
687694
--bond-pair Pb:I:3.50 \
688695
--bond-pair Pb:O:3.20 \
689-
--angle-triplet Pb:I:I:3.50:3.50
696+
--angle-triplet Pb:I:I:3.50:3.50 \
697+
--dihedral Pb:O:C:N:3.20:2.20:2.20
698+
699+
Each histogram CSV includes ordinary distribution statistics plus GDS-oriented
700+
metadata. Bond-distance histograms add ``gds_center_angstrom``,
701+
``gds_sigma_angstrom``, and ``gds_sigma2_angstrom_squared``. Angle and
702+
dihedral histograms add degree and radian forms, including
703+
``gds_center_degrees``, ``gds_sigma_degrees``, ``gds_center_radians``,
704+
``gds_sigma_radians``, and ``gds_variance_radians_squared``. The metadata also
705+
includes ``gds_*_variable`` names and paste-ready Artemis ``set`` rows, and
706+
the run's ``bondanalysis_results_index.json`` registers those variables across
707+
the saved cluster and aggregate distributions.
690708

691709
Restrict the run to selected stoichiometry folders and choose an
692710
explicit output directory ::
@@ -710,6 +728,7 @@ inspection and execution steps used by the UI and terminal interfaces.
710728
AngleTripletDefinition,
711729
BondAnalysisWorkflow,
712730
BondPairDefinition,
731+
DihedralQuartetDefinition,
713732
)
714733

715734
workflow = BondAnalysisWorkflow(
@@ -721,6 +740,11 @@ inspection and execution steps used by the UI and terminal interfaces.
721740
angle_triplets=[
722741
AngleTripletDefinition("Pb", "I", "I", 3.50, 3.50),
723742
],
743+
dihedral_quartets=[
744+
DihedralQuartetDefinition(
745+
"Pb", "O", "C", "N", 3.20, 2.20, 2.20
746+
),
747+
],
724748
)
725749
summary = workflow.inspect()
726750
result = workflow.run()

docs/getting-started/project-setup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ The **Component build mode** dropdown controls what happens when you click
108108
Representative structures are optional project-backed files that compatible
109109
Debye, Born, FFT, and RMCSetup workflows can use instead of average cluster
110110
folders. Use **Tools > Structure Analysis > Open Representative Structures** for
111-
the full interactive analysis UI, or use **Tools > CLI Setup > Open
111+
the full interactive analysis UI, or use **Tools > (beta) > CLI Setup > Open
112112
Representative CLI Setup (Beta)** to save
113113
`representative_structure_cli_run.json` and run the same backend from the
114114
source checkout:
@@ -117,8 +117,8 @@ source checkout:
117117
PYTHONPATH=src conda run --no-capture-output -n saxshell-py312 python -m saxshell.representativefinder run /path/to/project
118118
```
119119

120-
The same **Tools > CLI Setup** menu can prepare project-local run files for
121-
XYZ-to-PDB conversion, cluster extraction, cluster dynamics, and cluster
120+
The same **Tools > (beta) > CLI Setup** menu can prepare project-local run files
121+
for XYZ-to-PDB conversion, cluster extraction, cluster dynamics, and cluster
122122
dynamics ML. Those run files let you run long jobs from a terminal or batch
123123
several prepared project folders while keeping outputs linked back to their
124124
projects.

docs/user-guide/bond-analysis.md

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Bond Analysis
22

33
The **Bond Analysis** tool is SAXSShell's structure-analysis application for
4-
measuring bond-length and angle distributions from stoichiometry-sorted cluster
5-
folders.
4+
measuring bond-length, angle, dihedral, and coordination distributions from
5+
stoichiometry-sorted cluster folders.
66

77
## Launching the application
88

@@ -22,25 +22,80 @@ The current UI supports:
2222
- limiting the run to checked stoichiometry labels
2323
- defining bond-pair cutoffs directly in a table
2424
- defining angle triplets directly in a table
25+
- defining signed dihedral quartets directly in a table
2526
- loading built-in presets and saving custom presets for later reuse
2627
- reopening an existing bond-analysis output folder and browsing its saved
2728
distributions
2829

2930
The right side of the window focuses on the computed distributions. You can
30-
refresh a results directory, select one or more saved bond-pair or angle
31-
entries, and open them in a dedicated plot window. Matching items from multiple
32-
cluster types can be overlaid together for comparison.
31+
refresh a results directory, select one or more saved bond-pair, angle,
32+
dihedral, or coordination entries, and open them in a dedicated plot window.
33+
Matching items from multiple cluster types can be overlaid together for
34+
comparison.
3335

3436
## Typical workflow
3537

3638
1. Start from the project's sorted clusters folder.
3739
2. Confirm or choose the bond-analysis output directory.
3840
3. Refresh the detected cluster types and clear any stoichiometries you do not
3941
want to include.
40-
4. Load a preset or define the bond pairs and angle triplets manually.
42+
4. Load a preset or define the bond pairs, angle triplets, and dihedral
43+
quartets manually.
4144
5. Run the calculation and inspect the saved distributions from the results
4245
browser.
4346

47+
Dihedral quartets use adjacent-pair cutoffs: `ATOM1-ATOM2`, `ATOM2-ATOM3`,
48+
and `ATOM3-ATOM4` must each be within their requested cutoff. The reported
49+
values are signed degrees in `[-180, 180]`. The calculation projects the two
50+
outer bonds onto the plane perpendicular to the middle bond and uses `atan2` to
51+
keep the torsion sign. `-180` and `+180` are the same anti-aligned planar
52+
torsion at the wrap boundary, while `0` is the aligned planar torsion and is
53+
not equivalent to `180`.
54+
55+
When plotting dihedral distributions, the saved values are not modified, but
56+
the plot display is recentered when helpful. The display center snaps to the
57+
nearest clean multiple of 90 degrees (`0`, `+90`, `-90`, or `180`) based on the
58+
circular center, so a wrapped population near `-180` / `+180` appears as one
59+
continuous peak centered near `180` instead of being split across both plot
60+
edges. Even when the display is internally recentered, tick labels and summary
61+
values remain in the signed `[-180, 180]` convention. Dihedral plots also
62+
provide a plot-style toggle between a normal histogram and a radial histogram.
63+
The radial view draws all dihedral values on one circular axis, which is useful
64+
for combined nearly degenerate terminal distributions such as `O-C-N-C` where
65+
one branch may populate `0` and another may populate the `-180` / `+180`
66+
boundary.
67+
68+
Each histogram CSV includes ordinary distribution statistics plus
69+
GDS-oriented metadata. Bond-distance histograms add `gds_center_angstrom`,
70+
`gds_sigma_angstrom`, and `gds_sigma2_angstrom_squared`. Angle and dihedral
71+
histograms add `gds_center_degrees`, `gds_sigma_degrees`,
72+
`gds_center_radians`, `gds_sigma_radians`, and
73+
`gds_variance_radians_squared`. The same metadata also includes
74+
`gds_*_variable` names and paste-ready Artemis `set` rows. The run's
75+
`bondanalysis_results_index.json` registers those variables across the saved
76+
cluster and aggregate distributions. Dihedral GDS centers and widths use
77+
circular statistics, so a population split across the `-180` / `+180` histogram
78+
edge is treated as one wrapped distribution instead of being averaged toward
79+
`0`.
80+
81+
## EXAFS GDS handoff
82+
83+
After representative structures and bondanalysis are complete, open
84+
`Tools > Structure Analysis > Open EXAFS GDS Mapping` from the main SAXS UI.
85+
The mapping window loads the project representative-structure metadata and
86+
completed bondanalysis result folders, then lets you choose a stoichiometry
87+
representative, inspect labeled 3D and 2D absorber-scatterer path diagrams,
88+
select bond, angle, and dihedral registry variables, preview the generated GDS,
89+
and write a validated Artemis setup file.
90+
91+
The bondanalysis variables are imported as GDS-ready statistical `set` rows.
92+
They provide the distribution centers and sigmas that can anchor the GDS
93+
constraint setup while the EXAFS mapping tool builds the path/template side
94+
from the selected representative structure. Hydrogen-family atoms are excluded
95+
from the mapping diagrams and generated EXAFS paths. The absorber defaults to
96+
Pb when Pb is present, and can be changed to another non-hydrogen coordination
97+
center in the mapping window.
98+
4499
## Related pages
45100

46101
- [MD Extraction and Cluster Preparation](cluster-extraction.md)

docs/user-guide/cluster-dynamics-ml.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Cluster Dynamics ML
1+
# Cluster Dynamics
22

33
`clusterdynamicsml` is the predictive companion to `clusterdynamics`. It can be
44
launched directly from the source checkout or from the main SAXSShell UI. It
@@ -15,7 +15,7 @@ that includes both observed and predicted structures.
1515

1616
## What the application does
1717

18-
At a high level, Cluster Dynamics ML answers this question:
18+
At a high level, Cluster Dynamics answers this question:
1919

2020
> Given the smaller clusters that are observed in a trajectory and the
2121
> reference structures available for those smaller clusters, what larger
@@ -28,7 +28,7 @@ geometry rules.
2828

2929
## Inputs
3030

31-
Cluster Dynamics ML expects all of the inputs required by `clusterdynamics`,
31+
Cluster Dynamics expects all of the inputs required by `clusterdynamics`,
3232
plus a structure library for the observed smaller clusters.
3333

3434
### Required inputs
@@ -58,14 +58,14 @@ plus a structure library for the observed smaller clusters.
5858
6. Set the predicted share threshold used to prune tiny candidate populations.
5959
7. Optionally load experimental SAXS data.
6060
8. Run **Analyze and Predict Larger Clusters**.
61-
9. Review the `Summary`, `Lifetimes`, `Debye-Waller`, `Histograms`, and
61+
9. Review the `Summary`, `Lifetimes`, `Debye-Waller (beta)`, `Histograms`, and
6262
`SAXS` tabs.
6363
10. Save the dataset, CSV exports, or a detailed PowerPoint report if needed.
6464

6565
## Project-Backed CLI Setup
6666

67-
For background prediction runs, use **Tools > CLI Setup > Open Cluster Dynamics
68-
ML CLI Setup (Beta)**. The setup window writes
67+
For background prediction runs, use **Tools > (beta) > CLI Setup > Open Cluster
68+
Dynamics ML CLI Setup (Beta)**. The setup window writes
6969
`cluster_dynamics_ml_cli_run.json` in the active project folder and shows the
7070
terminal commands to run later:
7171

@@ -305,7 +305,7 @@ definition.
305305

306306
## Debye scattering with pairwise Debye-Waller damping
307307

308-
Cluster Dynamics ML now distinguishes between two SAXS-component cases:
308+
Cluster Dynamics now distinguishes between two SAXS-component cases:
309309

310310
- `Averaged component`
311311
When a SAXS component is already averaged over many structure files, the
@@ -347,7 +347,7 @@ $\sin(q r_{ij}) / (q r_{ij})$.
347347

348348
### Debye-Waller-extended single-structure equation
349349

350-
For a single representative structure, Cluster Dynamics ML uses a pairwise
350+
For a single representative structure, Cluster Dynamics uses a pairwise
351351
Debye-Waller damping factor on the off-diagonal pair contributions:
352352

353353
$$
@@ -375,7 +375,7 @@ interference terms between distinct atoms are attenuated.
375375

376376
### Relation between $\sigma$ and $B$
377377

378-
Cluster Dynamics ML reports both the Gaussian displacement width
378+
Cluster Dynamics reports both the Gaussian displacement width
379379
$\sigma_{\alpha\beta}$ and the equivalent Debye-Waller $B$ coefficient:
380380

381381
$$
@@ -399,7 +399,7 @@ main-model refinement.
399399

400400
## How Debye-Waller coefficients are estimated
401401

402-
Cluster Dynamics ML estimates pairwise disorder from the observed structure
402+
Cluster Dynamics estimates pairwise disorder from the observed structure
403403
ensembles before it predicts values for the larger clusters.
404404

405405
### Observed-cluster ensemble estimate
@@ -471,8 +471,8 @@ measure a spread.
471471
### Predicted-cluster estimate
472472

473473
The larger predicted clusters do not have their own ensembles yet, so Cluster
474-
Dynamics ML fits a separate weighted ridge-regression model for each element
475-
pair type using the observed $\sigma_{L,\alpha\beta}$ values as the training
474+
Dynamics fits a separate weighted ridge-regression model for each element pair
475+
type using the observed $\sigma_{L,\alpha\beta}$ values as the training
476476
targets.
477477

478478
For a candidate feature vector $\mathbf{x}$, the predicted disorder value is:
@@ -493,7 +493,7 @@ $$
493493
$$
494494

495495
The feature vector is the same one already used for the other Cluster Dynamics
496-
ML properties:
496+
properties:
497497

498498
$$
499499
\mathbf{x} =
@@ -532,11 +532,11 @@ single extrapolated candidate dominate the whole distribution.
532532

533533
## Outputs
534534

535-
Cluster Dynamics ML can produce:
535+
Cluster Dynamics can produce:
536536

537537
- the standard time-binned colormap from `clusterdynamics`
538538
- a combined lifetime table containing observed and predicted rows
539-
- a `Debye-Waller` table listing the resolved \(\sigma\) and \(B\) values for
539+
- a `Debye-Waller (beta)` table listing the resolved \(\sigma\) and \(B\) values for
540540
each observed and predicted element pair
541541
- histogram views for observed-only and observed-plus-predicted populations
542542
- SAXS traces for observed-only and observed-plus-predicted models
@@ -622,7 +622,7 @@ model. Related model families include:
622622

623623
## Why the current algorithm was chosen
624624

625-
Cluster Dynamics ML is trying to extrapolate from a small observed size series
625+
Cluster Dynamics is trying to extrapolate from a small observed size series
626626
to larger unobserved clusters. In that setting, a simple regularized model has
627627
practical advantages:
628628

@@ -637,7 +637,7 @@ ridge-style regression plus geometry rules over a higher-capacity learned model.
637637

638638
## TODO
639639

640-
The current Debye-Waller workflow is intentionally scoped to Cluster Dynamics ML
640+
The current Debye-Waller workflow is intentionally scoped to Cluster Dynamics
641641
result inspection and to the single-structure component traces built inside that
642642
tool. A later extension may expose these pairwise \(B\) or \(\sigma\)
643643
coefficients to the main SAXS prefit and DREAM refinement templates as optional

docs/user-guide/cluster-dynamics.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Cluster Dynamics
1+
# Cluster Dynamics Time-Binned
22

33
`clusterdynamics` is the time-resolved companion to `clusters`. It analyzes the
44
same extracted XYZ or PDB frame folders from `mdtrajectory`, reuses the same
@@ -80,8 +80,8 @@ directory automatically.
8080

8181
## Project-Backed CLI Setup
8282

83-
For longer cluster-dynamics runs, use **Tools > CLI Setup > Open Cluster
84-
Dynamics CLI Setup (Beta)**. The setup window writes
83+
For longer cluster-dynamics runs, use **Tools > (beta) > CLI Setup > Open
84+
Cluster Dynamics CLI Setup (Beta)**. The setup window writes
8585
`cluster_dynamics_cli_run.json` in the active project folder and shows the
8686
terminal commands to run later:
8787

@@ -214,6 +214,6 @@ time basis explicit so the heatmap and lifetime interpretation stay transparent.
214214
## Related pages
215215

216216
- [Cluster Extraction](cluster-extraction.md)
217-
- [Cluster Dynamics ML](cluster-dynamics-ml.md)
217+
- [Cluster Dynamics](cluster-dynamics-ml.md)
218218
- [Project Configuration](project-configuration.md)
219219
- [Results and Export](results-and-export.md)

0 commit comments

Comments
 (0)