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 2 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_1 in component main (metre).
 * STATES[1] is v_1 in component main (m_per_s).
 * STATES[2] is a_1 in component main (m_per_s2).
 * ALGEBRAIC[0] is u_C in component main (J_per_m).
 * ALGEBRAIC[1] is u_R in component main (J_per_m).
 * STATES[3] is u_L in component main (J_per_m).
 * CONSTANTS[0] is C in component main (m2_per_J).
 * CONSTANTS[1] is R in component main (Js_per_m2).
 * CONSTANTS[2] is L in component main (Js2_per_m2).
 * RATES[0] is d/dt q_1 in component main (metre).
 * RATES[1] is d/dt v_1 in component main (m_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] = 0.1;
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] - STATES[1];
resid[1] = RATES[1] - STATES[2];
resid[2] = ALGEBRAIC[0] - - ALGEBRAIC[1] - 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[0] = STATES[0]/CONSTANTS[0];
ALGEBRAIC[1] =  STATES[1]*CONSTANTS[1];
}
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)
{
}