Skip to content

feat(cad): Sneed-Folk maximum-projection sphericity#406

Merged
nochallenge merged 1 commit into
masterfrom
feat/cad-max-projection-sphericity
Jun 8, 2026
Merged

feat(cad): Sneed-Folk maximum-projection sphericity#406
nochallenge merged 1 commit into
masterfrom
feat/cad-max-projection-sphericity

Conversation

@nochallenge

Copy link
Copy Markdown
Owner

What

Adds measure::solid_bounding_box_max_projection_sphericity and _tol — the Sneed-Folk maximum-projection sphericity:

// psi_p = cbrt(c^2 / (a*b))   (dimensionless, in (0, 1]),  a >= b >= c sorted AABB extents

Why

The AABB shape family has the Zingg pair (elongation #375, flatness #381) and the Corey shape factor (#387), but not the maximum-projection sphericity — the ratio of a particle's maximum projection area to that of an equal-volume sphere, a classic sedimentology descriptor. psi_p = 1 for an equant cube/sphere and drops toward 0 for a blade/rod/disc. It is corey_shape_factor^(2/3) — a clean non-tautological cross-check. A degenerate solid (zero intermediate/longest extent) returns CadError::Tessellation.

Test

solid_bounding_box_max_projection_sphericity_is_cbrt_c2_over_ab:

Both fns re-exported from lib.rs alphabetically. valenx-cad 68 lib tests (was 67); cargo clippy -p valenx-cad --all-targets -- -D warnings clean. Research-grade particle-shape descriptor.

Add measure::solid_bounding_box_max_projection_sphericity[_tol], the
Sneed-Folk maximum-projection sphericity:

  psi_p = cbrt(c^2 / (a*b))   (dimensionless, in (0, 1])

where a >= b >= c are the sorted AABB extents -- a classic sedimentology
particle-shape descriptor (the ratio of the particle's maximum projection
area to that of an equal-volume sphere): 1 for an equant cube/sphere,
small for a blade, rod, or disc. It is the cube root of the
corey_shape_factor squared, psi_p = CSF^(2/3) (#387). Mirrors corey but
with cbrt(c^2/(ab)); degenerate (zero intermediate/longest extent) ->
CadError::Tessellation.

Analytic test solid_bounding_box_max_projection_sphericity_is_cbrt_c2_over_ab:
(a) worked box(2,4,6) -> cbrt(1/6) ~= 0.55032;
(b) threads solid_bounding_box_extents (#363): cbrt(s0^2/(s1*s2));
(c) cross-check threading corey_shape_factor (#387) (non-tautological):
    psi_p = CSF^(2/3);
(d) range 0 < psi_p <= 1; cube and sphere -> 1 (equant);
(e) _tol wrapper agrees with the default.

Both fns re-exported from lib.rs alphabetically. valenx-cad 68 lib tests
(was 67), cargo clippy --all-targets -D warnings clean.
@nochallenge nochallenge merged commit cff9bed into master Jun 8, 2026
@nochallenge nochallenge deleted the feat/cad-max-projection-sphericity branch June 8, 2026 19:10
nochallenge added a commit that referenced this pull request Jun 8, 2026
Add FlowSolution::vorticity_std_dev(), the standard deviation of the
interior vorticity:

  sigma_omega = sqrt( <(omega - <omega>)^2> )   (1/s)

the spatial fluctuation of the central-difference vorticity about its
area-average, completing the mean / rms / std vorticity-statistics triad
(mean_vorticity #400, rms_vorticity #406). By the variance identity it
satisfies sigma^2 = omega_rms^2 - <omega>^2. Mirrors pressure_std_dev's
deviation-sum form (mean via mean_vorticity, then sum (omega-mean)^2);
returns 0 for a grid too small (nx < 3 or ny < 3).

Analytic test vorticity_std_dev_completes_the_variance_identity:
(a) uniform shear u(y)=gamma*y has constant omega = -gamma -> sigma = 0;
(b) quadratic shear u(y)=a*y^2 has omega = -2a*y varying in space ->
    sigma > 0, and the variance identity sigma = sqrt(omega_rms^2 -
    <omega>^2) threads mean_vorticity + rms_vorticity (three separate
    loops, non-tautological);
(c) grid too small for an interior difference -> 0.

Pure method on FlowSolution, no lib.rs change. cfd-native 124 lib tests
(was 123), cargo clippy --all-targets -D warnings clean.
nochallenge added a commit that referenced this pull request Jun 8, 2026
Add FlowSolution::rms_divergence(), the root-mean-square divergence over
all nx*ny cells:

  rms = sqrt( <(div u)^2> )   (1/s)

the L2 continuity residual. Unlike the signed mean_divergence (whose +/-
cells cancel), the RMS sums squares so it never cancels -- the standard
convergence metric for how well the discrete continuity constraint
div u = 0 is satisfied. The square-summing companion to the signed mean
(#417) and the peak max_divergence, mirroring rms_vorticity (#406).

Analytic test rms_divergence_is_the_l2_continuity_residual:
(a) solenoidal shear -> rms = 0;
(b) uniform expansion (div u = c everywhere) -> rms = c, and for the
    constant field rms == mean == max (threads both, non-tautological);
(c) sign-varying "tent" (div u = [c,c,c,-c,-c] per row) -> rms = c while
    the signed mean cancels to c/5, so rms > |mean| (the RMS catches the
    local violations the mean misses);
(d) zero-flow -> 0.

Pure method on FlowSolution, no lib.rs change. cfd-native 126 lib tests
(was 125), cargo clippy --all-targets -D warnings clean.
nochallenge added a commit that referenced this pull request Jun 8, 2026
Add FlowSolution::rms_strain_rate(), the root-mean-square rate-of-strain
magnitude over the interior cells:

  rms = sqrt( <|S|^2> )   (1/s)

the L2 deformation rate. Since |S|^2 = 2 S_ij S_ij, this is the quantity
that sets the viscous dissipation eps = 2*nu*<S_ij S_ij> = nu*<|S|^2>, so
it measures how strongly the flow is being strained (and thus dissipating
energy). Completes the strain-rate family (at_cell / max / mean / rms),
mirroring rms_vorticity (#406).

Analytic test rms_strain_rate_is_the_l2_deformation_rate:
(a) pure shear u(y)=gamma*y -> |S|=gamma uniformly -> rms=gamma, and since
    |S|=|omega|=gamma for a pure shear, rms_strain_rate == rms_vorticity
    (threads rms_vorticity via the grad-u decomposition);
(b) solid-body rotation -> rms strain = 0 while rms vorticity = 2*Omega
    (strain != rotation);
(c) non-uniform quadratic shear -> rms >= mean > 0 (Jensen);
(d) grid too small for an interior difference -> 0.

Pure method on FlowSolution, no lib.rs change. cfd-native 128 lib tests
(was 127), cargo clippy --all-targets -D warnings clean.
nochallenge added a commit that referenced this pull request Jun 8, 2026
Add FlowSolution::mean_dissipation_rate(kinematic_viscosity), the rate at
which the flow irreversibly converts kinetic energy to heat by viscosity:

  eps = nu * <|S|^2> = nu * (rms_strain_rate)^2   (m^2/s^3, per unit mass)

the quantity that closes the turbulent energy budget (the Kolmogorov
cascade rate). Since |S|^2 = 2 S_ij S_ij, eps = 2*nu*<S_ij S_ij>. It is
the strain-squared companion to rms_strain_rate (#428), threading it
directly. A pure rotation strains nothing and dissipates nothing; only
deformation dissipates.

Analytic test mean_dissipation_rate_is_viscosity_times_strain_squared:
(a) worked: pure shear u(y)=gamma*y, |S|=gamma, nu=0.1 -> eps=nu*gamma^2=0.4;
(b) threads rms_vorticity (#406) (non-tautological): for a pure shear
    |S|=|omega|, so eps = nu*rms_vorticity^2;
(c) solid-body rotation -> no strain -> no dissipation (even though it spins);
(d) proportional to nu, and zero at nu=0.

Pure method on FlowSolution, no lib.rs change. cfd-native 129 lib tests
(was 128), cargo clippy --all-targets -D warnings clean.
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