Skip to content

canonical_configuration | add --seed for reproducibility - #95

Open
flokno wants to merge 10 commits into
mainfrom
fk_seed_canonical_configuration
Open

flokno wants to merge 10 commits into
mainfrom
fk_seed_canonical_configuration

Conversation

@flokno

@flokno flokno commented Oct 17, 2024 •

Copy link
Copy Markdown
Contributor

Add --seed argument to canonical_configuration for being able to create supercells in a deterministic way.

Changes

  • --seed N (N ≥ 0) seeds the random number generator, so the same seed gives the same configurations. Without --seed (default -1), the generator is seeded from the wall time as before.
  • lo_mersennetwister%init takes a new optional integer seed that sets the state directly, so every integer seed is distinct. Existing callers are unaffected.
  • initialize_cell takes an optional random number generator from the caller and hands the advanced state back, so consecutive configurations differ.
  • --seed together with --semirandom stops with an error; seeding --semirandom is out of scope.
  • canonical_configuration stops when run with more than one MPI rank, except with --semirandom, which is MPI parallel.
  • With --modes, the log prints the frequency (THz) of each displaced mode as an extra column.
  • Fix the Makefile dependency of type_forceconstant_secondorder on lo_randomnumbers.
  • Document --seed in the help text and in docs/program/canonical_configuration.md.

Tests

New acceptance tests in tests/canonical_configuration:

  • the same seed, run twice, gives identical configurations
  • two configurations within one seeded run differ
  • seeds 0 and 1 give different configurations
  • two runs without a seed, 1 s apart, give different configurations

The reference for the --modes log is updated for the new frequency column.

🤖 Generated with Claude Code

flokno and others added 10 commits October 6, 2026 22:10
Given/when/then tests: the same seed reproduces configurations, configurations
within a seeded run differ, different seeds differ, and runs without a seed differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
initialize_cell copied the random state from the caller but never handed it
back, so every configuration in a run was drawn from the same state. Seeds
were mapped via 1/seed, of which only the fractional part is used, so seeds 0
and 1 collided. Add an optional exact integer seed to the RNG init instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…column

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The serial-only check added with --seed also stopped --semirandom, which
is MPI parallel and worked in parallel before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The parent module now uses lo_randomnumbers, so depend on lo_randomnumbers.o.
Drop the cross .f90 dependencies between the module and its aux submodule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@flokno
flokno force-pushed the fk_seed_canonical_configuration branch from ccec69a to f1f396a Compare October 6, 2026 20:12
@flokno
flokno marked this pull request as ready for review October 6, 2026 20:13

This branch has not been deployed

No deployments
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.

1 participant