Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Code/Source/solver/CepMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ class cepModelType

/// @brief Time integration options
odeType odes;

/// @brief Interface for Aliev-Panfilov cellular activation model
CepModAp ap;

/// @brief Interface for Bueno-Orovio cellular activation model
CepModBo bo;

/// @brief Interface for Fitzhugh-Nagumo cellular activation model
CepModFn fn;

/// @brief Interface for Tusscher-Panfilov cellular activation model
CepModTtp ttp;
};

/// @brief Cardiac electromechanics model type
Expand Down
74 changes: 37 additions & 37 deletions Code/Source/solver/cep_ion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void cep_init(Simulation* simulation)
for (int iDmn = 0; iDmn < eq.nDmn; iDmn++) {
auto cPhys = eq.dmn[iDmn].phys;
int dID = eq.dmn[iDmn].Id;
if ((cPhys != EquationType::phys_CEP) || !utils::btest(com_mod.dmnId(a),dID)) {
if ((cPhys != EquationType::phys_CEP) || (dID >= 0 && !utils::btest(com_mod.dmnId(a),dID))) {
continue;
}
int nX = eq.dmn[iDmn].cep.nX;
Expand All @@ -62,7 +62,7 @@ void cep_init(Simulation* simulation)
Vector<double> Xl(nX);
Vector<double> Xgl(nG);

cep_init_l(cep_mod, eq.dmn[iDmn].cep, nX, nG, Xl, Xgl);
cep_init_l(eq.dmn[iDmn].cep, nX, nG, Xl, Xgl);

sA(a) = sA(a) + 1.0;

Expand Down Expand Up @@ -97,7 +97,7 @@ void cep_init(Simulation* simulation)
Vector<double> Xl(nX);
Vector<double> Xgl(nG);

cep_init_l(cep_mod, eq.dmn[1].cep, nX, nG, Xl, Xgl);
cep_init_l(eq.dmn[0].cep, nX, nG, Xl, Xgl);

for (int i = 0; i < nX; i++) {
cep_mod.Xion(i,a) = Xl(i);
Expand All @@ -114,24 +114,24 @@ void cep_init(Simulation* simulation)
// cep_init_l
//------------
//
void cep_init_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<double>& X, Vector<double>& Xg)
void cep_init_l(cepModelType& cep, int nX, int nG, Vector<double>& X, Vector<double>& Xg)
{
switch (cep.cepType) {

case ElectrophysiologyModelType::AP:
cep_mod.ap.init(nX, X);
cep.ap.init(nX, X);
break;

case ElectrophysiologyModelType::BO:
cep_mod.bo.init(nX, X);
cep.bo.init(nX, X);
break;

case ElectrophysiologyModelType::FN:
cep_mod.fn.init(nX, X);
cep.fn.init(nX, X);
break;

case ElectrophysiologyModelType::TTP:
cep_mod.ttp.init(cep.imyo, nX, nG, X, Xg);
cep.ttp.init(cep.imyo, nX, nG, X, Xg);
break;
}
}
Expand Down Expand Up @@ -220,9 +220,9 @@ void cep_integ(Simulation* simulation, const int iEq, const int iDof, const Arra
auto cPhys = dmn.phys;
int dID = dmn.Id;

if (cPhys != Equation_CEP || !utils::btest(com_mod.dmnId(Ac),dID)) {
if (cPhys != Equation_CEP || (dID >= 0 && !utils::btest(com_mod.dmnId(Ac),dID))) {
continue;
}
}

int nX = dmn.cep.nX;
int nG = dmn.cep.nG;
Expand Down Expand Up @@ -383,12 +383,12 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
} else {
Istim = 0.0;
}
cep_mod.ap.integ_fe(nX, X, t, cep.dt, Istim, Ksac);
cep.ap.integ_fe(nX, X, t, cep.dt, Istim, Ksac);

// Electromechanics excitation-activation
if (cem.aStress) {
double epsX;
cep_mod.ap.actv_strs(X(0), cep.dt, yl, epsX);
cep.ap.actv_strs(X(0), cep.dt, yl, epsX);
}
}
} break;
Expand All @@ -402,12 +402,12 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
} else {
Istim = 0.0;
}
cep_mod.ap.integ_rk(nX, X, t, cep.dt, Istim, Ksac);
cep.ap.integ_rk(nX, X, t, cep.dt, Istim, Ksac);

// Electromechanics excitation-activation
if (cem.aStress) {
double epsX;
cep_mod.ap.actv_strs(X(0), cep.dt, yl, epsX);
cep.ap.actv_strs(X(0), cep.dt, yl, epsX);
}
}
} break;
Expand All @@ -422,12 +422,12 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
Istim = 0.0;
}

cep_mod.ap.integ_cn2(nX, X, t, cep.dt, Istim, Ksac, IPAR, RPAR);
cep.ap.integ_cn2(nX, X, t, cep.dt, Istim, Ksac, IPAR, RPAR);

// Electromechanics excitation-activation
if (cem.aStress) {
double epsX;
cep_mod.ap.actv_strs(X(0), cep.dt, yl, epsX);
cep.ap.actv_strs(X(0), cep.dt, yl, epsX);
}
}
} break;
Expand All @@ -453,14 +453,14 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
Istim = 0.0;
}

cep_mod.bo.integ_fe(cep.imyo, nX, X, t, cep.dt, Istim, Ksac, RPAR);
cep.bo.integ_fe(cep.imyo, nX, X, t, cep.dt, Istim, Ksac, RPAR);

// Electromechanics excitation-activation
if (cem.aStress) {
double epsX;
cep_mod.bo.actv_strs(X(0), cep.dt, yl, epsX);
cep.bo.actv_strs(X(0), cep.dt, yl, epsX);
} else if (cem.aStrain) {
cep_mod.bo.actv_strn(X(3), I4f, cep.dt, yl);
cep.bo.actv_strn(X(3), I4f, cep.dt, yl);
}
}
} break;
Expand All @@ -475,14 +475,14 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
Istim = 0.0;
}

cep_mod.bo.integ_rk(cep.imyo, nX, X, t, cep.dt, Istim, Ksac, RPAR);
cep.bo.integ_rk(cep.imyo, nX, X, t, cep.dt, Istim, Ksac, RPAR);

// Electromechanics excitation-activation
if (cem.aStress) {
double epsX;
cep_mod.bo.actv_strs(X(0), cep.dt, yl, epsX);
cep.bo.actv_strs(X(0), cep.dt, yl, epsX);
} else if (cem.aStrain) {
cep_mod.bo.actv_strn(X(3), I4f, cep.dt, yl);
cep.bo.actv_strn(X(3), I4f, cep.dt, yl);
}
}
} break;
Expand All @@ -497,14 +497,14 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
Istim = 0.0;
}

cep_mod.bo.integ_cn2(cep.imyo, nX, X, t, cep.dt, Istim, Ksac, IPAR, RPAR);
cep.bo.integ_cn2(cep.imyo, nX, X, t, cep.dt, Istim, Ksac, IPAR, RPAR);

// Electromechanics excitation-activation
if (cem.aStress) {
double epsX;
cep_mod.bo.actv_strs(X(0), cep.dt, yl, epsX);
cep.bo.actv_strs(X(0), cep.dt, yl, epsX);
} else if (cem.aStrain) {
cep_mod.bo.actv_strn(X(3), I4f, cep.dt, yl);
cep.bo.actv_strn(X(3), I4f, cep.dt, yl);
}
}
} break;
Expand All @@ -530,7 +530,7 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
} else {
Istim = 0.0;
}
cep_mod.fn.integ_fe(nX, X, t, cep.dt, Istim);
cep.fn.integ_fe(nX, X, t, cep.dt, Istim);
}
} break;

Expand All @@ -543,7 +543,7 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
} else {
Istim = 0.0;
}
cep_mod.fn.integ_rk(nX, X, t, cep.dt, Istim);
cep.fn.integ_rk(nX, X, t, cep.dt, Istim);
}
} break;

Expand All @@ -556,7 +556,7 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
} else {
Istim = 0.0;
}
cep_mod.fn.integ_cn2(nX, X, t, cep.dt, Istim, IPAR, RPAR);
cep.fn.integ_cn2(nX, X, t, cep.dt, Istim, IPAR, RPAR);
}
} break;
}
Expand All @@ -580,14 +580,14 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
} else {
Istim = 0.0;
}
cep_mod.ttp.integ_fe(cep.imyo, nX, nG, X, Xg, t, cep.dt, Istim, Ksac, RPAR);
cep.ttp.integ_fe(cep.imyo, nX, nG, X, Xg, t, cep.dt, Istim, Ksac, RPAR);

// Electromechanics excitation-activation
if (cem.aStress) {
double epsX;
cep_mod.ttp.actv_strs(X(3), cep.dt, yl, epsX);
cep.ttp.actv_strs(X(3), cep.dt, yl, epsX);
} else if (cem.aStrain) {
cep_mod.ttp.actv_strn(X(3), I4f, cep.dt, yl);
cep.ttp.actv_strn(X(3), I4f, cep.dt, yl);
}
}
} break;
Expand All @@ -602,14 +602,14 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
Istim = 0.0;
}

cep_mod.ttp.integ_rk(cep.imyo, nX, nG, X, Xg, t, cep.dt, Istim, Ksac, RPAR);
cep.ttp.integ_rk(cep.imyo, nX, nG, X, Xg, t, cep.dt, Istim, Ksac, RPAR);

// Electromechanics excitation-activation
if (cem.aStress) {
double epsX;
cep_mod.ttp.actv_strs(X(3), cep.dt, yl, epsX);
cep.ttp.actv_strs(X(3), cep.dt, yl, epsX);
} else if (cem.aStrain) {
cep_mod.ttp.actv_strn(X(3), I4f, cep.dt, yl);
cep.ttp.actv_strn(X(3), I4f, cep.dt, yl);
}
}
} break;
Expand All @@ -624,14 +624,14 @@ void cep_integ_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<doub
Istim = 0.0;
}

cep_mod.ttp.integ_cn2(cep.imyo, nX, nG, X, Xg, t, cep.dt, Istim, Ksac, IPAR, RPAR);
cep.ttp.integ_cn2(cep.imyo, nX, nG, X, Xg, t, cep.dt, Istim, Ksac, IPAR, RPAR);

// Electromechanics excitation-activation
if (cem.aStress) {
double epsX;
cep_mod.ttp.actv_strs(X(3), cep.dt, yl, epsX);
cep.ttp.actv_strs(X(3), cep.dt, yl, epsX);
} else if (cem.aStrain) {
cep_mod.ttp.actv_strn(X(3), I4f, cep.dt, yl);
cep.ttp.actv_strn(X(3), I4f, cep.dt, yl);
}
}
} break;
Expand Down
2 changes: 1 addition & 1 deletion Code/Source/solver/cep_ion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace cep_ion {

void cep_init(Simulation* simulation);

void cep_init_l(CepMod& cep_mod, cepModelType& cep, int nX, int nG, Vector<double>& X, Vector<double>& Xg);
void cep_init_l(cepModelType& cep, int nX, int nG, Vector<double>& X, Vector<double>& Xg);

void cep_integ(Simulation* simulation, const int iEq, const int iDof, const Array<double>& Dg);

Expand Down
17 changes: 9 additions & 8 deletions Code/Source/solver/distribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1557,14 +1557,15 @@ void dist_eq(ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, const std::
cm.bcast(cm_mod, &cep.odes.relTol);
}

cm.bcast(cm_mod, &cep_mod.ttp.G_Na);
cm.bcast(cm_mod, &cep_mod.ttp.G_CaL);
cm.bcast(cm_mod, &cep_mod.ttp.G_Kr);
cm.bcast(cm_mod, cep_mod.ttp.G_Ks);
cm.bcast(cm_mod, cep_mod.ttp.G_to);

cm.bcast(cm_mod, cep_mod.bo.tau_si);
cm.bcast(cm_mod, cep_mod.bo.tau_fi);
// Broadcast domain-specific model parameters
cm.bcast(cm_mod, &cep.ttp.G_Na);
cm.bcast(cm_mod, &cep.ttp.G_CaL);
cm.bcast(cm_mod, &cep.ttp.G_Kr);
cm.bcast(cm_mod, cep.ttp.G_Ks);
cm.bcast(cm_mod, cep.ttp.G_to);

cm.bcast(cm_mod, cep.bo.tau_si);
cm.bcast(cm_mod, cep.bo.tau_fi);
}

if ((dmn.phys == EquationType::phys_struct) || (dmn.phys == EquationType::phys_ustruct)) {
Expand Down
29 changes: 19 additions & 10 deletions Code/Source/solver/read_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,17 +1000,26 @@ void read_cep_domain(Simulation* simulation, EquationParameters* eq_params, Doma
}

// Set Ttp parameters.
//
if (domain_params->G_Na.defined()) { cep_mod.ttp.G_Na = domain_params->G_Na.value(); }
if (domain_params->G_Kr.defined()) { cep_mod.ttp.G_Kr = domain_params->G_Kr.value(); }
if (domain_params->G_Ks.defined()) { cep_mod.ttp.G_Ks[lDmn.cep.imyo - 1] = domain_params->G_Ks.value(); }
if (domain_params->G_to.defined()) { cep_mod.ttp.G_to[lDmn.cep.imyo - 1] = domain_params->G_to.value(); }
if (domain_params->G_CaL.defined()) { cep_mod.ttp.G_CaL = domain_params->G_CaL.value(); }
// Scalar params
std::map<Parameter<double>*,double*> simple_ttp_params{
{&domain_params->G_Na, &lDmn.cep.ttp.G_Na},
{&domain_params->G_Kr, &lDmn.cep.ttp.G_Kr},
{&domain_params->G_CaL, &lDmn.cep.ttp.G_CaL}
};

// Set Bo parameters.
//
if (domain_params->tau_si.defined()) { cep_mod.bo.tau_si[lDmn.cep.imyo - 1] = domain_params->tau_si.value(); }
if (domain_params->tau_fi.defined()) { cep_mod.bo.tau_fi[lDmn.cep.imyo - 1] = domain_params->tau_fi.value(); }
for (auto& [param, value] : simple_ttp_params) {
if (param->defined()) {
*value = param->value();
}
}

// Array params
if (domain_params->G_Ks.defined()) {
lDmn.cep.ttp.G_Ks[lDmn.cep.imyo - 1] = domain_params->G_Ks.value();
}
if (domain_params->G_to.defined()) {
lDmn.cep.ttp.G_to[lDmn.cep.imyo - 1] = domain_params->G_to.value();
}

// Set stimulus parameters.
//
Expand Down
11 changes: 11 additions & 0 deletions tests/cases/cep/slab_domains/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# **Problem Description**

Simulate the propagation of a planar wave in a slab with different domain conductances using the ten-Tusscher-Panfilov cell activation model.

![Slab domains visualization](domains.png)

## References
K. H. W. J. ten Tusscher, D. Noble, P. J. Noble, and A. V. Panfilov. A model for human ventricular tissue. American Journal of Physiology-Heart and Circulatory Physiology,
286(4):H1573–H1589, apr 2004.

3 changes: 3 additions & 0 deletions tests/cases/cep/slab_domains/domains.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/cases/cep/slab_domains/mesh/VOLUME.vtu
Git LFS file not shown
Loading
Loading