Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
caa6a19
Added new ParticleHDF class to generalize EXP HDF5 particle writing a…
Aug 14, 2026
0b48448
Added new ParticleHDF5 class header
Aug 14, 2026
369a778
Cherry pick the refactoring of 1d mass models from slabUpdate
Aug 14, 2026
5852d9a
Remove a stray character
Aug 14, 2026
c0a1bf1
Add a Python HDF5 IC check script
Aug 14, 2026
ffcf140
Tweaked the test profiles to allow user-specified total mass and make…
Aug 14, 2026
4fe6b80
Added mass on spherical table as a particle check
Aug 14, 2026
df779e1
Add HDF5 file generation to Zang ICs; update the mass tolerance
Aug 14, 2026
a495833
Allow use of non-MPI applications
Aug 14, 2026
18a0ce9
Potential fix for pull request finding
The9Cat Aug 14, 2026
828b00a
Potential fix for pull request finding
The9Cat Aug 14, 2026
4d2c233
Potential fix for pull request finding
The9Cat Aug 14, 2026
658a799
Potential fix for pull request finding
The9Cat Aug 14, 2026
f4bd1b7
Potential fix for pull request finding
The9Cat Aug 14, 2026
bff80dd
Potential fix for pull request finding
The9Cat Aug 14, 2026
103f3e0
Add gendisk HDF5 schema CTest coverage
Copilot Aug 14, 2026
86fc6c7
Add gendisk2d HDF5 CTest coverage
Copilot Aug 14, 2026
1f52901
test: add gendisk halo hdf5 schema check
Copilot Aug 14, 2026
1480253
Reduce root memory overhead in gathered HDF5 writes
Copilot Aug 14, 2026
fd116a9
Removed gas particle tests, decrease basis resolution to speed up tes…
Aug 15, 2026
97231fc
gendisk2d needs a smaller default RMIN to match the table
Aug 15, 2026
3e8d002
Apply suggestions from code review
The9Cat Aug 16, 2026
c5f0c07
Added compression to save some disk space
Aug 16, 2026
3746903
Merge branch 'generateHDF5ICs' of github.com:EXP-code/EXP into genera…
Aug 16, 2026
43bbc93
Change hsize_t to size_t to try to keep Clang happy
Aug 16, 2026
581199f
Another try at type matching
Aug 16, 2026
a51ac72
Potential fix for pull request finding
The9Cat Aug 16, 2026
f7d63fd
Missing commit of pyEXP updates for Cylindrical, oops
Aug 16, 2026
4d1654f
Change IC generation defaults to HDF5 and H5compress=5
Copilot Aug 16, 2026
90c5686
Merge branch 'devel' into generateHDF5ICs
Nov 30, 2026
746be22
Update output command for multiple ranks
The9Cat Nov 30, 2026
8ec93eb
Apply center-file offsets to HDF5 output
The9Cat Nov 30, 2026
9777608
Add standard library includes to massmodel1d.H
The9Cat Nov 30, 2026
65fe38e
Refactor energy conversion and return value logic
The9Cat Nov 30, 2026
4f8a34b
Correctly handle centering for HDF5 phase space
Nov 30, 2026
25458fe
Merge branch 'generateHDF5ICs' of github.com:EXP-code/EXP into genera…
Nov 30, 2026
3e4e18b
Updated centering for HDF5 output for gendisk and gendisk2d. The two
Nov 30, 2026
d919ea3
Added center checking to round-trip HDF5 script
Nov 30, 2026
cda1cd1
Check for filter specification and I/O status
Nov 30, 2026
9074ed1
Check for filter specification and I/O status
Nov 30, 2026
62a7d80
Provide additional filter setting and checking
Nov 30, 2026
e269384
Prevent test cruft from entering the repository
Nov 30, 2026
670358b
Prevent PyEXP from setting the global default compression unless expl…
Nov 30, 2026
a89b74f
Provide errors when caches and body files fail to write
Nov 30, 2026
435651b
Cubics should be a serial test, not MPI
Nov 30, 2026
f40f149
Proper return value and spelling error fix
Nov 30, 2026
329c8f7
Remove artifacts
Nov 30, 2026
bd86fdd
Update for implemented set of compression filters
Nov 30, 2026
68e0548
Updated logic to handle the correct compress filter combinations
Nov 30, 2026
f9ade36
Updated test script exercise HDF5 filter compression combinations
Nov 30, 2026
f6b84b8
Updated logic so that tests will run correctly in environments where …
Dec 1, 2026
3e514a7
Added a helper function to check for filter failures in the log file;…
Dec 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential libeigen3-dev libfftw3-dev libhdf5-dev libopenmpi-dev libomp-dev python3-numpy
sudo apt-get install -y build-essential libeigen3-dev libfftw3-dev libhdf5-dev libopenmpi-dev libomp-dev python3-numpy python3-h5py

- name: Verify HDF5 test dependencies
run: /usr/bin/python3 -c "import h5py, numpy"

- name: Setup submodule and build
run: |
Expand All @@ -52,6 +55,7 @@ jobs:
-DENABLE_NBODY=YES
-DENABLE_PYEXP=YES
-DCMAKE_BUILD_TYPE=Release
-DPython3_EXECUTABLE=/usr/bin/python3
-DEigen3_DIR=/usr/include/eigen3/share/eigen3/cmake
-DCMAKE_INSTALL_PREFIX=./install
-DCMAKE_CXX_FLAGS=${{ matrix.cxxflags }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ src/user/EllipsoidForce.cc
src/user/SLSphere.cc
_codeql_build_dir
_codeql_detected_source_root
__pycache__/
Testing/
7 changes: 7 additions & 0 deletions expui/BiorthBasis.H
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _BiorthBasis_H
#define _BiorthBasis_H

#include <optional>
#include <functional>
#include <tuple>
#include <map>
Expand Down Expand Up @@ -985,6 +986,12 @@ namespace BasisClasses
double rcylmin, rcylmax, acyl, hcyl, bias;
bool expcond, logarithmic, density, EVEN_M, sech2 = true;

//! Basis-cache compression. Only set when given in the YAML
//! config; otherwise the EmpCylSL defaults (as used by EXP and
//! gendisk) are left untouched.
std::optional<int> H5compress;
std::optional<bool> H5shuffle;

std::vector<Eigen::MatrixXd> potd, dpot, dpt2, dend;
std::vector<Eigen::MatrixXd> legs, dlegs, d2legs;

Expand Down
22 changes: 19 additions & 3 deletions expui/BiorthBasis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,9 @@ namespace BasisClasses
"pyproj",
"nint",
"totalCovar",
"fullCovar"
"fullCovar",
"H5compress",
"H5shuffle"
};

Cylindrical::Cylindrical(const YAML::Node& CONF) :
Expand Down Expand Up @@ -1529,10 +1531,20 @@ namespace BasisClasses
if (conf["vflag" ]) vflag = conf["vflag" ].as<int>();
if (conf["pyname" ]) pyname = conf["pyname" ].as<std::string>();
if (conf["pyproj" ]) pyproj = conf["pyproj" ].as<std::string>();
if (conf["pcavar"] ) pcavar = conf["pcavar" ].as<bool>();
if (conf["subsamp"] ) sampT = conf["subsamp" ].as<int>();
if (conf["pcavar" ]) pcavar = conf["pcavar" ].as<bool>();
if (conf["subsamp" ]) sampT = conf["subsamp" ].as<int>();
if (conf["samplesz" ]) sampT = conf["samplesz" ].as<int>();

if (conf["H5compress"]) H5compress = conf["H5compress"].as<int>();
if (conf["H5shuffle" ]) H5shuffle = conf["H5shuffle" ].as<bool>();

if (H5compress and (*H5compress < 0 or *H5compress > 9)) {
if (myid==0)
std::cerr << "---- Cylindrical: WARNING, H5compress must be between 0 and 9"
<< " (got " << *H5compress << "); using the default" << std::endl;
H5compress.reset();
}

// Sanity
sampT = std::max(1, sampT);

Expand Down Expand Up @@ -1604,6 +1616,10 @@ namespace BasisClasses
EmpCylSL::CMAPZ = cmapZ;
EmpCylSL::logarithmic = logarithmic;
EmpCylSL::VFLAG = vflag;
// Only override the EmpCylSL cache-compression defaults when the
// YAML config sets them
if (H5compress) EmpCylSL::H5compress = *H5compress;
if (H5shuffle ) EmpCylSL::H5shuffle = *H5shuffle;

// Convert dmodel string to lower case (deprojection model for EOF
// basis construction)
Expand Down
87 changes: 74 additions & 13 deletions exputil/EmpCylSL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ double EmpCylSL::RMAX = 20.0;
double EmpCylSL::HFAC = 0.2;
double EmpCylSL::PPOW = 4.0;
bool EmpCylSL::NewCoefs = true;
int EmpCylSL::H5compress = 5;
bool EmpCylSL::H5shuffle = false;


EmpCylSL::EmpModel EmpCylSL::mtype = EmpCylSL::EmpModel::Exponential;
Expand Down Expand Up @@ -994,7 +996,9 @@ int EmpCylSL::cache_grid(int readwrite, std::string cachename)

if (readwrite) {

// Check for new HDF5 file
// Check for new HDF5 file. The exists/rename/create sequence is
// not atomic: independent jobs writing the same cache file name
// concurrently are unsupported (see cache_grid in EmpCylSL.H).
if (std::filesystem::exists(cachefile)) {
if (myid==0)
std::cout << "---- EmpCylSL::cache_grid: cache file <"
Expand Down Expand Up @@ -2403,6 +2407,22 @@ void EmpCylSL::generate_eof(int numr, int nump, int numt,
Timer timer;
if (VFLAG & 16) timer.start();

// Sanity check on quadrature parameters
//
numr = std::max<int>(1, numr);
nump = std::max<int>(1, nump);
numt = std::max<int>(1, numt);

if (myid==0 and numr < 10) {
std::cerr << "EmpCylSL: Warning, numr=" << numr
<< " is very small for quadrature" << std::endl;
}

if (myid==0 and numt < 10) {
std::cerr << "EmpCylSL: Warning, numt=" << numt
<< " is very small for quadrature" << std::endl;
}

// Create spherical orthogonal basis if necessary
//
if (not ortho) {
Expand Down Expand Up @@ -2667,7 +2687,7 @@ void EmpCylSL::generate_eof(int numr, int nump, int numt,

} // *** r quadrature loop

if (VFLAG & 8) {
if (VFLAG & 16) {
auto t = timer.stop();
if (myid==0) {
std::cout << std::endl
Expand Down Expand Up @@ -2700,7 +2720,7 @@ void EmpCylSL::generate_eof(int numr, int nump, int numt,
//
make_eof();

if (VFLAG & 8) {
if (VFLAG & 16) {
cout << "Process " << setw(4) << myid << ": completed basis in "
<< timer.stop() << " seconds"
<< endl;
Expand Down Expand Up @@ -7463,6 +7483,39 @@ void EmpCylSL::WriteH5Cache()
file.createAttribute<int> ("eof_numt", HighFive::DataSpace::From(eof_vars.numt)).write(eof_vars.numt);


// To write an Eigen::MatrixXd with compression in HighFive, we we
// create the dataset with explicit chunk sizes and a deflation
// (gzip) filter before writing, because shortcut functions do not
// pass compression parameters.

auto dcpl = HighFive::DataSetCreateProps{};

// Define dimensions
std::vector<size_t> dims {static_cast<size_t>(NUMX+1),
static_cast<size_t>(NUMY+1)};

// Dataspace size definition
HighFive::DataSpace ds(dims);

// Define chunk size (e.g., matching matrix size or split into blocks)
std::vector<hsize_t> chunk_dims {static_cast<hsize_t>(NUMX+1),
static_cast<hsize_t>(NUMY+1)};

// Deflate only accepts levels 0-9; clamp rather than lose the
// cache to an HDF5 error
int level = H5compress;
if (level > 9) {
std::cerr << "---- EmpCylSL::WriteH5Cache: WARNING, H5compress="
<< H5compress << " is out of range [0, 9]; using 9" << std::endl;
level = 9;
}

if (level>0) {
dcpl.add(HighFive::Chunking(chunk_dims));
if (H5shuffle) dcpl.add(HighFive::Shuffle());
dcpl.add(HighFive::Deflate(level));
}

// Cosine functions

auto cosine = file.createGroup("Cosine");
Expand All @@ -7480,10 +7533,10 @@ void EmpCylSL::WriteH5Cache()
sout << n;
auto order = harmonic.createGroup(sout.str());

order.createDataSet("potC", potC [m][n]);
order.createDataSet("rforceC", rforceC[m][n]);
order.createDataSet("zforceC", zforceC[m][n]);
order.createDataSet("densC", densC [m][n]);
order.createDataSet<double>("potC", ds, dcpl).write(potC [m][n]);
order.createDataSet<double>("rforceC", ds, dcpl).write(rforceC[m][n]);
order.createDataSet<double>("zforceC", ds, dcpl).write(zforceC[m][n]);
order.createDataSet<double>("densC", ds, dcpl).write(densC [m][n]);
}
}

Expand All @@ -7504,15 +7557,23 @@ void EmpCylSL::WriteH5Cache()
sout << n;
auto order = harmonic.createGroup(sout.str());

order.createDataSet("potS", potS [m][n]);
order.createDataSet("rforceS", rforceS[m][n]);
order.createDataSet("zforceS", zforceS[m][n]);
order.createDataSet("densS", densS [m][n]);
order.createDataSet<double>("potS", ds, dcpl).write(potS [m][n]);
order.createDataSet<double>("rforceS", ds, dcpl).write(rforceS[m][n]);
order.createDataSet<double>("zforceS", ds, dcpl).write(zforceS[m][n]);
order.createDataSet<double>("densS", ds, dcpl).write(densS [m][n]);
}
}

} catch (HighFive::Exception& err) {
std::cerr << err.what() << std::endl;
} catch (const std::exception& err) {
std::cerr << std::endl
<< "**** EmpCylSL::WriteH5Cache: WARNING, FAILED to write the basis cache <"
<< cachefile << ">" << std::endl
<< "**** HDF5 error: " << err.what() << std::endl
<< "**** The basis in memory is fine, but the cache file is missing or"
<< " incomplete and will" << std::endl
<< "**** not be reusable; it will need to be regenerated next time."
<< std::endl << std::endl;
return;
}

std::cout << "---- EmpCylSL::WriteH5Cache: "
Expand Down
21 changes: 19 additions & 2 deletions include/EmpCylSL.H
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,17 @@ struct eof_variables {

//! The cache file name
std::string cachefile;
// 1=write, 0=read
// return: 0=failure
/** Read (0) or write (1) the basis cache; returns 0 on failure.

Writing is done by the root process only and is safe within one
run. Writing renames an existing cache to <file>.bak and then
creates <file>. This sequence is not protected against other
processes, so independent jobs (separate EXP, gendisk or pyEXP
runs) that write the same cache file name at the same time are
NOT supported: they can lose or overwrite each other's cache or
backup. Give concurrent jobs distinct cache file names, or
generate the cache once and let the other jobs read it.
*/
int cache_grid(int, std::string file);
double integral(int, int, int, int);
void get_pot(Eigen::MatrixXd&, Eigen::MatrixXd&, double, double);
Expand Down Expand Up @@ -448,6 +457,14 @@ public:
//! No extrapolating beyond grid (default: false)
static bool enforce_limits;

//! H5compression level (default: 5; good compromise between speed
//! and compression factor)
static int H5compress;

//! H5shuffle (default: false; tests suggests that shuffling makes
//! cache compression worse)
static bool H5shuffle;

/**
@brief Density model type
Available options:
Expand Down
14 changes: 12 additions & 2 deletions include/massmodel1d.H
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#ifndef _massmodel1d_H
#define _massmodel1d_H

#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <map>
#include <sstream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <tuple>
#include <vector>

#include "massmodel.H"
#include "biorth1d.H"
Expand Down Expand Up @@ -836,8 +845,9 @@ public:
// Convert energy to potential, so that the distribution function
// is nonzero only. That is, assume E = Omega*Ja, not zero at +/-
// H.
double J = fabs(E + M_PI*H)/Omega;
return -0.5*Omega*norm / std::pow(Jmax - J + epsilon, 1.5);
double shifted = E + M_PI*H;
double J = fabs(shifted)/Omega;
return std::copysign(0.5*norm / (Omega * std::pow(Jmax - J + epsilon, 1.5)), shifted);
}

double dfdv(const double E, const double p=0.0)
Expand Down
Loading
Loading