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 3 entries in the algebraic variable array.
   There are a total of 1 entries in each of the rate and state variable arrays.
   There are a total of 7 entries in the constant variable array.
 */
/*
 * VOI is x in component main (dimensionless).
 * ALGEBRAIC[0] is sin in component sin (dimensionless).
 * STATES[0] is sin in component sin (dimensionless).
 * CONSTANTS[0] is deriv_approx_initial_value in component main (dimensionless).
 * ALGEBRAIC[2] is sin in component sin (dimensionless).
 * CONSTANTS[2] is k2_oPi in component sin (dimensionless).
 * CONSTANTS[3] is k2Pi in component sin (dimensionless).
 * CONSTANTS[4] is kPi_2 in component sin (dimensionless).
 * CONSTANTS[5] is kPi in component sin (dimensionless).
 * CONSTANTS[6] is kPi_32 in component sin (dimensionless).
 * ALGEBRAIC[1] is z in component sin (dimensionless).
 * CONSTANTS[1] is C in component sin (dimensionless).
 * RATES[0] is d/dt sin in component sin (dimensionless).
 * There are a total of 6 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 0;
CONSTANTS[1] = 0.75;
CONSTANTS[2] = 2.00000/ 3.14159265358979;
CONSTANTS[3] =  2.00000* 3.14159265358979;
CONSTANTS[4] =  3.14159265358979/2.00000;
CONSTANTS[5] =  3.14159265358979;
CONSTANTS[6] = ( 3.00000* 3.14159265358979)/2.00000;
STATES[0] = CONSTANTS[0];
RATES[0] = 0.1;
}
void
computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
                 double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
resid[0] = RATES[0] - cos(VOI);
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] =  sin(VOI);
ALGEBRAIC[1] = (CONDVAR[0]<0.00000 ?  VOI*CONSTANTS[2] - 0.500000 : CONDVAR[1]<0.00000 ?  ( 3.14159265358979 - VOI)*CONSTANTS[2] - 0.500000 : CONDVAR[2]<0.00000 ?  (VOI -  3.14159265358979)*CONSTANTS[2] - 0.500000 :  (CONSTANTS[3] - VOI)*CONSTANTS[2] - 0.500000);
ALGEBRAIC[2] = (CONDVAR[3]<0.00000 ? - ( ALGEBRAIC[1]*ALGEBRAIC[1])+CONSTANTS[1]+ALGEBRAIC[1] : CONDVAR[4]<0.00000 ? - ( ALGEBRAIC[1]*ALGEBRAIC[1])+CONSTANTS[1]+ALGEBRAIC[1] : CONDVAR[5]<0.00000 ? ( ALGEBRAIC[1]*ALGEBRAIC[1] - CONSTANTS[1]) - ALGEBRAIC[1] : ( ALGEBRAIC[1]*ALGEBRAIC[1] - CONSTANTS[1]) - ALGEBRAIC[1]);
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = VOI - CONSTANTS[4];
CONDVAR[1] = VOI - CONSTANTS[5];
CONDVAR[2] = VOI - CONSTANTS[6];
CONDVAR[3] = VOI - CONSTANTS[4];
CONDVAR[4] = VOI - CONSTANTS[5];
CONDVAR[5] = VOI - CONSTANTS[6];
}
Source
Derived from workspace Approximating Sine Waves at changeset d80ad0e8c5c5.
This exposure was expired.
Collaboration
To begin collaborating on this work, please use your git client and issue this command:
License
The terms of use/license for this work is unspecified.