Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyser/Generator: support systems of non-linear algebraic equations #942

Merged
merged 161 commits into from
May 23, 2023

Conversation

agarny
Copy link
Contributor

@agarny agarny commented Jul 20, 2021

Fixes #882.

@agarny agarny marked this pull request as draft August 16, 2021 22:07
@agarny agarny changed the title Analyser/Generator: support models with algebraic equations with one unknown that require root finding Analyser/Generator: support pure algebraic models Dec 4, 2022
@agarny agarny changed the title Analyser/Generator: support pure algebraic models Analyser/Generator: support systems of non-linear algebraic equations Dec 5, 2022
Reworked our test for an algebraic equation with one non-isolated unknown.
@agarny agarny force-pushed the issue882 branch 2 times, most recently from ecb1985 to feb6e2a Compare December 8, 2022 05:51
hsorby
hsorby previously approved these changes May 15, 2023
@agarny agarny requested a review from nickerso May 15, 2023 00:28
src/generatorprofile.cpp Outdated Show resolved Hide resolved
@agarny agarny force-pushed the issue882 branch 6 times, most recently from 585c446 to 36a7c05 Compare May 17, 2023 11:36
… system.

Such variables are the only unknown variable in an equation, but they are not on their own on either the LHS or RHS of that equation, hence we solve them using an NLA system. This means that we need to provide an initial guess and we can safely use zero since that NLA system has only one solution.
@agarny agarny force-pushed the issue882 branch 2 times, most recently from 79d585a to 3f5928a Compare May 18, 2023 03:07
Now, rates are also computed using an NLA equation.
In the end, there is nothing preventing us from doing that since we already do it for variables, e.g., x = y+z with x and y known and z the unknown variable for which we use an initial guess of zero.
Copy link
Contributor

@hsorby hsorby left a comment

Choose a reason for hiding this comment

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

In the void initialiseVariables(double *states, double *rates, double *variables); function is the rates argument ever used without the external variable argument?

@agarny
Copy link
Contributor Author

agarny commented May 23, 2023

In the void initialiseVariables(double *states, double *rates, double *variables); function is the rates argument ever used without the external variable argument?

It actually has nothing to do with external variables. The reason it was introduced is that rates[x] may now be computed using an NLA equation, in which case we need to have an initial guess for rates[x] and this is done through initialiseVariables().

@hsorby
Copy link
Contributor

hsorby commented May 23, 2023

In the void initialiseVariables(double *states, double *rates, double *variables); function is the rates argument ever used without the external variable argument?

It actually has nothing to do with external variables. The reason it was introduced is that rates[x] may now be computed using an NLA equation, in which case we need to have an initial guess for rates[x] and this is done through initialiseVariables().

Do we have a test showing this, I couldn't see a test generating a rates argument in the initialiseVariables() without also using the externalVariable argument.

@agarny
Copy link
Contributor Author

agarny commented May 23, 2023

In the void initialiseVariables(double *states, double *rates, double *variables); function is the rates argument ever used without the external variable argument?

It actually has nothing to do with external variables. The reason it was introduced is that rates[x] may now be computed using an NLA equation, in which case we need to have an initial guess for rates[x] and this is done through initialiseVariables().

Do we have a test showing this, I couldn't see a test generating a rates argument in the initialiseVariables() without also using the externalVariable argument.

Yes:

void initialiseVariables(double *states, double *rates, double *variables)
{
variables[0] = 0.0;
variables[1] = 0.0;
variables[2] = 0.0;
variables[3] = 0.0;
variables[4] = 1.0;
variables[5] = 0.0;
variables[6] = 0.0;
variables[7] = 0.3;
variables[8] = 0.0;
variables[9] = 120.0;
variables[10] = 0.0;
variables[11] = 0.0;
variables[12] = 0.0;
variables[13] = 0.0;
variables[14] = 0.0;
variables[15] = 36.0;
variables[16] = 0.0;
variables[17] = 0.0;
states[0] = 0.0;
states[1] = 0.6;
states[2] = 0.05;
states[3] = 0.325;
rates[0] = 0.0;
rates[1] = 0.0;
rates[2] = 0.0;
rates[3] = 0.0;
}
.

@agarny agarny merged commit 44ab099 into cellml:main May 23, 2023
@agarny agarny deleted the issue882 branch May 23, 2023 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Analyser/Generator: support systems of non-linear algebraic equations
3 participants