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 28 entries in the algebraic variable array.
   There are a total of 8 entries in each of the rate and state variable arrays.
   There are a total of 31 entries in the constant variable array.
 */
/*
 * VOI is time in component environment (second).
 * STATES[0] is wi in component wi (micrometre).
 * CONSTANTS[0] is Lp in component model_parameters (cm_per_millimolar_second).
 * CONSTANTS[1] is Xi in component model_parameters (millimolar_micrometre).
 * ALGEBRAIC[8] is Nao in component model_parameters (millimolar).
 * ALGEBRAIC[6] is Ko in component model_parameters (millimolar).
 * ALGEBRAIC[10] is Clo in component model_parameters (millimolar).
 * ALGEBRAIC[12] is HCO3o in component model_parameters (millimolar).
 * ALGEBRAIC[7] is Nai in component model_parameters (millimolar).
 * ALGEBRAIC[5] is Ki in component model_parameters (millimolar).
 * ALGEBRAIC[9] is Cli in component model_parameters (millimolar).
 * ALGEBRAIC[11] is HCO3i in component model_parameters (millimolar).
 * ALGEBRAIC[0] is wo in component wo (micrometre).
 * CONSTANTS[2] is w_tot in component wo (micrometre).
 * STATES[1] is N_Nai in component N_Nai (millimolar_micrometre).
 * ALGEBRAIC[26] is dN_Nai_dt in component N_Nai (millimolar_micrometre_per_second).
 * CONSTANTS[3] is gNa in component model_parameters (per_ohm_cm2).
 * ALGEBRAIC[13] is ENa in component Nernst_potentials (volt).
 * ALGEBRAIC[20] is Vm in component membrane (volt).
 * ALGEBRAIC[19] is J_NaKATPase in component J_NaKATPase (mole_per_cm2_second).
 * CONSTANTS[4] is F in component model_parameters (C_per_mol).
 * CONSTANTS[5] is theta_NKCC1 in component model_parameters (dimensionless).
 * ALGEBRAIC[17] is J_NKCC1 in component J_NKCC1 (millimolar_micrometre_per_second).
 * CONSTANTS[6] is theta_NBC in component model_parameters (dimensionless).
 * ALGEBRAIC[24] is J_NBC in component J_NBC (millimolar_micrometre_per_second).
 * STATES[2] is N_Ki in component N_Ki (millimolar_micrometre).
 * ALGEBRAIC[23] is dN_Ki_dt in component N_Ki (millimolar_micrometre_per_second).
 * CONSTANTS[7] is gK in component model_parameters (per_ohm_cm2).
 * ALGEBRAIC[14] is EK in component Nernst_potentials (volt).
 * CONSTANTS[8] is theta_KCC1 in component model_parameters (dimensionless).
 * ALGEBRAIC[16] is J_KCC1 in component J_KCC1 (millimolar_micrometre_per_second).
 * STATES[3] is N_HCO3i in component N_HCO3i (millimolar_micrometre).
 * ALGEBRAIC[27] is dN_HCO3i_dt in component N_HCO3i (millimolar_micrometre_per_second).
 * STATES[4] is N_Cli in component N_Cli (millimolar_micrometre).
 * STATES[5] is N_Nao in component N_Nao (millimolar_micrometre).
 * ALGEBRAIC[4] is y in component model_parameters (dimensionless).
 * CONSTANTS[9] is kc in component model_parameters (micrometre_millimolar_per_second).
 * STATES[6] is N_Ko in component N_Ko (millimolar_micrometre).
 * STATES[7] is N_HCO3o in component N_HCO3o (millimolar_micrometre).
 * ALGEBRAIC[1] is N_Clo in component N_Clo (millimolar_micrometre).
 * ALGEBRAIC[15] is ECl in component Nernst_potentials (volt).
 * CONSTANTS[10] is T in component model_parameters (kelvin).
 * CONSTANTS[11] is R in component model_parameters (J_per_mol_K).
 * CONSTANTS[12] is gKCC1 in component J_KCC1 (per_ohm_cm2).
 * ALGEBRAIC[2] is ft in component J_KCC1 (dimensionless).
 * CONSTANTS[13] is gNBC in component J_NBC (per_ohm_cm2).
 * ALGEBRAIC[18] is ENBC in component ENBC (volt).
 * CONSTANTS[14] is gNKCC1 in component J_NKCC1 (per_ohm_cm2).
 * ALGEBRAIC[3] is ft in component J_NKCC1 (dimensionless).
 * CONSTANTS[15] is zNBC in component ENBC (dimensionless).
 * CONSTANTS[16] is gCl in component model_parameters (per_ohm_cm2).
 * CONSTANTS[17] is Pmax in component J_NaKATPase (mole_per_cm2_second).
 * CONSTANTS[18] is K_Nai in component J_NaKATPase (millimolar).
 * CONSTANTS[19] is K_Ko in component J_NaKATPase (millimolar).
 * ALGEBRAIC[21] is I_K in component I_K (millimolar_micrometre_per_second).
 * CONSTANTS[20] is nA in component model_parameters (per_mole).
 * CONSTANTS[21] is elementary_charge in component model_parameters (C).
 * ALGEBRAIC[22] is I_Cl in component I_Cl (millimolar_micrometre_per_second).
 * ALGEBRAIC[25] is I_Na in component I_Na (millimolar_micrometre_per_second).
 * CONSTANTS[22] is t0 in component model_parameters (second).
 * CONSTANTS[23] is t1 in component model_parameters (second).
 * CONSTANTS[24] is t2 in component model_parameters (second).
 * CONSTANTS[25] is alpha in component model_parameters (dimensionless).
 * CONSTANTS[26] is beta in component model_parameters (dimensionless).
 * CONSTANTS[27] is deltaT in component model_parameters (second).
 * CONSTANTS[28] is gamma_alpha_beta in component model_parameters (dimensionless).
 * CONSTANTS[29] is gamma_alpha in component model_parameters (dimensionless).
 * CONSTANTS[30] is gamma_beta in component model_parameters (dimensionless).
 * RATES[0] is d/dt wi in component wi (micrometre).
 * RATES[1] is d/dt N_Nai in component N_Nai (millimolar_micrometre).
 * RATES[2] is d/dt N_Ki in component N_Ki (millimolar_micrometre).
 * RATES[3] is d/dt N_HCO3i in component N_HCO3i (millimolar_micrometre).
 * RATES[4] is d/dt N_Cli in component N_Cli (millimolar_micrometre).
 * RATES[5] is d/dt N_Nao in component N_Nao (millimolar_micrometre).
 * RATES[6] is d/dt N_Ko in component N_Ko (millimolar_micrometre).
 * RATES[7] is d/dt N_HCO3o in component N_HCO3o (millimolar_micrometre).
 * There are a total of 16 condition variables.
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
STATES[0] = 0.061;
CONSTANTS[0] = 2.1e-4;
CONSTANTS[1] = 12.41;
CONSTANTS[2] = 0.0879;
STATES[1] = 0.99796;
CONSTANTS[3] = 1.314e-4;
CONSTANTS[4] = 9.649e4;
CONSTANTS[5] = 1;
CONSTANTS[6] = 1;
STATES[2] = 5.52782;
CONSTANTS[7] = 0.004;
CONSTANTS[8] = 1;
STATES[3] = 0.58804;
STATES[4] = 0.32879;
STATES[5] = 4.301041;
CONSTANTS[9] = 7.35e-2;
STATES[6] = 0.0807;
STATES[7] = 0.432552;
CONSTANTS[10] = 300;
CONSTANTS[11] = 8.315;
CONSTANTS[12] = 1e-6;
CONSTANTS[13] = 9.03e-5;
CONSTANTS[14] = 5.54e-6;
CONSTANTS[15] = -1;
CONSTANTS[16] = 8.797e-5;
CONSTANTS[17] = 1.4207e-10;
CONSTANTS[18] = 10;
CONSTANTS[19] = 1.5;
CONSTANTS[20] = 6.0221415e23;
CONSTANTS[21] = 1.6e-19;
CONSTANTS[22] = 10;
CONSTANTS[23] = 20;
CONSTANTS[24] = 30;
CONSTANTS[25] = 2;
CONSTANTS[26] = 14;
CONSTANTS[27] = CONSTANTS[23] - CONSTANTS[22];
CONSTANTS[28] = factorial((CONSTANTS[25]+CONSTANTS[26]) - 1.00000);
CONSTANTS[29] = factorial(CONSTANTS[25] - 1.00000);
CONSTANTS[30] = factorial(CONSTANTS[26] - 1.00000);
RATES[0] = 0.1;
RATES[1] = 0.1;
RATES[2] = 0.1;
RATES[3] = 0.1;
RATES[4] = 0.1;
RATES[5] = 0.1;
RATES[6] = 0.1;
RATES[7] = 0.1;
}
void
computeResiduals(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
                 double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
resid[0] = RATES[0] -  1.00000*CONSTANTS[0]*((ALGEBRAIC[7]+ALGEBRAIC[5]+ALGEBRAIC[9]+ALGEBRAIC[11]+CONSTANTS[1]/STATES[0]) - (ALGEBRAIC[8]+ALGEBRAIC[6]+ALGEBRAIC[10]+ALGEBRAIC[12]));
resid[1] = RATES[1] - ALGEBRAIC[26];
resid[2] = RATES[2] - ALGEBRAIC[23];
resid[3] = RATES[3] - ALGEBRAIC[27];
resid[4] = RATES[4] - ALGEBRAIC[23]+ALGEBRAIC[26]+ALGEBRAIC[27];
resid[5] = RATES[5] -  1.00000e+10*( (CONSTANTS[3]/CONSTANTS[4])*(ALGEBRAIC[20] - ALGEBRAIC[13])+ 3.00000*ALGEBRAIC[19]) - ( CONSTANTS[5]*ALGEBRAIC[17]+ CONSTANTS[6]*ALGEBRAIC[24]+ CONSTANTS[9]*ALGEBRAIC[4]);
resid[6] = RATES[6] - ( (( 1.00000e+10*CONSTANTS[7])/CONSTANTS[4])*(ALGEBRAIC[20] - ALGEBRAIC[14])+ CONSTANTS[9]*ALGEBRAIC[4]) - ( CONSTANTS[5]*ALGEBRAIC[17]+ CONSTANTS[8]*ALGEBRAIC[16]+ 1.00000e+10*2.00000*ALGEBRAIC[19]);
resid[7] = RATES[7] -  - 2.00000*CONSTANTS[6]*ALGEBRAIC[24];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[21] = ( 1.00000e+10*2.00000*ALGEBRAIC[19]*CONSTANTS[4])/( CONSTANTS[21]*CONSTANTS[20]) -  (( 1.00000e+10*CONSTANTS[7])/( CONSTANTS[21]*CONSTANTS[20]))*(ALGEBRAIC[20] - ALGEBRAIC[14]);
ALGEBRAIC[22] =  (( 1.00000e+10*CONSTANTS[16])/( CONSTANTS[21]*CONSTANTS[20]))*(ALGEBRAIC[20] - ALGEBRAIC[15]);
ALGEBRAIC[25] = ALGEBRAIC[24] - ( (( 1.00000e+10*CONSTANTS[3])/( CONSTANTS[21]*CONSTANTS[20]))*(ALGEBRAIC[20] - ALGEBRAIC[13])+( 1.00000e+10*3.00000*ALGEBRAIC[19]*CONSTANTS[4])/( CONSTANTS[21]*CONSTANTS[20]));
}
void
computeEssentialVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[4] = (CONDVAR[4]>=0.00000&&CONDVAR[5]<=0.00000 ?  (CONSTANTS[28]/( CONSTANTS[29]*CONSTANTS[30]))*pow(1.00000 - (VOI - CONSTANTS[22])/CONSTANTS[27], CONSTANTS[26] - 1.00000)*pow((VOI - CONSTANTS[22])/CONSTANTS[27], CONSTANTS[25] - 1.00000) : CONDVAR[6]>0.00000&&CONDVAR[7]<0.00000 ? -1.00000 : 0.00000);
ALGEBRAIC[5] = (CONDVAR[8]>0.00000 ? STATES[2]/STATES[0] : 1.00000e-180);
ALGEBRAIC[0] = CONSTANTS[2] - STATES[0];
ALGEBRAIC[6] = (CONDVAR[9]>0.00000 ? STATES[6]/ALGEBRAIC[0] : 1.00000e-180);
ALGEBRAIC[7] = (CONDVAR[10]>0.00000 ? STATES[1]/STATES[0] : 1.00000e-180);
ALGEBRAIC[8] = (CONDVAR[11]>0.00000 ? STATES[5]/ALGEBRAIC[0] : 1.00000e-180);
ALGEBRAIC[9] = (CONDVAR[12]>0.00000 ? STATES[4]/STATES[0] : 1.00000e-180);
ALGEBRAIC[1] = (STATES[5]+STATES[6]) - STATES[7];
ALGEBRAIC[10] = (CONDVAR[13]>0.00000 ? ALGEBRAIC[1]/ALGEBRAIC[0] : 1.00000e-180);
ALGEBRAIC[11] = (CONDVAR[14]>0.00000 ? STATES[3]/STATES[0] : 1.00000e-180);
ALGEBRAIC[12] = (CONDVAR[15]>0.00000 ? STATES[7]/ALGEBRAIC[0] : 1.00000e-180);
ALGEBRAIC[13] =  (( CONSTANTS[11]*CONSTANTS[10])/( 1.00000*CONSTANTS[4]))*log(ALGEBRAIC[8]/ALGEBRAIC[7]);
ALGEBRAIC[14] =  (( CONSTANTS[11]*CONSTANTS[10])/( 1.00000*CONSTANTS[4]))*log(ALGEBRAIC[6]/ALGEBRAIC[5]);
ALGEBRAIC[2] = (CONDVAR[0]>=0.00000&&CONDVAR[1]<0.00000 ? 1.00000 : 0.00000);
ALGEBRAIC[16] =  (( (( 1.00000e+10*CONSTANTS[12]*ALGEBRAIC[2])/CONSTANTS[4])*CONSTANTS[11]*CONSTANTS[10])/CONSTANTS[4])*log(( ALGEBRAIC[6]*ALGEBRAIC[10])/( ALGEBRAIC[5]*ALGEBRAIC[9]));
ALGEBRAIC[3] = (CONDVAR[2]>=0.00000&&CONDVAR[3]<0.00000 ? 1.00000 : 0.00000);
ALGEBRAIC[17] =  (( (( 1.00000e+10*CONSTANTS[14]*ALGEBRAIC[3])/CONSTANTS[4])*CONSTANTS[11]*CONSTANTS[10])/CONSTANTS[4])*log( (( (ALGEBRAIC[8]/ALGEBRAIC[7])*ALGEBRAIC[6])/ALGEBRAIC[5])*pow(ALGEBRAIC[10]/ALGEBRAIC[9], 2.00000));
ALGEBRAIC[19] = ( (( CONSTANTS[17]*pow(ALGEBRAIC[7], 1.50000))/(pow(ALGEBRAIC[7], 1.50000)+pow(CONSTANTS[18], 1.50000)))*ALGEBRAIC[6])/(ALGEBRAIC[6]+CONSTANTS[19]);
ALGEBRAIC[15] =  (( CONSTANTS[11]*CONSTANTS[10])/( - 1.00000*CONSTANTS[4]))*log(ALGEBRAIC[10]/ALGEBRAIC[9]);
ALGEBRAIC[18] =  (( CONSTANTS[11]*CONSTANTS[10])/( CONSTANTS[15]*CONSTANTS[4]))*log(( (ALGEBRAIC[8]/ALGEBRAIC[7])*pow(ALGEBRAIC[12], 2.00000))/pow(ALGEBRAIC[11], 2.00000));
ALGEBRAIC[20] = (( CONSTANTS[3]*ALGEBRAIC[13]+ CONSTANTS[7]*ALGEBRAIC[14]+ CONSTANTS[16]*ALGEBRAIC[15]+ CONSTANTS[6]*CONSTANTS[13]*ALGEBRAIC[18]) -  ALGEBRAIC[19]*CONSTANTS[4])/(CONSTANTS[3]+CONSTANTS[7]+CONSTANTS[16]+ CONSTANTS[6]*CONSTANTS[13]);
ALGEBRAIC[23] = ( CONSTANTS[5]*ALGEBRAIC[17]+ CONSTANTS[8]*ALGEBRAIC[16]+ 1.00000e+10*2.00000*ALGEBRAIC[19]) -  (( 1.00000e+10*CONSTANTS[7])/CONSTANTS[4])*(ALGEBRAIC[20] - ALGEBRAIC[14]);
ALGEBRAIC[24] =  (( 1.00000e+10*CONSTANTS[13])/CONSTANTS[4])*(ALGEBRAIC[20] - ALGEBRAIC[18]);
ALGEBRAIC[26] = ( CONSTANTS[5]*ALGEBRAIC[17]+ CONSTANTS[6]*ALGEBRAIC[24]) -  1.00000e+10*( (CONSTANTS[3]/CONSTANTS[4])*(ALGEBRAIC[20] - ALGEBRAIC[13])+ 3.00000*ALGEBRAIC[19]);
ALGEBRAIC[27] =  2.00000*CONSTANTS[6]*ALGEBRAIC[24];
}
void
getStateInformation(double* SI)
{
SI[0] = 1.0;
SI[1] = 1.0;
SI[2] = 1.0;
SI[3] = 1.0;
SI[4] = 1.0;
SI[5] = 1.0;
SI[6] = 1.0;
SI[7] = 1.0;
}
void
computeRoots(double VOI, double* CONSTANTS, double* RATES, double* OLDRATES, double* STATES,
             double* OLDSTATES, double* ALGEBRAIC, double* CONDVARS)
{
CONDVAR[0] = VOI - 10.0000;
CONDVAR[1] = VOI - 20.0000;
CONDVAR[2] = VOI - 10.0000;
CONDVAR[3] = VOI - 20.0000;
CONDVAR[4] = VOI - CONSTANTS[22];
CONDVAR[5] = VOI - CONSTANTS[23];
CONDVAR[6] = VOI - CONSTANTS[23];
CONDVAR[7] = VOI - CONSTANTS[24];
CONDVAR[8] = STATES[2]/STATES[0] - 0.00000;
CONDVAR[9] = STATES[6]/ALGEBRAIC[0] - 0.00000;
CONDVAR[10] = STATES[1]/STATES[0] - 0.00000;
CONDVAR[11] = STATES[5]/ALGEBRAIC[0] - 0.00000;
CONDVAR[12] = STATES[4]/STATES[0] - 0.00000;
CONDVAR[13] = ALGEBRAIC[1]/ALGEBRAIC[0] - 0.00000;
CONDVAR[14] = STATES[3]/STATES[0] - 0.00000;
CONDVAR[15] = STATES[7]/ALGEBRAIC[0] - 0.00000;
}