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 16 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 37 entries in the constant variable array.
 */
/*
 * VOI is Time in component Environmental (second).
 * CONSTANTS[0] is S in component Parameters (hertz).
 * CONSTANTS[1] is Zeta in component Parameters (dimensionless).
 * CONSTANTS[2] is R0 in component Parameters (mm).
 * CONSTANTS[3] is Cwall in component Parameters (mm_per_mmHg).
 * CONSTANTS[4] is Kne in component Parameters (mmHg_per_mm).
 * CONSTANTS[5] is K1 in component Parameters (mmHg_per_mm).
 * CONSTANTS[6] is K2 in component Parameters (mmHg_per_mm).
 * CONSTANTS[7] is K3 in component Parameters (mmHg_per_mm).
 * CONSTANTS[8] is Bwall in component Parameters (mmHg_s_per_sq_mm).
 * CONSTANTS[9] is B1 in component Parameters (mmHg_s_per_mm).
 * CONSTANTS[10] is B2 in component Parameters (mmHg_s_per_mm).
 * CONSTANTS[11] is B3 in component Parameters (mmHg_s_per_mm).
 * CONSTANTS[12] is Tsmax in component Parameters (AU).
 * CONSTANTS[13] is Tpmax in component Parameters (AU).
 * CONSTANTS[14] is Tsmin in component Parameters (AU).
 * CONSTANTS[15] is Tpmin in component Parameters (AU).
 * CONSTANTS[16] is Gcns in component Parameters (dimensionless).
 * CONSTANTS[17] is Gs in component Parameters (per_Hertz).
 * CONSTANTS[18] is Gp in component Parameters (per_Hertz).
 * CONSTANTS[19] is tau_nor in component Parameters (second).
 * CONSTANTS[20] is tau_ach in component Parameters (second).
 * CONSTANTS[21] is tau_HR_nor in component Parameters (second).
 * CONSTANTS[22] is tau_HR_ach in component Parameters (second).
 * CONSTANTS[23] is HRo in component Parameters (Beats_per_min).
 * CONSTANTS[24] is HRmax in component Parameters (Beats_per_min).
 * CONSTANTS[25] is HRmin in component Parameters (Beats_per_min).
 * CONSTANTS[26] is Beta in component Parameters (dimensionless).
 * CONSTANTS[27] is delta_th in component Parameters (dimensionless).
 * CONSTANTS[28] is q_nor in component Parameters (per_s).
 * CONSTANTS[29] is q_ach in component Parameters (per_s).
 * CONSTANTS[30] is K_nor in component Parameters (AU).
 * CONSTANTS[31] is K_ach in component Parameters (AU).
 * CONSTANTS[32] is Gamma in component Parameters (dimensionless).
 * ALGEBRAIC[10] is alpha_cns in component Nervous_System (hertz).
 * ALGEBRAIC[8] is n in component Nervous_System (hertz).
 * ALGEBRAIC[6] is Delta in component Coupling_Dynamics (dimensionless).
 * CONSTANTS[33] is alpha_s0 in component Nervous_System (hertz).
 * CONSTANTS[34] is alpha_p0 in component Nervous_System (hertz).
 * STATES[0] is A in component Aortic_Wall (mm_sq).
 * ALGEBRAIC[0] is P in component Aortic_Wall (mmHg).
 * ALGEBRAIC[1] is R in component Aortic_Wall (mm).
 * STATES[1] is Eps_1 in component Coupling_Dynamics (dimensionless).
 * STATES[2] is Eps_2 in component Coupling_Dynamics (dimensionless).
 * STATES[3] is Eps_3 in component Coupling_Dynamics (dimensionless).
 * ALGEBRAIC[4] is Eps_wall in component Coupling_Dynamics (dimensionless).
 * ALGEBRAIC[12] is Ts in component PNS_tones (AU).
 * ALGEBRAIC[13] is Tp in component PNS_tones (AU).
 * STATES[4] is c_nor in component Norepinephrine (AU).
 * STATES[5] is C_ach in component Acetylcholine (AU).
 * ALGEBRAIC[2] is delta_HR_ss in component Heart_Response_Nor (Beats_per_min).
 * CONSTANTS[35] is delta_HR_smax in component Heart_Response_Nor (Beats_per_min).
 * STATES[6] is delta_HR_s in component Heart_Response_Nor (Beats_per_min).
 * ALGEBRAIC[3] is delta_HR_ps in component HR_ach (Beats_per_min).
 * CONSTANTS[36] is delta_HR_pmax in component HR_ach (Beats_per_min).
 * ALGEBRAIC[5] is delta_HR_pfast in component HR_ach (Beats_per_min).
 * STATES[7] is delta_HR_pslow in component HR_ach (Beats_per_min).
 * ALGEBRAIC[7] is delta_HR_p in component HR_ach (Beats_per_min).
 * ALGEBRAIC[14] is HR in component HR_Combined (Beats_per_min).
 * ALGEBRAIC[11] is HR_p in component HR_Combined (Beats_per_min).
 * ALGEBRAIC[9] is HR_s in component HR_Combined (Beats_per_min).
 * ALGEBRAIC[15] is Period in component HR_Combined (Sec_per_Beat).
 * RATES[0] is d/dt A in component Aortic_Wall (mm_sq).
 * RATES[1] is d/dt Eps_1 in component Coupling_Dynamics (dimensionless).
 * RATES[2] is d/dt Eps_2 in component Coupling_Dynamics (dimensionless).
 * RATES[3] is d/dt Eps_3 in component Coupling_Dynamics (dimensionless).
 * RATES[4] is d/dt c_nor in component Norepinephrine (AU).
 * RATES[5] is d/dt C_ach in component Acetylcholine (AU).
 * RATES[6] is d/dt delta_HR_s in component Heart_Response_Nor (Beats_per_min).
 * RATES[7] is d/dt delta_HR_pslow in component HR_ach (Beats_per_min).
 */
void
initConsts(double* CONSTANTS, double* RATES, double *STATES)
{
CONSTANTS[0] = 480;
CONSTANTS[1] = 1;
CONSTANTS[2] = 1.6;
CONSTANTS[3] = 0.006;
CONSTANTS[4] = 1;
CONSTANTS[5] = 1.5;
CONSTANTS[6] = 3.75;
CONSTANTS[7] = 1.05;
CONSTANTS[8] = 1;
CONSTANTS[9] = 1;
CONSTANTS[10] = 10;
CONSTANTS[11] = 206.973;
CONSTANTS[12] = 4.12;
CONSTANTS[13] = 4.994;
CONSTANTS[14] = 0.5;
CONSTANTS[15] = 1.6;
CONSTANTS[16] = 1;
CONSTANTS[17] = 0.178;
CONSTANTS[18] = 0.492;
CONSTANTS[19] = 9.1;
CONSTANTS[20] = 0.2;
CONSTANTS[21] = 2.1;
CONSTANTS[22] = 2.5;
CONSTANTS[23] = 282.648;
CONSTANTS[24] = 483.218;
CONSTANTS[25] = 226.238;
CONSTANTS[26] = 0.175;
CONSTANTS[27] = 0;
CONSTANTS[28] = 0.1099;
CONSTANTS[29] = 5;
CONSTANTS[30] = 1.12;
CONSTANTS[31] = 0.65;
CONSTANTS[32] = 0.75;
CONSTANTS[33] = 58.6;
CONSTANTS[34] = 76.019;
STATES[0] = 15.20531;
STATES[1] = 0.2042;
STATES[2] = 0.183;
STATES[3] = 0.161;
STATES[4] = 1.441;
STATES[5] = 1.0;
STATES[6] = 0;
STATES[7] = 0;
CONSTANTS[35] = CONSTANTS[24] - CONSTANTS[23];
CONSTANTS[36] = CONSTANTS[23] - CONSTANTS[25];
}
void
computeRates(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = 100.000+ 10.0000* sin( 5.00000*VOI);
RATES[0] = (- ( pow((STATES[0]/ 3.14159265358979), 1.0 / 2) - CONSTANTS[2])/CONSTANTS[3]+ALGEBRAIC[0])/CONSTANTS[8];
ALGEBRAIC[2] = ( CONSTANTS[35]*pow(STATES[4], 2.00000))/(pow(CONSTANTS[30], 2.00000)+pow(STATES[4], 2.00000));
RATES[6] = (- STATES[6]+ALGEBRAIC[2])/CONSTANTS[21];
ALGEBRAIC[3] = ( CONSTANTS[36]*pow(STATES[5], 2.00000))/(pow(CONSTANTS[31], 2.00000)+pow(STATES[5], 2.00000));
RATES[7] = (- STATES[7]+ (1.00000 - CONSTANTS[32])*ALGEBRAIC[3])/CONSTANTS[22];
ALGEBRAIC[1] = pow(STATES[0]/ 3.14159265358979, 0.500000);
ALGEBRAIC[4] = (ALGEBRAIC[1] - CONSTANTS[2])/CONSTANTS[2];
rootfind_0(VOI, CONSTANTS, RATES, STATES, ALGEBRAIC, pret);
ALGEBRAIC[6] = ALGEBRAIC[4] - STATES[1];
ALGEBRAIC[8] =  CONSTANTS[0]*(ALGEBRAIC[6] -  CONSTANTS[1]*CONSTANTS[27]);
ALGEBRAIC[10] =  CONSTANTS[16]*ALGEBRAIC[8];
ALGEBRAIC[12] = CONSTANTS[14]+(CONSTANTS[12] - CONSTANTS[14])/(exp( CONSTANTS[17]*(ALGEBRAIC[10] - CONSTANTS[33]))+1.00000);
RATES[4] = - (STATES[4]/CONSTANTS[19])+ CONSTANTS[28]*ALGEBRAIC[12];
ALGEBRAIC[13] = CONSTANTS[15]+(CONSTANTS[13] - CONSTANTS[15])/(exp( - CONSTANTS[18]*(ALGEBRAIC[10] - CONSTANTS[34]))+1.00000);
RATES[5] = - (STATES[5]/CONSTANTS[20])+ CONSTANTS[29]*ALGEBRAIC[13];
}
void
computeVariables(double VOI, double* CONSTANTS, double* RATES, double* STATES, double* ALGEBRAIC)
{
ALGEBRAIC[0] = 100.000+ 10.0000* sin( 5.00000*VOI);
ALGEBRAIC[2] = ( CONSTANTS[35]*pow(STATES[4], 2.00000))/(pow(CONSTANTS[30], 2.00000)+pow(STATES[4], 2.00000));
ALGEBRAIC[3] = ( CONSTANTS[36]*pow(STATES[5], 2.00000))/(pow(CONSTANTS[31], 2.00000)+pow(STATES[5], 2.00000));
ALGEBRAIC[1] = pow(STATES[0]/ 3.14159265358979, 0.500000);
ALGEBRAIC[4] = (ALGEBRAIC[1] - CONSTANTS[2])/CONSTANTS[2];
ALGEBRAIC[6] = ALGEBRAIC[4] - STATES[1];
ALGEBRAIC[8] =  CONSTANTS[0]*(ALGEBRAIC[6] -  CONSTANTS[1]*CONSTANTS[27]);
ALGEBRAIC[10] =  CONSTANTS[16]*ALGEBRAIC[8];
ALGEBRAIC[12] = CONSTANTS[14]+(CONSTANTS[12] - CONSTANTS[14])/(exp( CONSTANTS[17]*(ALGEBRAIC[10] - CONSTANTS[33]))+1.00000);
ALGEBRAIC[13] = CONSTANTS[15]+(CONSTANTS[13] - CONSTANTS[15])/(exp( - CONSTANTS[18]*(ALGEBRAIC[10] - CONSTANTS[34]))+1.00000);
ALGEBRAIC[5] =  CONSTANTS[32]*ALGEBRAIC[3];
ALGEBRAIC[7] = ALGEBRAIC[5]+STATES[7];
ALGEBRAIC[9] = CONSTANTS[23]+STATES[6];
ALGEBRAIC[11] = CONSTANTS[23] - ALGEBRAIC[7];
ALGEBRAIC[14] = ALGEBRAIC[11]+( (ALGEBRAIC[9] - CONSTANTS[23])*(ALGEBRAIC[11] -  CONSTANTS[26]*CONSTANTS[25]))/(CONSTANTS[23] -  CONSTANTS[26]*CONSTANTS[25]);
ALGEBRAIC[15] = 60.0000/ALGEBRAIC[14];
}

void objfunc_0(double *p, double *hx, int m, int n, void *adata)
{
  struct rootfind_info* rfi = (struct rootfind_info*)adata;
#define VOI rfi->aVOI
#define CONSTANTS rfi->aCONSTANTS
#define RATES rfi->aRATES
#define STATES rfi->aSTATES
#define ALGEBRAIC rfi->aALGEBRAIC
#define pret rfi->aPRET
  RATES[1] = p[0];
  RATES[2] = p[1];
  RATES[3] = p[2];
  hx[0] = RATES[1] - (( CONSTANTS[4]*(ALGEBRAIC[4] - STATES[1]) -  CONSTANTS[5]*(STATES[1] - STATES[2]))/CONSTANTS[9]+RATES[2]);
  hx[1] = RATES[2] - (( CONSTANTS[5]*(STATES[1] - STATES[2]) -  CONSTANTS[6]*(STATES[2] - STATES[3]))+ CONSTANTS[9]*RATES[1]+ CONSTANTS[10]*RATES[3])/(CONSTANTS[9]+CONSTANTS[10]);
  hx[2] = RATES[3] - (( CONSTANTS[6]*(STATES[2] - STATES[3]) -  CONSTANTS[7]*STATES[3])+ CONSTANTS[10]*RATES[2])/(CONSTANTS[10]+CONSTANTS[11]);
#undef VOI
#undef CONSTANTS
#undef RATES
#undef STATES
#undef ALGEBRAIC
#undef pret
}
void rootfind_0(double VOI, double* CONSTANTS, double* RATES,
double* STATES, double* ALGEBRAIC, int* pret)
{
  static double p[3] = {0.1,0.1,0.1};
  double bp[3], work[LM_DIF_WORKSZ(3, 3)];
  struct rootfind_info rfi;
  rfi.aVOI = VOI;
  rfi.aCONSTANTS = CONSTANTS;
  rfi.aRATES = RATES;
  rfi.aSTATES = STATES;
  rfi.aALGEBRAIC = ALGEBRAIC;
  rfi.aPRET = pret;
  do_levmar(objfunc_0, p, bp, work, pret, 3, &rfi);
  RATES[1] = p[0];
  RATES[2] = p[1];
  RATES[3] = p[2];
}
Source
Derived from workspace Bugenhagen 2010 at changeset cac8b4a154b4.
Collaboration
To begin collaborating on this work, please use your git client and issue this command:
License

This work is licensed under a Creative Commons Attribution 3.0 Unported License.