Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
aff7fe8
Add constraint base classes for DAE support
dwfncar Jan 18, 2026
4654f26
Add state and builder infrastructure for DAE constraints
dwfncar Jan 18, 2026
3988f54
Integrate DAE constraints into Rosenbrock solver
dwfncar Jan 18, 2026
cf4dca0
Add documentation for constraint classes and fix param comments
dwfncar Jan 19, 2026
02e8d62
Standardize mathematical notation in docs and comments
dwfncar Jan 20, 2026
8870586
Rename and expand indexing patterns documentation
dwfncar Jan 20, 2026
6b9f658
Add architecture overview and test coverage to walkthrough
dwfncar Jan 20, 2026
11e2ed3
Add flat array memory layout documentation to walkthrough
dwfncar Jan 20, 2026
7f532f1
Rename forcing_jacobian_parallel.md for clarity
dwfncar Jan 20, 2026
aa71b5d
Address PR review feedback: move docs and use Yield type
dwfncar Jan 23, 2026
89cffe3
Use micm-specific error types for constraint validation
dwfncar Jan 23, 2026
2079709
Optimize Constraint interface to avoid per-cell allocations
dwfncar Jan 23, 2026
070a19d
Add constructor validation for EquilibriumConstraint
dwfncar Jan 23, 2026
1f7ba7d
Cleanup.
dwfncar Jan 29, 2026
6a0ae29
Added detailed Codex reviews and recommendations in TODO.
dwfncar Jan 29, 2026
0bb0a29
Added Codex 5.2 at Extra High reasoning depth review pass.
dwfncar Jan 29, 2026
62c6af5
Merge branch 'main' into dae-1-constraint-classes
boulderdaze Jan 30, 2026
3623120
merge main
boulderdaze Jan 30, 2026
351cd5f
Merge branch 'dae-1-constraint-classes' into dae-3-rosenbrock-integra…
boulderdaze Feb 2, 2026
7798bab
fix the tests
boulderdaze Feb 3, 2026
7c84ff8
constraint check is done out of loop
boulderdaze Feb 3, 2026
2a127af
remove unused function
boulderdaze Feb 3, 2026
59577b7
Review dae 1 constraint classes (#914)
boulderdaze Feb 3, 2026
0189d1c
fix the typo
boulderdaze Feb 4, 2026
f0c5b7f
add a missing header
boulderdaze Feb 4, 2026
7714eda
Merge branch 'dae-1-constraint-classes' into dae-3-rosenbrock-integra…
boulderdaze Feb 5, 2026
e68744b
Merge branch 'dae-3-rosenbrock-integration' into v2-review-dae-3-rose…
boulderdaze Feb 5, 2026
c0d8d56
remove unnecessary setter for constraints
boulderdaze Feb 5, 2026
b8cc902
change the type of unique ptr to vector
boulderdaze Feb 5, 2026
77ba699
remove unncessary docs
boulderdaze Feb 5, 2026
71bb326
add deep copy for constraint
boulderdaze Feb 6, 2026
5f4656c
temp
boulderdaze Feb 10, 2026
011c0f3
merge main
boulderdaze Feb 10, 2026
d83270b
Merge branch 'dae-3-rosenbrock-integration' into v2-review-dae-3-rose…
boulderdaze Feb 10, 2026
46a75a8
replace unique ptr to variant
boulderdaze Feb 10, 2026
14a6cde
fix the error
boulderdaze Feb 10, 2026
5d98cfa
fix test
boulderdaze Feb 10, 2026
e229bf9
code clean up
boulderdaze Feb 10, 2026
b66fca0
revert the previous change for get solver
boulderdaze Feb 10, 2026
b3cca64
make builder copyable
boulderdaze Feb 10, 2026
119d567
fix test
boulderdaze Feb 10, 2026
eda8cb0
add comments on test
boulderdaze Feb 10, 2026
dd83fdd
revert back
boulderdaze Feb 11, 2026
3533f31
state size
boulderdaze Feb 11, 2026
e8c2668
code cleanup
boulderdaze Feb 11, 2026
9335b46
address copilot review
boulderdaze Feb 11, 2026
b92f583
Fix missing constraint Jacobian terms on Rosenbrock rejected-step pat…
Copilot Feb 11, 2026
46d09f9
address copilot review
boulderdaze Feb 11, 2026
d6c83a7
nvhpc error
boulderdaze Feb 11, 2026
21a9315
Merge branch 'v2-review-dae-3-rosenbrock-integration' of github.com:N…
boulderdaze Feb 11, 2026
4a899b3
add params for constructor for cuda
boulderdaze Feb 11, 2026
edef9a8
fix a bug
boulderdaze Feb 11, 2026
419afd3
Implement full mass-matrix DAE row replacement
dwfncar Feb 11, 2026
92c54f5
Update DAE review and move design docs
dwfncar Feb 11, 2026
c3e9b9a
Fix review issues and add DAE integration tests
dwfncar Feb 11, 2026
a4e7a97
Fix State copy slicing, Jacobian duplicate deps, and unused-species c…
dwfncar Feb 11, 2026
6ed3977
Add multi-grid-cell DAE integration test
dwfncar Feb 11, 2026
e50fbb9
Fix Jacobian concentration guards and Solve overload clamping
dwfncar Feb 11, 2026
8cbfaef
Remove design docs from tracking and add to .gitignore
dwfncar Feb 11, 2026
c7217ae
Resolve all LOW review items: return type, dead code, sparsity filter…
dwfncar Feb 11, 2026
7c384cc
Fix DAE algebraic-row Jacobian flat-id pruning regression
dwfncar Feb 11, 2026
b4cd012
Add DAE reorder-state and algebraic-reactant regression tests
dwfncar Feb 11, 2026
1949846
Track architecture doc and untrack internal review notes
dwfncar Feb 11, 2026
5982f6a
Untrack architecture doc from PR scope
dwfncar Feb 11, 2026
08f16d8
Fix the test failure for DAE constraint enforcement PR (#933)
boulderdaze Feb 19, 2026
17553d2
resolve the merge conflicts
boulderdaze Feb 19, 2026
33b9d4d
fixes the syntax error
boulderdaze Feb 19, 2026
0356b54
Review and rework DAE Constraint enforcement PR (#937)
boulderdaze Feb 26, 2026
85cfb14
address the copilot review
boulderdaze Feb 26, 2026
3e7724b
merge main
boulderdaze Mar 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions docs/design/CODEX_TODO.md

This file was deleted.

34 changes: 0 additions & 34 deletions docs/design/FULL_REVIEW.md

This file was deleted.

76 changes: 49 additions & 27 deletions include/micm/constraint/constraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,83 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once

#include <micm/constraint/equilibrium_constraint.hpp>
#include <micm/constraint/linear_constraint.hpp>

#include <cstddef>
#include <string>
#include <utility>
#include <variant>
#include <vector>
#include <concepts>
#include <type_traits>

namespace micm
{

/// @brief Abstract base class for algebraic constraints G(y) = 0
///
/// Constraints define algebraic relations that must be satisfied by the species
/// concentrations. They are used in DAE (Differential-Algebraic Equation) solvers
/// to enforce conditions like chemical equilibrium or mass conservation.
///
/// Each constraint provides:
/// - A residual function G(y) that should equal zero when the constraint is satisfied
/// - Jacobian entries dG/dy for each species the constraint depends on
/// @brief This class uses std::variant to hold different constraint types.
/// Each constraint provides:
/// - A residual function G(y) that should equal zero when the constraint is satisfied
/// - Jacobian entries dG/dy for each species the constraint depends on
class Constraint
{
public:
/// @brief Name of the constraint (for identification)
std::string name_;
using ConstraintVariant = std::variant<EquilibriumConstraint, LinearConstraint>;

/// @brief Names of species this constraint depends on
std::vector<std::string> species_dependencies_;
ConstraintVariant constraint_;

/// @brief Default constructor
Constraint() = default;
template<typename T>
requires std::same_as<std::decay_t<T>, EquilibriumConstraint> ||
std::same_as<std::decay_t<T>, LinearConstraint>
Constraint(T&& constraint)
: constraint_(std::forward<T>(constraint))
{
}

/// @brief Constructor with name
/// @param name Constraint identifier
explicit Constraint(const std::string& name)
: name_(name)
/// @brief Get the constraint name
/// @return Constraint name
std::string GetName() const
{
return std::visit([](const auto& c) { return c.name_; }, constraint_);
}

/// @brief Virtual destructor
virtual ~Constraint() = default;
/// @brief Get species dependencies
/// @return Vector of species names this constraint depends on
const std::vector<std::string>& GetSpeciesDependencies() const
{
return std::visit([](const auto& c) -> const std::vector<std::string>& { return c.species_dependencies_; }, constraint_);
}

/// @brief Get the number of species this constraint depends on
/// @return Number of dependent species
std::size_t NumberOfDependencies() const
{
return std::visit([](const auto& c) { return c.species_dependencies_.size(); }, constraint_);
}

/// @brief Evaluate the constraint residual G(y)
/// @param concentrations Pointer to species concentrations (row of state matrix)
/// @param indices Pointer to indices mapping species_dependencies_ to positions in concentrations
/// @return Residual value (should be 0 when constraint is satisfied)
virtual double Residual(const double* concentrations, const std::size_t* indices) const = 0;
double Residual(const double* concentrations, const std::size_t* indices) const
{
return std::visit([&](const auto& c) { return c.Residual(concentrations, indices); }, constraint_);
}

/// @brief Compute partial derivatives dG/d[species] for each dependent species
/// @param concentrations Pointer to species concentrations (row of state matrix)
/// @param indices Pointer to indices mapping species_dependencies_ to positions in concentrations
/// @param jacobian Output buffer for partial derivatives dG/d[species] (same order as species_dependencies_)
virtual void Jacobian(const double* concentrations, const std::size_t* indices, double* jacobian) const = 0;
void Jacobian(const double* concentrations, const std::size_t* indices, double* jacobian) const
{
std::visit([&](const auto& c) { c.Jacobian(concentrations, indices, jacobian); }, constraint_);
}

/// @brief Get the number of species this constraint depends on
/// @return Number of dependent species
std::size_t NumberOfDependencies() const
/// @brief Returns the species whose state row should be replaced by this algebraic constraint
/// @return Algebraic species name
const std::string& GetAlgebraicSpecies() const
{
return species_dependencies_.size();
return std::visit([](const auto& c) -> const std::string& { return c.AlgebraicSpecies(); }, constraint_);
}
};

Expand Down
Loading
Loading