Skip to content

feat: add uncertainty quantification elastic#296

Open
Atilaac wants to merge 2 commits intomainfrom
feat-add-uncertainty-quantification-elastic
Open

feat: add uncertainty quantification elastic#296
Atilaac wants to merge 2 commits intomainfrom
feat-add-uncertainty-quantification-elastic

Conversation

@Atilaac
Copy link
Copy Markdown
Contributor

@Atilaac Atilaac commented Apr 15, 2026

Introduce n_repeats to elastic_simulation to run multiple independent repeats per strain and compute uncertainty.

The function now accumulates Cij samples per repeat, returns mean and std (Cij and Cij_std) and mean/std for isotropic moduli (moduli, moduli_std).

Updated docstring/return spec and adjusted logic for normal and shear strain handling.

Tests updated/added to validate Cij index mapping, n_repeats std behavior, and related test refactors (imports and isotropic moduli checks).

Documentation and example notebook updated to document n_repeats, show printed uncertainties, and set n_repeats=3 in examples.

Atilaac added 2 commits April 15, 2026 19:51
Introduce n_repeats to elastic_simulation to run multiple independent repeats per strain and compute uncertainty. The function now accumulates Cij samples per repeat, returns mean and std (Cij and Cij_std) and mean/std for isotropic moduli (moduli, moduli_std). Use ddof=0 for n_repeats==1 and ddof=1 (sample std) for n_repeats>1. Updated docstring/return spec and adjusted logic for normal and shear strain handling. Tests updated/added to validate Cij index mapping, n_repeats std behavior, and related test refactors (imports and isotropic moduli checks).
Enable statistical uncertainty estimation by running independent repeats per strain state. elastic_simulation: add n_repeats handling (each repeat uses seed + r), collect per-repeat Cij samples, compute mean and per-element std, and return Cij_samples and n_repeats; compute moduli means and stds and expose them as B/G/E/nu and B_std/G_std/E_std/nu_std. Preserve previous behavior when n_repeats=1. Use cij mean for cubicity warnings. Documentation and example notebook updated to document n_repeats, show printed uncertainties, and set n_repeats=3 in examples.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Atilaac Atilaac requested a review from ltalirz April 15, 2026 21:32
@Atilaac
Copy link
Copy Markdown
Contributor Author

Atilaac commented Apr 16, 2026

Here, the calculations are serial for now. In principle, this is fine since most of those are short calculations. However, I plan to run all calculations in parallel, both for deformations and for repetition, which is slightly complex. For example, we run a few independent deformations for n_repetitions, or we keep it simple and run all deformations in a single cycle for n_repetitions. This latter one, I have implemented locally. This is worth discussing, and if either is agreed upon, or if another suggestion is made, I plan to add it to another PR to keep this one focused.

Copy link
Copy Markdown
Contributor

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Atilaac !

Could you please make the documentation of n_repeats a bit more specific by saying what changes between repeats?

These repeats are still all for the same glass sample, right?
In your experiments, do you see significant spread between repeats?

@ltalirz
Copy link
Copy Markdown
Contributor

ltalirz commented Apr 16, 2026

Here, the calculations are serial for now. In principle, this is fine since most of those are short calculations. However, I plan to run all calculations in parallel, both for deformations and for repetition, which is slightly complex. For example, we run a few independent deformations for n_repetitions, or we keep it simple and run all deformations in a single cycle for n_repetitions. This latter one, I have implemented locally. This is worth discussing, and if either is agreed upon, or if another suggestion is made, I plan to add it to another PR to keep this one focused.

Ok to wait with parallelization - we first need to figure out our general approach to parallelization that works with hierarchical workflows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants