Skip to content

Add number_of_moles property and extensive thermodynamic properties to Material#709

Merged
bobmyhill merged 12 commits intogeodynamics:mainfrom
bobmyhill:n_moles
Nov 28, 2025
Merged

Add number_of_moles property and extensive thermodynamic properties to Material#709
bobmyhill merged 12 commits intogeodynamics:mainfrom
bobmyhill:n_moles

Conversation

@bobmyhill
Copy link
Copy Markdown
Member

@bobmyhill bobmyhill commented Nov 28, 2025

BREAKING CHANGES

This pull request refactors the handling of extensive and molar properties, primarily by standardizing the use of number_of_moles and providing clear separation between extensive and molar quantities.

Major changes:

  • Added number_of_moles property to Material, with getter and setter, and refactored all relevant classes to use this standardized attribute. By default, number_of_moles is equal to 1 for all classes.
  • Removed use of the undocumented, invisible n_moles attribute.
  • Introduced extensive property getters (e.g., internal_energy, volume, entropy, etc.) in the parent Material class, which all multiply molar properties by number_of_moles.
  • Updated aliases (e.g., V, S, H, C_v, C_p) to reference extensive properties instead of molar ones. This is the only major user-facing break in behaviour
  • Refactored composite property calculations (phase_volumes, phase_masses, formula) to use extensive properties
  • Updated check_eos_consistency() in burnman/tools/eos.py to work directly with extensive properties

Separately, this PR also adds cleaner error messaging and try/except blocks for when properties are requested before set_state() has been called.

@bobmyhill
Copy link
Copy Markdown
Member Author

Addresses #707

@bobmyhill bobmyhill added this to the 3.0 milestone Nov 28, 2025
@bobmyhill bobmyhill merged commit dbb1c31 into geodynamics:main Nov 28, 2025
12 checks passed
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