Skip to content

Rupture velocity refactor#80

Merged
lispandfound merged 22 commits intopegasusfrom
rvfac
Feb 23, 2026
Merged

Rupture velocity refactor#80
lispandfound merged 22 commits intopegasusfrom
rvfac

Conversation

@lispandfound
Copy link
Contributor

@lispandfound lispandfound commented Dec 16, 2025

This PR refactors hf-sim and realisation-to-srf to have a common set of rupture velocity parameters. The background is explained in slack.

Rupture velocity determines the how the wavefront of the rupture moves across the rupture geometry during SRF generation, and HF calculation. It relates to the SRF rupture initiation times, and the lower frequency HF output. In the current workflow settings the rupture velocity is decreased near the surface and at depth. It is consistently adjusted in the high-frequency code path too. However, this is only because Rob applied a consistent set of defaults between the two codebases. When we adjust these parameters we need to make sure they stay in sync. This is the motivation for the PR.

I also slightly refactored the hf-sim code to add some tests. Basically cutting down the main function to have it call more subfunctions and then testing those subfunctions.

The high line count here is just because I have extracted common options into a new defaults file. I did this because I got sick of editing four different files in the same places over and over.

@gemini-code-assist
Copy link

Summary of Changes

Hello @lispandfound, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the handling of rupture velocity parameters within the workflow, centralizing them into a new RuptureVelocity configuration. This change addresses the previous challenge of manually synchronizing these parameters between the high-frequency simulation (hf-sim) and SRF generation (realisation-to-srf) code paths. By establishing a single, consistent definition for rupture velocity, the PR enhances the maintainability and reliability of the simulation workflow, ensuring that the wavefront movement is consistently applied across different stages of the process.

Highlights

  • Centralized Rupture Velocity Parameters: Rupture velocity parameters (rvfrac, rvfrac_shal, rvfrac_deep) have been moved from the hf configuration section into a new, dedicated RuptureVelocity class and configuration section. This ensures a single source of truth for these parameters across hf-sim and realisation-to-srf.
  • Renamed Parameter for Consistency: The rvfac_seg parameter in SRFConfig and related schemas has been consistently renamed to rvfrac_seg to align with the new rvfrac naming convention.
  • Updated Default Parameter Files: Multiple defaults.yaml files across different versions have been updated to reflect the new rupture_velocity section and the removal of rupture velocity parameters from the hf section. Several root_defaults.yaml files have also been removed as part of this cleanup.
  • New Utility Functions and Tests for HF Simulation: New functions station_seeds and create_hf_dataset have been added to hf_sim.py to improve seed generation and dataset structuring. Corresponding tests have been added in tests/test_hf.py to validate their functionality, including stable hashing and dataset creation.
  • Refactored HF and SRF Generation Scripts: The hf_sim.py and realisation_to_srf.py scripts have been updated to utilize the new RuptureVelocity object, ensuring that rupture velocity parameters are passed and used consistently during high-frequency simulation input building and SRF command generation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully refactors the rupture velocity parameters into a common configuration, which is a great improvement for consistency and maintainability across hf-sim and realisation-to-srf. The changes are well-implemented throughout the codebase, including configuration files, schemas, and scripts. The refactoring in hf_sim.py to extract helper functions like station_seeds and create_hf_dataset significantly improves code clarity and testability. The addition of new tests, especially using property-based testing with hypothesis, is commendable. I found one minor issue in a new test case, which is detailed in the comments.

lispandfound and others added 2 commits December 17, 2025 13:19
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors rupture velocity parameters to ensure they remain synchronized between low-frequency (SRF generation) and high-frequency (HF) simulation code paths. It extracts common rupture velocity parameters (rvfrac, rvfrac_shal, rvfrac_deep) from the HFConfig class into a new dedicated RuptureVelocity configuration class that can be shared between both simulation workflows. The PR also includes minor refactoring of the hf_sim module to improve testability by extracting helper functions.

Key changes:

  • Created new RuptureVelocity configuration class with shared rupture velocity parameters
  • Renamed rvfac to rvfrac and rvfac_seg to rvfrac_seg for naming consistency
  • Added property-based tests using Hypothesis for hf_sim helper functions

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
workflow/schemas.py Added RUPTURE_VELOCITY_SCHEMA and removed rupture velocity fields from HF_CONFIG_SCHEMA; renamed rvfac_seg to rvfrac_seg in SRF_SCHEMA
workflow/realisations.py Added RuptureVelocity dataclass; removed rupture velocity fields from HFConfig; renamed rvfac_seg to rvfrac_seg in SRFConfig
workflow/scripts/realisation_to_srf.py Integrated RuptureVelocity into SRFRealisationContext and _build_genslip_command; passes rupture velocity parameters to genslip
workflow/scripts/hf_sim.py Updated build_hf_input to use RuptureVelocity; extracted station_seeds and create_hf_dataset helper functions; integrated RuptureVelocity in run_hf; uses configured t_sec instead of hardcoded start time
workflow/default_parameters/*/defaults.yaml Moved rupture velocity parameters from hf section to new rupture_velocity section; renamed rvfac_seg to rvfrac_seg
workflow/default_parameters/*/root_defaults.yaml Deleted obsolete root defaults files for all parameter versions
tests/test_realisation.py Added RuptureVelocity to test cases
tests/test_hf.py Added comprehensive tests for build_hf_input, stable_hash, station_seeds, and create_hf_dataset functions using property-based testing with Hypothesis
pyproject.toml Added hypothesis test dependency and updated deptry configuration
.github/workflows/deptry.yml Simplified deptry command to use configuration from pyproject.toml

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…HF input test

- Correct typo in comment for output file placeholder
- Add assertion for rupture velocity parameters line
- Fix typo in comment regarding referential transparency in station seeds test
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 20 out of 22 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@lispandfound lispandfound changed the base branch from srf_options to pegasus January 6, 2026 23:08
@lispandfound lispandfound dismissed AndrewRidden-Harper’s stale review January 6, 2026 23:08

The base branch was changed.

lispandfound and others added 5 commits January 7, 2026 16:43
- In genslip, the defaults from the source code are 6.5km +/- 1.5km for
shallow transition and are 17.5 +/- 2.5km for deep transition.
- The defaults and bounds calculation has been updated for consistency
joelridden
joelridden previously approved these changes Jan 19, 2026
@lispandfound lispandfound merged commit 0f7e322 into pegasus Feb 23, 2026
7 checks passed
@lispandfound lispandfound deleted the rvfac branch February 23, 2026 03:12
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.

4 participants