openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
stretch.cc
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) NumeriCor GmbH
2 // SPDX-License-Identifier: LicenseRef-APL-1.1
3 
8 #include <stdlib.h>
9 #include "stretch.h"
10 
11 namespace limpet {
12 
14 using ::opencarp::timer_manager;
15 
16 void apply_stretch_pulse(MULTI_IF *miif, pulseStretch*s, timer_manager *tm);
17 
22 void
23 initializePulseStretch(float strain, float onset, float duration, float rise,
24  float fall, stretch *s)
25 {
27  s->pulse.sr = strain + 1.;
28  s->pulse.onset = onset;
29  s->pulse.duration = duration;
30  s->pulse.rise = rise;
31  s->pulse.fall = fall;
32 }
33 
34 
39 void
40 apply_stretch(MULTI_IF *miif, stretch *s, timer_manager *tm)
41 {
42  if(s->prtcl==STRAIN_PULSE) {
43  apply_stretch_pulse(miif, &s->pulse, tm);
44  return;
45  }
46  if(s->prtcl==ISOMETRIC) {
47  log_msg(NULL, 2, 0, "Isometric stretch protocol not implemented yet.");
48  return;
49  }
50 }
51 
52 
57 void
58 apply_stretch_pulse(MULTI_IF *miif, pulseStretch*s, timer_manager *tm)
59 {
60  double t = tm->time;
61  double dt = tm->time_step;
62 
63  if(s->sr>1.0) {
64  if((t>s->onset) && ((t-s->onset)<s->rise)) {
65  // rising phase of stretch pulse
66  double strain_rate = (s->sr-1.)/s->rise;
67  double inc_strain = strain_rate*dt;
68 
69  miif->gdata[delLambda]->set(strain_rate);
70  *(miif->gdata[Lambda]) += inc_strain;
71  }
72  else if ((t>=(s->onset+s->rise)) && t<(s->onset+s->duration-s->fall)) {
73  // plateau phase of stretch pulse
74  miif->gdata[delLambda]->set(0.0);
75  miif->gdata[Lambda]->set(s->sr);
76  }
77  else if ((t>=(s->onset+s->duration-s->fall)) && (t<(s->onset+s->duration))) {
78  // falling phase of stretch pulse
79  double strain_rate = (s->sr-1.)/s->fall;
80  double dec_strain = -strain_rate*dt;
81  miif->gdata[delLambda]->set(-strain_rate);
82  miif->gdata[Lambda]->set(dec_strain);
83  }
84  else {
85  // pulse is off, stretch and stretch ratio must be 0 now
86  miif->gdata[delLambda]->set(0.0);
87  miif->gdata[Lambda]->set(1.);
88  }
89  }
90 }
91 
92 } // namespace limpet
virtual void set(const vector< T > &idx, const vector< S > &vals, const bool additive=false, const bool local=false)=0
opencarp::sf_vec * gdata[NUM_IMP_DATA_TYPES]
data used by all IMPs
Definition: MULTI_ION_IF.h:212
#define log_msg(F, L, O,...)
Definition: filament.h:8
void apply_stretch(MULTI_IF *miif, stretch *s, timer_manager *tm)
Definition: stretch.cc:40
void initializePulseStretch(float strain, float onset, float duration, float rise, float fall, stretch *s)
Definition: stretch.cc:23
@ STRAIN_PULSE
Definition: stretch.h:12
@ ISOMETRIC
Definition: stretch.h:12
void apply_stretch_pulse(MULTI_IF *miif, pulseStretch *s, timer_manager *tm)
Definition: stretch.cc:58
s_prtcl prtcl
Definition: stretch.h:36
pulseStretch pulse
Definition: stretch.h:37