#include <NhsSystemWithImplicitSolver.hpp>
Public Member Functions | |
NhsSystemWithImplicitSolver () | |
void | SetActiveTensionInitialGuess (double activeTensionInitialGuess) |
void | SolveDoNotUpdate (double startTime, double endTime, double timestep) |
void | UpdateStateVariables () |
void | UseImplicitExplicitSolveForZ (bool useImplicitExplicitSolveForZ=true) |
double | GetActiveTensionAtNextTime () |
Private Member Functions | |
void | ImplicitSolveForActiveTension () |
double | CalcActiveTensionResidual (double activeTensionGuess) |
double | ImplicitSolveForCaTrop (double newActiveTension) |
double | ImplicitSolveForZ (double newCaTrop) |
double | CalcZResidual (double z, double newCaTrop) |
double | ImplicitExplicitSolveForZ (double newCaTrop) |
double | ImplicitSolveForQ () |
Private Attributes | |
double | mDt |
bool | mUseImplicitExplicitSolveForZ |
std::vector< double > | mTempStoredStateVariables |
std::vector< double > | mCurrentStateVars |
double | mActiveTensionInitialGuess |
double | mActiveTensionSolution |
Static Private Attributes | |
static const double | mTolerance = 1e-10 |
The idea is to solve a 1d nonlinear problem for the active tension, where the problem f(T_a)=T_a, where T_a is the current active tension, and f(T_a) is the active tension obtained by assuming this active tension and solving the ODEs as follows:
Given T_a, so compute solution for Ca_trop using backward euler (1d linear problem) Using this Ca_trop, compute solution for z using backward euler (1d nonlinear problem) Solve for Qi implicitly using backward euler (three 1d linear problems) Compute T0, Q and then T_a
Reference: J.P. Whiteley, M.J. Bishop, D.J. Gavaghan "Soft Tissue Modelling of Cardiac Fibres for Use in Coupled Mechano-Electric Simulations"
Definition at line 50 of file NhsSystemWithImplicitSolver.hpp.
NhsSystemWithImplicitSolver::NhsSystemWithImplicitSolver | ( | ) |
Instead of solving an ODE for Qi, assume that the Qi equations reach a static solution on a timescale much smaller than thatt of the deformation, and therefore solve the algebraic equation 0 = A_i lambda_dot - alpha_i Q_i to Q_i(t).
This method returns Q = Q1+Q2+Q3 Constructor
Definition at line 245 of file NhsSystemWithImplicitSolver.cpp.
References NhsCellularMechanicsOdeSystem::GetActiveTension(), AbstractOdeSystem::GetNumberOfStateVariables(), mActiveTensionInitialGuess, mActiveTensionSolution, mTempStoredStateVariables, and mUseImplicitExplicitSolveForZ.
void NhsSystemWithImplicitSolver::ImplicitSolveForActiveTension | ( | ) | [private] |
The main Newton solve
Solve a 1d nonlinear system, f(T_a)=T_a, where T_a is the current active tension and f(T_a) is the active tension obtained by assuming this active tension and solving the ODEs as follows
Given T_a, so compute solution for Ca_trop using backward euler (1d linear problem) Using this Ca_trop, compute solution for z using backward euler (1d nonlinear problem) Solve for Qi implicitly using backward euler (three 1d linear problems) Compute T0, Q and then T_a
Definition at line 37 of file NhsSystemWithImplicitSolver.cpp.
References CalcActiveTensionResidual(), mActiveTensionInitialGuess, mActiveTensionSolution, and mTolerance.
Referenced by SolveDoNotUpdate().
double NhsSystemWithImplicitSolver::CalcActiveTensionResidual | ( | double | activeTensionGuess | ) | [private] |
The residual function for the main Newton solve. See ImplicitSolveForActiveTension()
activeTensionGuess |
Definition at line 90 of file NhsSystemWithImplicitSolver.cpp.
References NhsCellularMechanicsOdeSystem::CalculateT0(), ImplicitExplicitSolveForZ(), ImplicitSolveForCaTrop(), ImplicitSolveForQ(), ImplicitSolveForZ(), NhsCellularMechanicsOdeSystem::mA, mTempStoredStateVariables, and mUseImplicitExplicitSolveForZ.
Referenced by ImplicitSolveForActiveTension().
double NhsSystemWithImplicitSolver::ImplicitSolveForCaTrop | ( | double | newActiveTension | ) | [private] |
Assume the active tension is known and solve for the Ca_trop at the next time implicitly using backward euler. This can be done directly as the rhs is linear in Ca_trop
newActiveTension |
Definition at line 145 of file NhsSystemWithImplicitSolver.cpp.
References NhsCellularMechanicsOdeSystem::mCalciumI, NhsCellularMechanicsOdeSystem::mCalciumTroponinMax, mCurrentStateVars, mDt, NhsCellularMechanicsOdeSystem::mGamma, NhsCellularMechanicsOdeSystem::mKon, NhsCellularMechanicsOdeSystem::mKrefoff, and NhsCellularMechanicsOdeSystem::mTref.
Referenced by CalcActiveTensionResidual().
double NhsSystemWithImplicitSolver::ImplicitSolveForZ | ( | double | newCaTrop | ) | [private] |
Assume the Ca_trop is known and solve for the z at the next time implicitly using backward euler. Uses Newton's method.
newCaTrop |
Definition at line 157 of file NhsSystemWithImplicitSolver.cpp.
References CalcZResidual(), mCurrentStateVars, and mTolerance.
Referenced by CalcActiveTensionResidual().
double NhsSystemWithImplicitSolver::CalcZResidual | ( | double | z, | |
double | newCaTrop | |||
) | [private] |
Residual for solving z implicitly. See ImplicitSolveForZ().
z | ||
newCaTrop |
Definition at line 178 of file NhsSystemWithImplicitSolver.cpp.
References NhsCellularMechanicsOdeSystem::mAlpha0, NhsCellularMechanicsOdeSystem::mAlphaR1, NhsCellularMechanicsOdeSystem::mAlphaR2, NhsCellularMechanicsOdeSystem::mCalciumTrop50, mCurrentStateVars, mDt, NhsCellularMechanicsOdeSystem::mKZ, NhsCellularMechanicsOdeSystem::mN, and NhsCellularMechanicsOdeSystem::mNr.
Referenced by ImplicitSolveForZ().
double NhsSystemWithImplicitSolver::ImplicitExplicitSolveForZ | ( | double | newCaTrop | ) | [private] |
Solve for z semi implicitly. See UseImplicitExplicitSolveForZ().
newCaTrop |
Definition at line 194 of file NhsSystemWithImplicitSolver.cpp.
References NhsCellularMechanicsOdeSystem::mAlpha0, NhsCellularMechanicsOdeSystem::mAlphaR1, NhsCellularMechanicsOdeSystem::mAlphaR2, NhsCellularMechanicsOdeSystem::mCalciumTrop50, mCurrentStateVars, mDt, NhsCellularMechanicsOdeSystem::mKZ, NhsCellularMechanicsOdeSystem::mN, and NhsCellularMechanicsOdeSystem::mNr.
Referenced by CalcActiveTensionResidual().
double NhsSystemWithImplicitSolver::ImplicitSolveForQ | ( | ) | [private] |
Solve for Q1,Q2,Q3 (and therefore Q) implicitly using backward euler. These can be done directly as the rhs is linear in Qi
Definition at line 208 of file NhsSystemWithImplicitSolver.cpp.
References NhsCellularMechanicsOdeSystem::mA1, NhsCellularMechanicsOdeSystem::mA2, NhsCellularMechanicsOdeSystem::mA3, NhsCellularMechanicsOdeSystem::mAlpha1, NhsCellularMechanicsOdeSystem::mAlpha2, NhsCellularMechanicsOdeSystem::mAlpha3, mCurrentStateVars, NhsCellularMechanicsOdeSystem::mDLambdaDt, mDt, and mTempStoredStateVariables.
Referenced by CalcActiveTensionResidual().
void NhsSystemWithImplicitSolver::SetActiveTensionInitialGuess | ( | double | activeTensionInitialGuess | ) |
Set a current active tension guess. Generally not needed as the current active tension is used if this isn't called.
activeTensionInitialGuess |
Definition at line 255 of file NhsSystemWithImplicitSolver.cpp.
References mActiveTensionInitialGuess.
Referenced by ImplicitCardiacMechanicsAssembler< DIM >::AssembleOnElement().
void NhsSystemWithImplicitSolver::SolveDoNotUpdate | ( | double | startTime, | |
double | endTime, | |||
double | timestep | |||
) |
Solves for the new state variables at the given end time using the implicit method. Note that the internal state variables are not altered, the solution is saved instead. Call UpdateStateVariables() to update, and GetActiveTensionAtNextTime() to get the solved active tension
The state variables are not updated because this solve will be called as part of the newton iteration (ie guess stretch, see what the new active tension is) in a fully implicit method
startTime | ||
endTime | ||
timestep |
Definition at line 261 of file NhsSystemWithImplicitSolver.cpp.
References TimeStepper::AdvanceOneTimeStep(), ImplicitSolveForActiveTension(), TimeStepper::IsTimeAtEnd(), mCurrentStateVars, mDt, AbstractOdeSystem::mStateVariables, and mTempStoredStateVariables.
Referenced by ImplicitCardiacMechanicsAssembler< DIM >::AssembleOnElement().
void NhsSystemWithImplicitSolver::UpdateStateVariables | ( | ) |
Update the state variables using the stored solution. Call after SolveDoNotUpdate() if the solution is to be accepted
Definition at line 285 of file NhsSystemWithImplicitSolver.cpp.
References mCurrentStateVars, and AbstractOdeSystem::mStateVariables.
void NhsSystemWithImplicitSolver::UseImplicitExplicitSolveForZ | ( | bool | useImplicitExplicitSolveForZ = true |
) |
Solve for z semi-implicitly instead of fully implicitly. If we assume we know Ca_trop solving for z is a 1d nonlinear problem. Call this to treat the problem implicitly in the linear terms on the rhs of dzdt (the (1-z) and (z) terms), and explicitly in the nonlinear term (the z^nr/(z^nr + K^nr) term. This means the problem can be solved directly and no Newton iterations are needed.
useImplicitExplicitSolveForZ |
Definition at line 293 of file NhsSystemWithImplicitSolver.cpp.
References mUseImplicitExplicitSolveForZ.
double NhsSystemWithImplicitSolver::GetActiveTensionAtNextTime | ( | ) |
Get the active tension corresponding to the stored state variables computed from the last SolveDoNoUpdate(), ie the active tension at the next time. Note that calling GetActiveTension() on the base class will use the internal state variables and return the active tension at the last time, if SolveDoNoUpdate() has been called but UpdateStateVariables() has not
Definition at line 298 of file NhsSystemWithImplicitSolver.cpp.
References mActiveTensionSolution.
Referenced by ImplicitCardiacMechanicsAssembler< DIM >::AssembleOnElement().
const double NhsSystemWithImplicitSolver::mTolerance = 1e-10 [static, private] |
Tolerance for solving nonlinear system which require newton's method NOTE: 1e-6 doesn't give graphically close results when solving a full problem and comparing implicit with explicit
Definition at line 58 of file NhsSystemWithImplicitSolver.hpp.
Referenced by ImplicitSolveForActiveTension(), and ImplicitSolveForZ().
double NhsSystemWithImplicitSolver::mDt [private] |
Timestep for the ODEs solving
Definition at line 61 of file NhsSystemWithImplicitSolver.hpp.
Referenced by CalcZResidual(), ImplicitExplicitSolveForZ(), ImplicitSolveForCaTrop(), ImplicitSolveForQ(), and SolveDoNotUpdate().
bool NhsSystemWithImplicitSolver::mUseImplicitExplicitSolveForZ [private] |
See SetUseImplicitExplicitSolveForZ()
Definition at line 64 of file NhsSystemWithImplicitSolver.hpp.
Referenced by CalcActiveTensionResidual(), NhsSystemWithImplicitSolver(), and UseImplicitExplicitSolveForZ().
std::vector<double> NhsSystemWithImplicitSolver::mTempStoredStateVariables [private] |
Temporary stored state variables - current guesses to the current solution
Definition at line 67 of file NhsSystemWithImplicitSolver.hpp.
Referenced by CalcActiveTensionResidual(), ImplicitSolveForQ(), NhsSystemWithImplicitSolver(), and SolveDoNotUpdate().
std::vector<double> NhsSystemWithImplicitSolver::mCurrentStateVars [private] |
Current state variables to be used in the next timestep
Definition at line 69 of file NhsSystemWithImplicitSolver.hpp.
Referenced by CalcZResidual(), ImplicitExplicitSolveForZ(), ImplicitSolveForCaTrop(), ImplicitSolveForQ(), ImplicitSolveForZ(), SolveDoNotUpdate(), and UpdateStateVariables().
double NhsSystemWithImplicitSolver::mActiveTensionInitialGuess [private] |
Initial guess for the active tension
Definition at line 72 of file NhsSystemWithImplicitSolver.hpp.
Referenced by ImplicitSolveForActiveTension(), NhsSystemWithImplicitSolver(), and SetActiveTensionInitialGuess().
double NhsSystemWithImplicitSolver::mActiveTensionSolution [private] |
The solution for the active tension after a SolveDoNotUpdate() has been called
Definition at line 74 of file NhsSystemWithImplicitSolver.hpp.
Referenced by GetActiveTensionAtNextTime(), ImplicitSolveForActiveTension(), and NhsSystemWithImplicitSolver().