Skip to content

Fix get_ilayer: select the ablating layer from the radius at the start of the step - #13

Merged
jmcclena merged 1 commit into
ProjectTorreyPines:masterfrom
omeneghini-pf:fix-get-ilayer
Nov 24, 2026
Merged

jmcclena merged 1 commit into
ProjectTorreyPines:masterfrom
omeneghini-pf:fix-get-ilayer

Conversation

@omeneghini-pf

Copy link
Copy Markdown
Contributor

Problem

A pellet with more than one layer is ablated with the model of layer 1 for its whole flight.

ablate! calls dr_dt!(pelt, k), which calls get_ilayer(pelt, k), before step k has computed pelt.radius[k]. That entry is still 0.0 from the initialisation in Pellet. get_ilayer reads it, finds every entry of radius .- cumsum(thickness) negative, and returns 1.

Given the correct radius, it would still pick the wrong layer. It returns the last layer whose outer radius is at or below the pellet radius. That is the layer inside the one that holds the surface: for a 0.7 mm core under a 0.3 mm shell, a pellet of 0.9 mm radius gets the core.

Fix

get_ilayer now takes the radius at the start of the step, pelt.radius[k-1]. It returns the first layer, counting from the innermost as the thickness check in Pellet implies, whose outer radius reaches it.

Test

A new get_ilayer testset builds a two-layer pellet (0.7 mm core, 0.3 mm shell) on the D3D template. It checks the layer at radii of 1.0, 0.8, 0.7 and 0.2 mm. On master the two radii inside the shell return layer 1 instead of 2; with this change all four pass. The existing tests use single-layer pellets and are unchanged.

🤖 Generated with Claude Code

…t of the step

ablate! calls dr_dt!(pelt, k) before step k has set pelt.radius[k], which is still 0.0, so get_ilayer returned layer 1 for every step and a multi-layer pellet ablated with the first layer's model throughout. It also compared the radius with the layers' outer radii, which picks the layer inside the one holding the surface.

get_ilayer now takes pelt.radius[k-1] and returns the first layer, innermost first, whose outer radius reaches it. Adds a unit test on a two-layer pellet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jmcclena
jmcclena merged commit db201d4 into ProjectTorreyPines:master Nov 24, 2026
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.

2 participants