Skip to content

feat: Problem-Solver API redesign for v0.2.0#201

Merged
MasanoriKanamaru merged 16 commits into
mainfrom
feature/tpm-problem-solver-api
Jun 10, 2026
Merged

feat: Problem-Solver API redesign for v0.2.0#201
MasanoriKanamaru merged 16 commits into
mainfrom
feature/tpm-problem-solver-api

Conversation

@MasanoriKanamaru

@MasanoriKanamaru MasanoriKanamaru commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

This PR implements the Problem-Solver API redesign planned for v0.2.0, separating problem definition from simulation state and introducing a solve interface inspired by DifferentialEquations.jl.

  • Add SingleAsteroidThermoPhysicalProblem and BinaryAsteroidThermoPhysicalProblem problem types that encapsulate shape, thermophysical parameters, boundary conditions, and modeling flags
  • Add solve(problem, algorithm; kwargs...) via CommonSolve.jl, replacing run_TPM!
  • Add algorithm types (ExplicitEuler, ImplicitEuler, CrankNicolson) and boundary condition types (RadiationBoundaryCondition, InsulationBoundaryCondition, IsothermalBoundaryCondition)
  • Add BinaryAsteroidThermoPhysicalProblem(shape, thermo_params; kwargs...) convenience constructor accepting tuples (shape1, shape2) and (thermo_params1, thermo_params2)
  • Add init_temperature!(stpm, T₀::AbstractMatrix) for warm-start from a previous result
  • Add init_temperature!(btpm, T₀_primary, T₀_secondary) for per-body initialization
  • Export ThermoParams and subsolar_temperature; move subsolar_temperature to thermo_params.jl
  • Rename tpm_run.jltpm_init.jl
  • Remove run_TPM!

Migration

# v0.1.x
stpm = SingleAsteroidThermoPhysicalModel(shape, thermo_params; ...)
init_temperature!(stpm, T₀)
result = run_TPM!(stpm, ephem, times_to_save, face_ID)

# v0.2.0
problem = SingleAsteroidThermoPhysicalProblem(shape, thermo_params;
    with_self_shadowing      = true,
    upper_boundary_condition = RadiationBoundaryCondition(),
)
solution = solve(problem, CrankNicolson();
    ephem         = ephem,
    times_to_save = times_to_save,
    face_ID       = face_ID,
    T₀            = 200.0,
)

Test plan

  • All existing tests pass (julia --project test/runtests.jl)
  • Benchmark suite runs without error (julia --project=benchmark benchmark/run_benchmarks.jl)
  • Binary asteroid test (TPM_Didymos) passes with T₀_primary / T₀_secondary kwargs

🤖 Generated with Claude Code

MasanoriKanamaru and others added 11 commits June 9, 2026 12:46
Reflects the addition of CommonSolve.jl as a dependency and
Julia version update from 1.11.6 to 1.12.6.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
v0.2.0 requires AbstractShapeModel (introduced in v0.5.0) for the
new problem types. Support for v0.4.x is dropped as planned.

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

Introduce problem definition types that separate "what to solve" from
"how to solve it", following the DifferentialEquations.jl Problem-Solver
pattern.

SingleAsteroidThermoPhysicalProblem holds:
- shape (AbstractShapeModel), thermo_params
- with_self_shadowing, with_self_heating (modeling flags)
- upper_boundary_condition, lower_boundary_condition

BinaryAsteroidThermoPhysicalProblem composes two single-asteroid
problems and adds with_mutual_shadowing, with_mutual_heating flags.

Both constructors handle automatic BVH / face_visibility_graph
building and call broadcast_thermo_params!.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add src/tpm_solve.jl with solve(::SingleAsteroidThermoPhysicalProblem, ...)
  and solve(::BinaryAsteroidThermoPhysicalProblem, ...) extending CommonSolve.solve
- Add _build_single_tpm and _build_cache internal helpers
- Remove run_TPM! from tpm_run.jl (replaced by solve)
- Reorganize AsteroidThermoPhysicalModels.jl: interleave export with include
  so each file's public API is visible at its definition site

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace SingleAsteroidTPM/BinaryAsteroidTPM construction + init_temperature! + run_TPM!
with SingleAsteroidThermoPhysicalProblem / BinaryAsteroidThermoPhysicalProblem + solve.
Benchmark setup functions now return (problem, ephem); component benchmarks use
_build_single_tpm for direct access to internal model state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The main package now requires AsteroidShapeModels >= 0.5 (AbstractShapeModel),
so update the benchmark environment to match.

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

- Rename tpm_run.jl → tpm_init.jl (file now contains only init_temperature!)
- Move subsolar_temperature to thermo_params.jl where thermal params are defined
- Add init_temperature!(stpm, T₀::AbstractMatrix) for initializing from a previous result
- Add init_temperature!(btpm, T₀_primary, T₀_secondary) for per-body initialization
- Export subsolar_temperature from main module

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

- Remove default value from T₀ in single-asteroid solve (must be explicitly provided)
- Replace T₀ with T₀_primary and T₀_secondary in binary solve (no defaults)
- T₀ accepts Real or AbstractMatrix of size (n_depth, n_face) in both solve methods
- Update test (TPM_Didymos) and benchmark calls accordingly

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

- Add BinaryAsteroidThermoPhysicalProblem(shape, thermo_params; kwargs...) convenience
  constructor accepting tuples (shape1, shape2) and (thermo_params1, thermo_params2);
  single-body kwargs are applied identically to both bodies
- Add ::Bool type annotations to all boolean kwargs in problem constructors
- Add ::SingleAsteroidThermoPhysicalProblem annotations to primary/secondary args

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Consistent with CommonSolve.jl convention and the solve docstrings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.95402% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.00%. Comparing base (4a1a544) to head (99a449d).

Files with missing lines Patch % Lines
src/tpm_problem.jl 71.42% 6 Missing ⚠️
src/tpm_solve.jl 98.07% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #201      +/-   ##
==========================================
- Coverage   92.84%   92.00%   -0.85%     
==========================================
  Files          11       13       +2     
  Lines         559      600      +41     
==========================================
+ Hits          519      552      +33     
- Misses         40       48       +8     

☔ 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 5 commits June 10, 2026 11:20
ThermoParams is a fundamental user-facing type that must be accessible
without module qualification after `using AsteroidThermoPhysicalModels`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers subsolar_temperature, BinaryAsteroidThermoPhysicalProblem
convenience constructor (tuple args, per-body params, shared kwargs),
and init_temperature! with AbstractMatrix and per-body binary overloads.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Now that ThermoParams is exported, the AsteroidThermoPhysicalModels.
prefix is no longer needed in test files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The params overload silently uses the first element of reflectance_vis
and emissivity, which is inconsistent for non-uniform ThermoParams.
Marks the overload for future removal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MasanoriKanamaru MasanoriKanamaru merged commit a23e3a4 into main Jun 10, 2026
10 of 12 checks passed
@MasanoriKanamaru MasanoriKanamaru deleted the feature/tpm-problem-solver-api branch June 10, 2026 03:06
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