Generated Code
The following is c code generated by the CellML API from this CellML file. (Back to language selection)
The raw code is available.
/* There are a total of 9 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 13 entries in the constant variable array. */ /* * VOI is t in component main (second). * STATES[0] is omega in component main (per_s). * CONSTANTS[0] is omega_ref in component main (per_s). * ALGEBRAIC[0] is logOmega in component main (dimensionless). * CONSTANTS[1] is E_1 in component main (J_per_C2). * CONSTANTS[2] is E_2 in component main (J_per_m2). * CONSTANTS[3] is R_1 in component main (Js_per_C2). * CONSTANTS[4] is R_2 in component main (Js_per_m2). * CONSTANTS[5] is L_1 in component main (Js2_per_C2). * CONSTANTS[6] is L_2 in component main (Js2_per_m2). * CONSTANTS[7] is Bl in component main (Js_per_C_m). * ALGEBRAIC[1] is x_1 in component main (J_per_m2). * ALGEBRAIC[2] is x_2 in component main (J2_per_m4). * CONSTANTS[10] is omega_3 in component main (per_s). * CONSTANTS[11] is logOmega_3 in component main (dimensionless). * ALGEBRAIC[3] is G_real in component main (Js_per_C2). * ALGEBRAIC[4] is G_imag in component main (Js_per_C2). * ALGEBRAIC[5] is amplitude in component main (Js_per_C2). * CONSTANTS[8] is amplitude_ref in component main (Js_per_C2). * ALGEBRAIC[6] is phase in component main (dimensionless). * CONSTANTS[9] is phase_ref in component main (dimensionless). * ALGEBRAIC[7] is phase_degrees in component main (dimensionless). * ALGEBRAIC[8] is logAmplitude in component main (dimensionless). * RATES[0] is d/dt omega in component main (per_s). */ void initConsts(double* CONSTANTS, double* RATES, double *STATES) { STATES[0] = 0.1; CONSTANTS[0] = 1; CONSTANTS[1] = 0; CONSTANTS[2] = 2000; CONSTANTS[3] = 3.5; CONSTANTS[4] = 0.4; CONSTANTS[5] = 0.15; CONSTANTS[6] = 0.018; CONSTANTS[7] = 10; CONSTANTS[8] = 1; CONSTANTS[9] = 1; CONSTANTS[10] = pow((CONSTANTS[2]/CONSTANTS[6]), 1.0 / 2); CONSTANTS[12] = 1.00000; CONSTANTS[11] = arbitrary_log(CONSTANTS[10]/CONSTANTS[0], 10); } void computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { RATES[0] = CONSTANTS[12]; } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = arbitrary_log(STATES[0]/CONSTANTS[0], 10); ALGEBRAIC[1] = CONSTANTS[2] - pow(STATES[0], 2.00000)*CONSTANTS[6]; ALGEBRAIC[2] = pow(ALGEBRAIC[1], 2.00000)+pow( STATES[0]*CONSTANTS[4], 2.00000); ALGEBRAIC[3] = CONSTANTS[3]+( CONSTANTS[4]*pow( STATES[0]*CONSTANTS[7], 2.00000))/ALGEBRAIC[2]; ALGEBRAIC[4] = STATES[0]*(CONSTANTS[5]+( pow(CONSTANTS[7], 2.00000)*ALGEBRAIC[1])/ALGEBRAIC[2]); ALGEBRAIC[5] = pow((pow(ALGEBRAIC[3], 2.00000)+pow(ALGEBRAIC[4], 2.00000)), 1.0 / 2); ALGEBRAIC[6] = atan(ALGEBRAIC[4]/ALGEBRAIC[3]); ALGEBRAIC[7] = ( ALGEBRAIC[6]*180.000)/ 3.14159265358979; ALGEBRAIC[8] = arbitrary_log(ALGEBRAIC[5]/CONSTANTS[8], 10); }