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 8 entries in the algebraic variable array. There are a total of 3 entries in each of the rate and state variable arrays. There are a total of 8 entries in the constant variable array. */ /* * VOI is t in component environment (second). * CONSTANTS[0] is R in component environment (J_per_K_per_mol). * CONSTANTS[1] is T in component environment (kelvin). * CONSTANTS[2] is F in component environment (C_per_mol). * CONSTANTS[3] is C_m in component environment (fF). * STATES[0] is q_K_o in component environment (fmol). * STATES[1] is q_K_i in component environment (fmol). * ALGEBRAIC[6] is v_K_ATP in component K_ATP (fmol_per_sec). * STATES[2] is q_mem in component environment (fC). * ALGEBRAIC[7] is I_mem_K_ATP in component K_ATP (fA). * CONSTANTS[4] is kappa_K_ATP in component K_ATP_parameters (fmol_per_sec). * CONSTANTS[5] is K_K_i in component K_ATP_parameters (per_fmol). * CONSTANTS[6] is K_K_o in component K_ATP_parameters (per_fmol). * CONSTANTS[7] is zK in component K_ATP_parameters (dimensionless). * ALGEBRAIC[1] is mu_K_o in component K_ATP (J_per_mol). * ALGEBRAIC[2] is mu_K_i in component K_ATP (J_per_mol). * ALGEBRAIC[4] is Am_K_ATP in component K_ATP (J_per_mol). * ALGEBRAIC[3] is Af_K_ATP in component K_ATP (J_per_mol). * ALGEBRAIC[5] is Ar_K_ATP in component K_ATP (J_per_mol). * ALGEBRAIC[0] is V_mem in component K_ATP (volt). * RATES[0] is d/dt q_K_o in component environment (fmol). * RATES[1] is d/dt q_K_i in component environment (fmol). * RATES[2] is d/dt q_mem in component environment (fC). */ void initConsts(double* CONSTANTS, double* RATES, double *STATES) { CONSTANTS[0] = 8.314; CONSTANTS[1] = 310; CONSTANTS[2] = 96485; CONSTANTS[3] = 153400; STATES[0] = 27.9828; STATES[1] = 5510; STATES[2] = -13039; CONSTANTS[4] = 1.1812e-05; CONSTANTS[5] = 9.99086e-05; CONSTANTS[6] = 0.000663229; CONSTANTS[7] = 1; } void computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = STATES[2]/CONSTANTS[3]; ALGEBRAIC[4] = CONSTANTS[7]*CONSTANTS[2]*ALGEBRAIC[0]; ALGEBRAIC[2] = CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[5]*STATES[1]); ALGEBRAIC[3] = ALGEBRAIC[2]+ CONSTANTS[7]*CONSTANTS[2]*ALGEBRAIC[0]; ALGEBRAIC[1] = CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[6]*STATES[0]); ALGEBRAIC[5] = ALGEBRAIC[1]; ALGEBRAIC[6] = (ALGEBRAIC[4]==0.00000 ? CONSTANTS[4]*(exp(ALGEBRAIC[3]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[5]/( CONSTANTS[0]*CONSTANTS[1]))) : ((( CONSTANTS[4]*ALGEBRAIC[4])/( CONSTANTS[0]*CONSTANTS[1]))/(exp(ALGEBRAIC[4]/( CONSTANTS[0]*CONSTANTS[1])) - 1.00000))*(exp(ALGEBRAIC[3]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[5]/( CONSTANTS[0]*CONSTANTS[1])))); RATES[0] = ALGEBRAIC[6]; RATES[1] = - ALGEBRAIC[6]; ALGEBRAIC[7] = CONSTANTS[2]*- CONSTANTS[7]*ALGEBRAIC[6]; RATES[2] = ALGEBRAIC[7]; } void computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC) { ALGEBRAIC[0] = STATES[2]/CONSTANTS[3]; ALGEBRAIC[4] = CONSTANTS[7]*CONSTANTS[2]*ALGEBRAIC[0]; ALGEBRAIC[2] = CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[5]*STATES[1]); ALGEBRAIC[3] = ALGEBRAIC[2]+ CONSTANTS[7]*CONSTANTS[2]*ALGEBRAIC[0]; ALGEBRAIC[1] = CONSTANTS[0]*CONSTANTS[1]*log( CONSTANTS[6]*STATES[0]); ALGEBRAIC[5] = ALGEBRAIC[1]; ALGEBRAIC[6] = (ALGEBRAIC[4]==0.00000 ? CONSTANTS[4]*(exp(ALGEBRAIC[3]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[5]/( CONSTANTS[0]*CONSTANTS[1]))) : ((( CONSTANTS[4]*ALGEBRAIC[4])/( CONSTANTS[0]*CONSTANTS[1]))/(exp(ALGEBRAIC[4]/( CONSTANTS[0]*CONSTANTS[1])) - 1.00000))*(exp(ALGEBRAIC[3]/( CONSTANTS[0]*CONSTANTS[1])) - exp(ALGEBRAIC[5]/( CONSTANTS[0]*CONSTANTS[1])))); ALGEBRAIC[7] = CONSTANTS[2]*- CONSTANTS[7]*ALGEBRAIC[6]; }