Generated Code
The following is c_ida code generated by the CellML API from this CellML file. (Back to language selection)
The raw code is available.
/*
There are a total of 4 entries in the algebraic variable array.
There are a total of 4 entries in each of the rate and state variable arrays.
There are a total of 3 entries in the constant variable array.
*/
/*
* VOI is t in component main (second).
* STATES[0] is q_C in component main (coulomb).
* ALGEBRAIC[3] is v_C in component main (C_per_s).
* ALGEBRAIC[0] is v_R in component main (C_per_s).
* STATES[1] is v_L in component main (C_per_s).
* STATES[2] is a_L in component main (C_per_s2).
* ALGEBRAIC[1] is u_C in component main (J_per_C).
* ALGEBRAIC[2] is u_R in component main (J_per_C).
* STATES[3] is u_L in component main (J_per_C).
* CONSTANTS[0] is C in component main (C2_per_J).
* CONSTANTS[1] is R in component main (Js_per_C2).
* CONSTANTS[2] is L in component main (Js2_per_C2).
* RATES[0] is d/dt q_C in component main (coulomb).
* RATES[1] is d/dt v_L in component main (C_per_s).
* There are a total of 0 condition variables.
*/
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 1;
STATES[1] = 0;
CONSTANTS[0] = 20;
CONSTANTS[1] = 2;
CONSTANTS[2] = 10;
STATES[2] = 0.1001;
STATES[3] = 0.1001;
RATES[0] = 0.1001;
RATES[1] = 0.1001;
}
void
computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
resid[0] = RATES[0] - ALGEBRAIC[3];
resid[1] = RATES[1] - STATES[2];
resid[2] = ALGEBRAIC[1] - ALGEBRAIC[2]+STATES[3];
resid[3] = STATES[3] - STATES[2]*CONSTANTS[2];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[1] = STATES[0]/CONSTANTS[0];
ALGEBRAIC[0] = STATES[1];
ALGEBRAIC[2] = ALGEBRAIC[0]*CONSTANTS[1];
ALGEBRAIC[3] = - ALGEBRAIC[0];
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
SI[1] = 1.0;
SI[2] = 0.0;
SI[3] = 0.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
}
