Skip to content

Include functionality for rearranging algebraic loops to turn certain DAEs into ODEs#1400

Open
agarny wants to merge 143 commits into
cellml:mainfrom
agarny:issue1050
Open

Include functionality for rearranging algebraic loops to turn certain DAEs into ODEs#1400
agarny wants to merge 143 commits into
cellml:mainfrom
agarny:issue1050

Conversation

@agarny
Copy link
Copy Markdown
Contributor

@agarny agarny commented May 25, 2026

Fixes #1050.

RLee64 and others added 30 commits December 12, 2025 13:26
Also changed the name of astMap to variableMap to better reflect what it's actually mapping to
Substituted with std::pair<bool, SymEngine::RCP<const SymEngine::Basic>> use instead
Mostly GPT generated test cases
Test case has been superseded by the newly added test suite to more robustly test for equation rearrangement
Previous system assumed that symengine expressions contained only 0-2 children, but in reality it could be any whole number. This adjusts the existing conversion logic to account for this.
Made it so that we also now consider mathml unary +/- operators
Can now handle unary plus, minus, unary minus, and CN types from AST (which means code now passes Analyser.rearrangeAdditiveEquations)
Had an error at equation 4

Also added brackets to equation comments to make things more clear
Now passes Analyser.rearrangeMultiplicativeEquations
Now covers a greater variety of cases
Symengine is not capable of rearranging trig functions into inverse trig functions (e.g. tan(x) = y cannot become x = atan(y))
Now has better Eq 1 test case and more consistent variable naming
Now supports
- Decimal point values (i.e. doubles)
- Constants (E, pi, and inf)
We need to ensure that there can only be one real solution for each
Some specific things had to be added to handle this
- CN representing integers must be appropriately converted since symengine requires exponentials to be whole numbers
- We need to filter out real from non-real solutions since we assume users will want to ignore the complex domain in most cases
Now assumes left child will always be the non-null component
RLee64 and others added 13 commits January 30, 2026 16:51
SymEngine doesn't simplify anything past an equality
Test cases out of sync with simplification commit
Avoid matching external variable to an equation since it's possible it's meant to be undefined for the equation.

Also initialise external variables at the end if still unknown
Removed unused code, introduced proper comment formatting, used/removed const, auto, and & where appropriate.
Removed unused code, introduced proper comment formatting, used/removed const, auto, and & where appropriate. Also fixed minor issues where relevant.
Only support the three most recent versions of macOS, not to mention that we want to be able to use `std::format()` which is only available on macOS 13 and later.
Copilot AI review requested due to automatic review settings May 25, 2026 00:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@agarny agarny changed the title Include functionality for rearranging algebraic loops to turn certain DAE's into ODE's Include functionality for rearranging algebraic loops to turn certain DAEs into ODEs May 25, 2026
agarny added 9 commits May 25, 2026 13:34
This has indeed been done "properly" in PR cellml#1390.
They were making the code a bit faster but more difficult to maintain.
…txt`.

The idea is for the library type to be determined by CMake to allow building `test_utils` as static or shared, depending on the project's configuration.
They were making the code a bit faster but more difficult to maintain.
…txt`.

The idea is for the library type to be determined by CMake to allow building `test_utils` as static or shared, depending on the project's configuration.
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.

Include functionality for rearranging algebraic loops to turn certain DAEs into ODEs

3 participants