Skip to content

feat: separate ThermoParams/GridParams for v0.3.0#218

Merged
MasanoriKanamaru merged 14 commits into
mainfrom
feat/thermo-grid-params
Jul 1, 2026
Merged

feat: separate ThermoParams/GridParams for v0.3.0#218
MasanoriKanamaru merged 14 commits into
mainfrom
feat/thermo-grid-params

Conversation

@MasanoriKanamaru

Copy link
Copy Markdown
Member

Summary

  • Extract GridParams from the monolithic ThermoParams so that thermophysical material properties and numerical grid configuration are held in separate, focused types
  • Add keyword-argument constructors for both types and a mixed scalar/vector constructor for ThermoParams
  • Update all problem constructors, solvers, and tests to the new API

Changes

New type: GridParams

# Keyword constructor (recommended) — Δz is auto-computed
grid_params = GridParams(; z_max=0.6, n_depth=61)

# Positional constructor — explicit Δz (advanced use)
grid_params = GridParams(z_max, n_depth, Δz)

Fields: z_max, n_depth, Δz (primary params first, derived last).

Redesigned ThermoParams

# Keyword constructor (recommended)
thermo_params = ThermoParams(
    conductivity    = 0.1,
    density         = 1270.0,
    heat_capacity   = 600.0,
    reflectance_vis = 0.04,
    reflectance_ir  = 0.0,
    emissivity      = 1.0,
)

# Mixed scalar/vector — scalars are auto-broadcast to match vector length
thermo_params = ThermoParams(
    conductivity    = [0.1, 0.3, ...],  # per-face vector
    density         = 1270.0,           # scalar → broadcast
    heat_capacity   = 600.0,
    reflectance_vis = [0.04, 0.1, ...],
    reflectance_ir  = 0.0,
    emissivity      = 1.0,
)

Updated problem constructors

# Single asteroid
problem = SingleAsteroidThermoPhysicalProblem(shape, thermo_params, grid_params; ...)

# Binary asteroid — per-body or shared params
problem = BinaryAsteroidThermoPhysicalProblem(
    (shape1, shape2),
    (thermo_params1, thermo_params2),
    (grid_params1, grid_params2);
    ...
)
# shared:
problem = BinaryAsteroidThermoPhysicalProblem(
    (shape1, shape2), thermo_params, grid_params; ...
)

Breaking Changes

Before (v0.2.x) After (v0.3.0)
ThermoParams(k, ρ, Cₚ, R_vis, R_ir, ε, z_max, Δz, n_depth) ThermoParams(…) + GridParams(; z_max, n_depth)
thermo_params.thermal_conductivity thermo_params.conductivity
thermo_params.n_depth / .Δz grid_params.n_depth / .Δz
Problem(shape, thermo_params; …) Problem(shape, thermo_params, grid_params; …)
broadcast_thermo_params! removed (expansion happens at construction time)

Test plan

  • Unit tests for ThermoParams: scalar, keyword, vector, mixed scalar/vector, keyword mixed, mismatched-length validation (test/test_thermo_grid_params.jl)
  • Unit tests for GridParams: keyword auto-Δz, positional explicit Δz, constructor consistency
  • All existing integration tests updated and passing (Pkg.test() — 189 tests, 0 failures)
  • Migration guide added to CHANGELOG.md

🤖 Generated with Claude Code

MasanoriKanamaru and others added 11 commits June 29, 2026 15:50
- Add `GridParams` struct for numerical grid settings (z_max, Δz, n_depth),
  extracted from the old monolithic `ThermoParams`
- Redesign `ThermoParams` to hold only material properties; rename
  `thermal_conductivity` → `conductivity`; remove grid fields
- Add scalar outer constructor `ThermoParams(k, ρ, Cₚ, R_vis, R_ir, ε)`
  that creates length-1 vectors for uniform surfaces
- `SingleAsteroidThermoPhysicalProblem` now takes `(shape, thermo_params,
  grid_params)` and expands length-1 ThermoParams vectors to n_face at
  construction time via `_expand_thermo_params`, eliminating the `resize!`
  mutation in `broadcast_thermo_params!`
- Remove `broadcast_thermo_params!` from `tpm_state.jl`
- Add `_to_pair` helper; binary convenience constructor now accepts
  `ThermoParams`/Tuple and `GridParams`/Tuple for per-body or shared params
- Update `*EulerCache` / `CrankNicolsonCache` constructors to accept
  `GridParams` instead of `AbstractThermoParams`
- Update `_build_single_state` to access `problem.grid_params`

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add box-style section separators for single/binary problem sections
- Add `Union{ThermoParams, Tuple}` and `Union{GridParams, Tuple}` type
  annotations to the binary convenience constructor to restore type
  safety lost when `_to_pair` helper was introduced

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace `thermo_params.thermal_conductivity` with `thermo_params.conductivity`
  in heat_conduction.jl and tpm_solution.jl
- Replace `thermo_params.Δz` with `grid_params.Δz` in heat_conduction.jl
  and tpm_solution.jl
- Replace `thermo_params.n_depth` with `grid_params.n_depth` in tpm_solution.jl

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GridParams is unrelated to thermophysical material properties, so it
is moved from thermo_params.jl to its own file for clarity.
Also adds a note in the docstring about planned variable-spacing support.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Delegates to existing positional constructors, so both scalar Float64
and Vector{Float64} inputs work without additional dispatch logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rams.jl

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ar/vector args

Replace the scalar-only outer constructor with a single generalized constructor
that accepts Union{Float64, Vector{Float64}} per field. Scalar arguments are
automatically broadcast (fill) to match the length of any vector arguments,
so users no longer need to call fill manually for partially non-uniform surfaces.
Vector length consistency is validated at construction time, so _expand_thermo_params
only needs to check a single field when validating against n_face.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add GridParams(; z_max, n_depth) keyword constructor that auto-computes
Δz = z_max / (n_depth - 1), preventing inconsistency between z_max/n_depth
and Δz. Reorder fields to (z_max, n_depth, Δz) so primary parameters come
first and the derived Δz is last. Update tpm_problem.jl docstring example
to reflect the new field order.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add test/test_thermo_grid_params.jl covering:
- ThermoParams: scalar, keyword, vector, mixed scalar/vector, keyword mixed,
  and validation (mismatched vector lengths)
- GridParams: keyword auto-Δz, positional explicit Δz, consistency between
  both constructors

Register the new file in runtests.jl.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Update all test files to use the new separated ThermoParams and GridParams API:
- Replace positional 9-arg ThermoParams with keyword constructor
- Construct GridParams(; z_max, n_depth) separately and pass as third arg
  to SingleAsteroidThermoPhysicalProblem
- Remove manual Δz = z_max / (n_depth - 1) computations (now auto-computed)
- Remove fill() calls in non-uniform test (scalars are now auto-broadcast)
- Update field accesses: thermal_conductivity → conductivity,
  thermo_params.n_depth/Δz → grid_params.n_depth/Δz

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Document the ThermoParams/GridParams separation introduced in this release:
- Breaking changes: removed grid fields from ThermoParams, renamed
  thermal_conductivity → conductivity, updated problem constructor signatures,
  removed broadcast_thermo_params!
- Added: GridParams type with keyword constructor, ThermoParams keyword
  constructor, mixed scalar/vector ThermoParams support
- Migration guide with before/after code examples for all affected APIs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MasanoriKanamaru MasanoriKanamaru changed the title feat: separate ThermoParams/GridParams for v0.3.0 feat: separate ThermoParams/GridParams for v0.3.0 Jul 1, 2026
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.75%. Comparing base (b599cc1) to head (ddc9258).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #218      +/-   ##
==========================================
+ Coverage   96.59%   96.75%   +0.16%     
==========================================
  Files          14       15       +1     
  Lines         704      709       +5     
==========================================
+ Hits          680      686       +6     
+ Misses         24       23       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

MasanoriKanamaru and others added 3 commits July 1, 2026 10:44
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add test asserting ArgumentError when ThermoParams vector length is neither
1 nor n_face, covering the missing codecov line in tpm_problem.jl.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MasanoriKanamaru MasanoriKanamaru merged commit 422a55a into main Jul 1, 2026
12 checks passed
@MasanoriKanamaru MasanoriKanamaru deleted the feat/thermo-grid-params branch July 1, 2026 03:42
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