Skip to content

Slab force update - #215

Merged
The9Cat merged 135 commits into
develfrom
slabUpdate
Nov 30, 2026
Merged

The9Cat merged 135 commits into
develfrom
slabUpdate

Conversation

@The9Cat

@The9Cat The9Cat commented Apr 5, 2026 •

Copy link
Copy Markdown
Member

Updates for consistency with the current conventions

  1. Density for isothermal slab is now proportional to sech(z/2h)^2 rather than sech(z/h)^2
  2. SlablSL now implements the self_consistent flag for enabling a frozen potential
  3. Added a version # to the slab cache along with a user warning about this change

One general development support feature

Added compile -time parsing of the EXP version string into major, minor, patch for internal version control logic. E.g.

#include <iostream>
#include "libvars.H"
using namespace __EXP__;

int main()
{
  std::cout << "Major=" << exp_build.major << '\n';
  std::cout << "Minor=" << exp_build.minor << '\n';
  std::cout << "Patch=" << exp_build.patch << '\n';
  return 0;
}

This will make future version-dependent toggles easier to implement. We have a usage example in both SLGridSlab and in utils/Test.

Other updates

The slab implementation now supports independent horizontal periods consistently across basis construction, cache validation, coordinate wrapping, and force evaluation on CPU and CUDA. This PR also adds 1D slab model/orbit utilities and extends slab IC generation, HDF5 output, diagnostics, and pyEXP bindings.

@The9Cat The9Cat added the enhancement New feature or request label Apr 5, 2026
@The9Cat
The9Cat requested a review from Copilot April 5, 2026 19:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the slab force/basis implementation to match current conventions (isothermal slab profile normalization, cache versioning, and a self_consistent “frozen potential” mode) and adds compile-time parsing of the EXP version string for internal version-dependent logic.

Changes:

  • Switch isothermal slab model normalization to use a sech^2(z/2H) form and warn users when running older EXP versions.
  • Add a self_consistent configuration flag to SlabSL to support freezing the potential coefficients.
  • Add compile-time EXP version parsing (EXPversion.H, exp_build) and a small test utility; add slab cache version attribute.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
utils/Test/version_test.cc Adds a small example program that prints VERSION and parsed major/minor/patch.
utils/Test/CMakeLists.txt Builds the new vtest utility.
utils/ICs/bonnerebert.cc Removes the local VERSION macro and the -V version flag handling.
src/SlabSL.H Documents self_consistent and adds storage for frozen coefficients.
src/SlabSL.cc Adds YAML parsing for self_consistent and uses frozen coefficients during force evaluation.
src/cudaSlabSL.cu Uses frozen coefficients when copying coefficients to the GPU if self_consistent=false.
include/SLGridMP2.H Adds cache versioning for slab cache and improves internal grouping/comments.
include/libvars.H Exposes exp_build as a compile-time parsed {major,minor,patch} version triple.
include/EXPversion.H Introduces a constexpr version-string parser.
exputil/SLGridMP2.cc Updates isothermal slab profile functions and adds slab cache version checks/write.
exputil/libvars.cc Ensures config header is included in libvars translation unit.
expui/BiorthBasis.cc Allows self_consistent as a recognized YAML key for the slab basis config.
Comments suppressed due to low confidence (1)

utils/ICs/bonnerebert.cc:404

  • The -V/--version option was removed from getopt_long parsing, but long_options still defines a version entry and usage() still advertises -V. This makes the CLI help incorrect and --version will likely behave unexpectedly (depending on getopt_long behavior). Either restore handling for -V/--version or remove it consistently from long_options and the usage text.
			   "R:"	/* runit   */
			   "N:"	/* number  */
			   "S:"	/* seed    */
			   "h", /* help    */
			   long_options, (int *) 0)) != EOF)
    {
      switch (c)
	{
	case 'o':		/* --output */
	  oname = string(optarg);
	  break;
	case 'd':		/* --xstep */
	  h = atof(optarg);
	  break;
	case 'r':		/* --ratio */
	  Rratio = atof(optarg);
	  break;
	case 'R':		/* --runit */
	  R = atof(optarg);
	  break;
	case 'M':		/* --munit */
	  Munit = atof(optarg);
	  break;
	case 'm':		/* --mass */
	  M = atof(optarg);
	  break;
	case 'T':		/* --temp */
	  T = atof(optarg);
	  break;
	case 'N':		/* --number */
	  N = atoi(optarg);
	  break;
	case 'S':		/* --seed */
	  S = atoi(optarg);
	  break;
	case 'h':
	  usage (0);

	default:
	  usage (-1);
	}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/SlabSL.cc Resolved
Comment thread src/SlabSL.H Resolved
Comment thread src/SlabSL.H Resolved
Comment thread exputil/SLGridMP2.cc Resolved
Comment thread exputil/SLGridMP2.cc Resolved
Comment thread include/EXPversion.H Resolved
Comment thread utils/Test/version_test.cc Resolved
The9Cat and others added 7 commits April 5, 2026 16:33
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@The9Cat

The9Cat commented Apr 5, 2026

Copy link
Copy Markdown
Member Author

@michael-petersen I am probably the only one that uses the slab stuff and these changes implement some of the standard features from the other force classes. So no need for you to spend time on most of this. It's all tested and seems to work.

However, note that this PR adds a compile-time function that parses the CMake-generated VERSION string into a structure of three ints (major, minor, patch) that may be used to gate various features rather than reverting to some sort of on-the-fly parse of the VERSION for each case or using CPP macros (yuck). The structure, named EXPversion, is a global library variable compiled into exputil. E.g. this PR uses the EXPversion instance to alert the user to the scale height convention change for the the isothermal disk. Your comments on this bit will be helpful I think.

Copilot AI commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

@michael-petersen I am probably the only one that uses the slab stuff and these changes implement some of the standard features from the other force classes. So no need for you to spend time on most ...

The version_test.cc file now consistently uses "integer triplet" in both the file comment and the runtime output (commit b7ed7eb). The other resolved review comments were already addressed in earlier commits on this branch.

Martin D. Weinberg and others added 28 commits July 27, 2026 11:59
1. CPU and CUDA now wrap horizontal positions using the configured Lx
and Ly, including negative coordinates and multistep
updates. See src/SlabSL.cc:542 and src/cudaSlabSL.cu:336

2. The vertical eigensolver now uses
\(2\pi\sqrt{(k_x/L_x)^2+(k_y/L_y)^2}\) in both serial and MPI
runs. Unequal periods store separate entries for (kx, ky) and (ky,
kx), with matching cache and CUDA lookups. See
exputil/SLGridMP2.cc:2953 and exputil/SLGridMP2.cc:3341.

3. Public slab force evaluation now includes the 1/Lx and 1/Ly
derivative factors. See expui/BiorthBasis.cc:4213

4. The covariance index check now validates 0 <= kz < nmaxz. See
expui/BiorthBasis.cc:4494.

Focused regressions passed in serial and with one and two MPI ranks,
covering periodic equivalence, force agreement with finite
differences, rectangular modes, cache reloads, and index bounds. All
changed C++ and CUDA files compiled. I have not checked GPU execution.
@The9Cat
The9Cat merged commit 26ce83b into devel Nov 30, 2026
8 checks passed
@The9Cat
The9Cat deleted the slabUpdate branch November 30, 2026 17:31
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.

4 participants