Skip to content

use elements.rs as chemistry database - #782

Merged
moritz-gross merged 1 commit into
daisy:mainfrom
moritz-gross:use-elements-rs-as-chemistry-database
Sep 24, 2026
Merged

moritz-gross merged 1 commit into
daisy:mainfrom
moritz-gross:use-elements-rs-as-chemistry-database

Conversation

@moritz-gross

@moritz-gross moritz-gross commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

while wandering some more through the codebase, I saw that we have a whole periodic table laying around here.
I think this is something we'd better hand off.
I found the neat crate elements_rs for this. In particular, having categories like ElementCategory::NobleGas (not to speak of AlkalineEarthMetal etc.)

next to refactoring code, I this also uncovered a buggy test re Ammonia: The electronegativity of Nitrogen is 3.04, and that of Hydrogen is 2.20, so NH_3 is in descending order.

most likely, there is way more to hand off in this file, but this looks like an easy-to-do thing for now.

@moritz-gross moritz-gross added the rust Coding in Rust label Sep 20, 2026
@moritz-gross moritz-gross changed the title use elements.rs as chemistry database use elements.rs as chemistry database Sep 23, 2026
@moritz-gross

Copy link
Copy Markdown
Collaborator Author

TODO: check difference in MathCAT size, and how to judge such a thing

@moritz-gross

moritz-gross commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

binary size seems to actually shrink ?!?.

Running this:

git switch main
cargo clean
cargo build --release --lib --locked
cp target/release/liblibmathcat.so /tmp/mathcat-main.so

git switch use-elements-rs-as-chemistry-database
cargo clean
cargo build --release --lib --locked
cp target/release/liblibmathcat.so /tmp/mathcat-elements.so

stat -c '%n: %s bytes' \
    /tmp/mathcat-main.so \
    /tmp/mathcat-elements.so

gives the result

/tmp/mathcat-main.so: 605344 bytes
/tmp/mathcat-elements.so: 604152 bytes

The "eliminating-dead-code" step you mentioned is Link-Time Optimization as I just learned?! Seems to work well then.

@NSoiffer have you ever used the size command for inspecting section sizes of binaries? That could be interesting to inspect it further, but I think this would be more of a fun side-project than actually pragmatic here.

So in summary, this PR seems good to go

@moritz-gross
moritz-gross merged commit 824cdda into daisy:main Sep 24, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from Triage to Done in MathCAT Project Board Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Coding in Rust

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant