Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytic electron EOS and zsplit modifier #444

Merged
merged 41 commits into from
Dec 18, 2024
Merged

Analytic electron EOS and zsplit modifier #444

merged 41 commits into from
Dec 18, 2024

Conversation

Yurlungur
Copy link
Collaborator

@Yurlungur Yurlungur commented Dec 11, 2024

PR Summary

In this MR I implement an analytic electron EOS---this is essentially an ideal gas but with a Gruneisen coefficient set by the the degrees of freedom of an electron and a specific heat that scales with ionization state divided by mean atomic mass. The idea here is that you pass in ion density and electron temperature. The ionization state is also passed in through the lambda.

I am also in the process of implementing the z split as a modifier, which splits an equation of state into a component from the ions and a component from the electrons. The z split will be two modifiers, one EOS for electrons and one for ions. Both applied to a single EOS split it into two. z split is exact for an ideal gas but not for anything else, but it is commonly used. I'm not done with this yet, so it might not be in the diff yet, depending on when you look at the MR.

Note that in the case of nuclear burning, EOS's will also need to be potentially modified by a mass scale, as per our ScaledEOS modifier.

I will cover adding electron or ion sub-tables of tabulated Sesame EOS's in a subsequent MR.

PR Checklist

  • Adds a test for any bugs fixed. Adds tests for new features.
  • Format your changes by using the make format command after configuring with cmake.
  • Document any new features, update documentation for changes made.
  • Make sure the copyright notice on any files you modified is up to date.
  • After creating a pull request, note it in the CHANGELOG.md file.
  • LANL employees: make sure tests pass both on the github CI and on the Darwin CI

If preparing for a new release, in addition please check the following:

  • Update the version in cmake.
  • Move the changes in the CHANGELOG.md file under a new header for the new release, and reset the categories.
  • Ensure that any when='@main' dependencies are updated to the release version in the package.py

@Yurlungur Yurlungur changed the title WIP: Analytic electron EOS and zsplit modifier Analytic electron EOS and zsplit modifier Dec 17, 2024
Copy link
Collaborator Author

@Yurlungur Yurlungur left a comment

Choose a reason for hiding this comment

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

@jhp-lanl @jdolence @pdmullen @chadmeyer this is now ready for review.

@@ -9,7 +9,7 @@ on:
jobs:
formatting:
name: Check Formatting
runs-on: ubuntu-latest
runs-on: ubuntu-noble
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Latest is now 24.04 which does not support clang-format-12. For now, just pin to older Ubuntu. WIll resolve the dependency issue long term in a formal single MR in the new year. See #446

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is now ubuntu-22.04. Must use version number, not version name.

Comment on lines +443 to +444
# jmm: updated Dec 17, 2024 to avoid build errors on modern gcc
GIT_TAG v3.7.1)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Catch2 v3.0.1 does not compile on ubuntu 24.04. Update to 3.7.1 to rescue it.

CMakeLists.txt Outdated
Comment on lines 564 to 566
# Suppresses annoying ABI notes. See:
# https://stackoverflow.com/questions/52020305/what-exactly-does-gccs-wpsabi-option-do-what-are-the-implications-of-supressi
$<$<CXX_COMPILER_ID:GNU>:-Wno-psabi>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

GCC outputs these ABI notes. When compiling with -Werr those notes cause compilation to fail, but the notes explain gcc bugs, and are not singularity-eos problems. In the way we build singularity-eos (via spack or in-tree), ABI incompatibilities will never impact us.

Comment on lines +69 to +70
// JMM: Use VA_ARGS to capture more complex template types
#define SG_ADD_BASE_CLASS_USINGS(...) \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The problem here is that preprocessor macros interpret commas as separate arguments. This allows us to pass classes with multiple template arguments through the macro transparently.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice addition!

} \
}

#define SG_ADD_MODIFIER_MEAN_METHODS(t_) \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

split these out into separate modifier methods in preparation for isotopics.

template <typename Indexer_t = Real *>
PORTABLE_FORCEINLINE_FUNCTION Real GetScale_(Indexer_t &&lambda) const {
Real Z = GetIonizationState_(lambda);
if constexpr (ztype == ZSplitComponent::Electrons) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Notice the if constexpr here, which makes this a compile-time switch rather than runtime. We could make it runtime, but I chose not to. The trade-off here is that run-time would make the variant smaller. But compile time increases performance.

@Yurlungur
Copy link
Collaborator Author

Yurlungur commented Dec 17, 2024

Github updated the latest ubuntu runner to 24.04. This breaks everything. Actions taken:

  • For formatting, I pinned the runner to an older one. We'll need to resolve a formatting sweep later.
  • For other tests, I massaged build system or resolved caught warnings to keep things building.
  • For whatever reason gcc builds are much slower on 24.04 than previously. Builds are timing out. I have taken the following actions:
    • github runners have 4 threads. Now all github tests use make -j4
    • I shrank the default variant, removing some analytic equations of state. I would also like to remove the relativistic modifier from the variant by default, but it's too threaded through the python API. A problem for the future.
    • If that's not enough, I will disable Python builds from the github build.

@Yurlungur
Copy link
Collaborator Author

OK in addition to the timeout, the full fortran interface was running out of memory in the linker phase. Additional actions taken:

  • For github full test build, switch to -DCMAKE_BUILD_TYPE=Release which drops debug info
  • Remove user memory limits in the docker image
  • Switch to the ld.gold linker, which is faster and more memory efficient.

@@ -40,7 +40,7 @@ jobs:
-DSINGULARITY_USE_SPINER_WITH_HDF5=OFF \
-DSINGULARITY_FORCE_SUBMODULE_MODE=ON \
-B build .
cmake --build build
cmake --build build --parallel 4
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

builds the python bits faster. Speeds up doc build time by a factor of 4ish

@@ -9,7 +9,7 @@ on:
jobs:
formatting:
name: Check Formatting
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needed until we update clang-format to clang-17

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changes in this file required to deal with out-of-memory failure when linking the full fortran interface.

@@ -21,13 +21,15 @@ jobs:
- name: install dependencies
run: |
sudo apt-get update -y -qq
sudo apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages -qq build-essential gfortran libhdf5-serial-dev
sudo apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages -qq build-essential gfortran libhdf5-serial-dev binutils-gold
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

binutils-gold gets us use the gold linker developed by google specifically for big C++ projects. It seems to be much faster and more memory efficient. Generically I don't know if we want to rely on it, but honestly I was very impressed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll defer to @rbberger @dholladay00 and @mauneyc-LANL on their opinions here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah i think for now we don't need to change it elsewhere. In this particular CI test, this, GNU ld is too memory inefficient and the test doesn't finish without gold.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I could totally be wrong, but I have a bit of a hunch that among all the changes made, only the switch to Release is required. Should we be minimalistic here, or you are quite happy with binutils-gold?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was actually impressed by binutils-gold. The build time is also just faster with it on, so I'd like to leave it as this test takes about 10 minutes. That said, I'm fine removing it if (a) that still works and (b) people feel strongly.

Comment on lines +31 to +32
ulimit -m unlimited
ulimit -v unlimited
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure if this does anything inside a docker container, but it doesn't hurt.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But we could also be minimalistic if desirable... see above. No strong feelings here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll leave it. In worst case it does nothing.

-DSINGULARITY_PLUGINS=$(pwd)/../example/plugin \
-DCMAKE_LINKER=ld.gold \
-DCMAKE_BUILD_TYPE=Release \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Compared to the default build type, which is RelWithDebInfo, this drops debug symbols, shrinking the memory footprint during link stage.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm surprised that's such a huge memory hit to be honest. Honestly though, I find that if I really need debug symbols, I'm compiling with full Debug anyway so I'm okay with this change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah. I agree. Is also only for this test. The default build is still "RelWithDebInfo."

..
#-DSINGULARITY_TEST_PYTHON=ON \
#-DSINGULARITY_TEST_STELLAR_COLLAPSE=ON \
#..
make
make -j4
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

parallel build.

Comment on lines +577 to +579
# `-Wclass-memaccess now default with -Wall but we explicitly
# manage this ourselves in our serialization routines.
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<COMPILE_LANGUAGE:CXX>>:-Wno-class-memaccess>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is apparently a new warning. Since we sometimes build with -Werr its also an error. I am silencing it as memcpy is an intrinsic part of the serialization infrastructure and the heuristic that normally justifies warning doesn't apply in our case. We have introspection about the trivial and non-trivial copy properties of our data and we manage it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ping @rbberger just so you're aware

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ping @rbberger so you're aware

@Yurlungur
Copy link
Collaborator Author

Tests now passing on github and re-git.

@Yurlungur Yurlungur linked an issue Dec 18, 2024 that may be closed by this pull request
This was referenced Dec 18, 2024
@swjones
Copy link

swjones commented Dec 18, 2024

Looks good to me, tests added. The applicability of the Z-split is still not clear to me but that's something we will work on separately.

Copy link
Collaborator

@pdmullen pdmullen left a comment

Choose a reason for hiding this comment

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

LGTM! Non-blocking comments.

@@ -21,13 +21,15 @@ jobs:
- name: install dependencies
run: |
sudo apt-get update -y -qq
sudo apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages -qq build-essential gfortran libhdf5-serial-dev
sudo apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages -qq build-essential gfortran libhdf5-serial-dev binutils-gold
Copy link
Collaborator

Choose a reason for hiding this comment

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

I could totally be wrong, but I have a bit of a hunch that among all the changes made, only the switch to Release is required. Should we be minimalistic here, or you are quite happy with binutils-gold?

Comment on lines +31 to +32
ulimit -m unlimited
ulimit -v unlimited
Copy link
Collaborator

Choose a reason for hiding this comment

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

But we could also be minimalistic if desirable... see above. No strong feelings here.

singularity-eos/eos/modifiers/zsplit_eos.hpp Show resolved Hide resolved
singularity-eos/eos/modifiers/zsplit_eos.hpp Show resolved Hide resolved
Copy link
Collaborator

@jhp-lanl jhp-lanl left a comment

Choose a reason for hiding this comment

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

Minor changes

doc/sphinx/src/models.rst Outdated Show resolved Hide resolved
doc/sphinx/src/models.rst Show resolved Hide resolved
doc/sphinx/src/models.rst Outdated Show resolved Hide resolved
doc/sphinx/src/models.rst Outdated Show resolved Hide resolved
doc/sphinx/src/models.rst Show resolved Hide resolved
doc/sphinx/src/using-eos.rst Show resolved Hide resolved
Comment on lines +69 to +70
// JMM: Use VA_ARGS to capture more complex template types
#define SG_ADD_BASE_CLASS_USINGS(...) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice addition!

singularity-eos/eos/modifiers/zsplit_eos.hpp Show resolved Hide resolved
singularity-eos/eos/modifiers/zsplit_eos.hpp Show resolved Hide resolved
singularity-eos/eos/modifiers/zsplit_eos.hpp Show resolved Hide resolved
@Yurlungur
Copy link
Collaborator Author

Thanks @jhp-lanl and @pdmullen for the reviews! I think all comments should be addressed (as best they currently can with available physics fidelity). Regarding thermodynamic derivatives... I wonder if we can do better down the line. Something to consider once we have access to an ionization model.

@jhp-lanl
Copy link
Collaborator

Regarding thermodynamic derivatives... I wonder if we can do better down the line. Something to consider once we have access to an ionization model.

I completely agree. Not something to tackle now, but definitely something to keep in mind

@Yurlungur Yurlungur merged commit 70dfc73 into main Dec 18, 2024
8 checks passed
@Yurlungur Yurlungur deleted the jmm/zsplit branch December 18, 2024 21:21
@Yurlungur
Copy link
Collaborator Author

Thanks all! Merged. 🎊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request interface Library interface work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Smaller default variant
5 participants