Skip to content

feat(params): Provide Default Parameter Set and Global Accessor#4

Merged
TKanX merged 3 commits intomainfrom
feature/3-implement-parameter-loading-and-provide-default-dataset
Oct 19, 2025
Merged

feat(params): Provide Default Parameter Set and Global Accessor#4
TKanX merged 3 commits intomainfrom
feature/3-implement-parameter-loading-and-provide-default-dataset

Conversation

@TKanX
Copy link
Member

@TKanX TKanX commented Oct 19, 2025

Summary:

Enhances the cheq library by embedding a comprehensive default parameter set directly into the binary. A new public function, get_default_parameters, provides convenient, thread-safe, and singleton-style access to these parameters. This change significantly improves the library's usability out-of-the-box, as users can now perform calculations without needing to manually create and load a parameter file for common elements.

Changes:

  • Added Default TOML Parameter File:

    • Included resources/qeq.data.toml, a new file containing a comprehensive set of QEq parameters for elements 1 through 103.
    • The parameter file is extensively documented with information on units and data sources.
  • Implemented Global Parameter Accessor:

    • Created a new public function get_default_parameters().
    • This function uses std::sync::OnceLock to lazily parse the embedded TOML file on its first call and caches the result for all subsequent calls.
    • This approach ensures efficient, thread-safe access to a single, static instance of the default Parameters.
    • Added a panic! with a descriptive error message in get_or_init to catch potential library build issues where the embedded file might be corrupted.
  • Included Unit Tests for Default Parameters:

    • Added tests to verify that get_default_parameters successfully loads the parameters and contains expected elements (e.g., Carbon).
    • A test also confirms that subsequent calls to the function return a reference to the same cached instance, ensuring the singleton pattern is correctly implemented.

@TKanX TKanX self-assigned this Oct 19, 2025
@TKanX TKanX added the enhancement ✨ New feature or request label Oct 19, 2025
Copilot AI review requested due to automatic review settings October 19, 2025 23:51
@TKanX TKanX linked an issue Oct 19, 2025 that may be closed by this pull request
22 tasks
Copy link
Contributor

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 enhances the cheq library by embedding a comprehensive default parameter set directly into the binary and providing a global accessor function. The implementation allows users to perform calculations without manually creating parameter files for common elements.

  • Adds a comprehensive TOML file containing QEq parameters for elements 1-103
  • Implements get_default_parameters() function using std::sync::OnceLock for thread-safe singleton access
  • Includes unit tests to verify parameter loading and singleton behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/lib.rs Implements the global parameter accessor function with lazy initialization and singleton pattern
resources/qeq.data.toml Adds comprehensive atomic parameters for 103 elements with detailed documentation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@TKanX TKanX merged commit 716801f into main Oct 19, 2025
2 checks passed
@TKanX TKanX deleted the feature/3-implement-parameter-loading-and-provide-default-dataset branch October 19, 2025 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Parameter Loading and Provide Default Dataset

2 participants