Repository navigation
Fix get_ilayer: select the ablating layer from the radius at the start of the step - #13
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A pellet with more than one layer is ablated with the model of layer 1 for its whole flight.
ablate!callsdr_dt!(pelt, k), which callsget_ilayer(pelt, k), before stepkhas computedpelt.radius[k]. That entry is still0.0from the initialisation inPellet.get_ilayerreads it, finds every entry ofradius .- 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_ilayernow 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 inPelletimplies, whose outer radius reaches it.Test
A new
get_ilayertestset 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. Onmasterthe 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