openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
stretch.cc
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // openCARP is an open cardiac electrophysiology simulator.
3 //
4 // Copyright (C) 2020 openCARP project
5 //
6 // This program is licensed under the openCARP Academic Public License (APL)
7 // v1.0: You can use and redistribute it and/or modify it in non-commercial
8 // academic environments under the terms of APL as published by the openCARP
9 // project v1.0, or (at your option) any later version. Commercial use requires
10 // a commercial license (info@opencarp.org).
11 //
12 // This program is distributed without any warranty; see the openCARP APL for
13 // more details.
14 //
15 // You should have received a copy of the openCARP APL along with this program
16 // and can find it online: http://www.opencarp.org/license
17 // ----------------------------------------------------------------------------
18 
23 #include <stdlib.h>
24 #include "stretch.h"
25 
26 namespace limpet {
27 
29 using ::opencarp::timer_manager;
30 
31 void apply_stretch_pulse(MULTI_IF *miif, pulseStretch*s, timer_manager *tm);
32 
37 void
38 initializePulseStretch(float strain, float onset, float duration, float rise,
39  float fall, stretch *s)
40 {
42  s->pulse.sr = strain + 1.;
43  s->pulse.onset = onset;
44  s->pulse.duration = duration;
45  s->pulse.rise = rise;
46  s->pulse.fall = fall;
47 }
48 
49 
54 void
55 apply_stretch(MULTI_IF *miif, stretch *s, timer_manager *tm)
56 {
57  if(s->prtcl==STRAIN_PULSE) {
58  apply_stretch_pulse(miif, &s->pulse, tm);
59  return;
60  }
61  if(s->prtcl==ISOMETRIC) {
62  log_msg(NULL, 2, 0, "Isometric stretch protocol not implemented yet.");
63  return;
64  }
65 }
66 
67 
72 void
73 apply_stretch_pulse(MULTI_IF *miif, pulseStretch*s, timer_manager *tm)
74 {
75  double t = tm->time;
76  double dt = tm->time_step;
77 
78  if(s->sr>1.0) {
79  if((t>s->onset) && ((t-s->onset)<s->rise)) {
80  // rising phase of stretch pulse
81  double strain_rate = (s->sr-1.)/s->rise;
82  double inc_strain = strain_rate*dt;
83 
84  miif->gdata[delLambda]->set(strain_rate);
85  *(miif->gdata[Lambda]) += inc_strain;
86  }
87  else if ((t>=(s->onset+s->rise)) && t<(s->onset+s->duration-s->fall)) {
88  // plateau phase of stretch pulse
89  miif->gdata[delLambda]->set(0.0);
90  miif->gdata[Lambda]->set(s->sr);
91  }
92  else if ((t>=(s->onset+s->duration-s->fall)) && (t<(s->onset+s->duration))) {
93  // falling phase of stretch pulse
94  double strain_rate = (s->sr-1.)/s->fall;
95  double dec_strain = -strain_rate*dt;
96  miif->gdata[delLambda]->set(-strain_rate);
97  miif->gdata[Lambda]->set(dec_strain);
98  }
99  else {
100  // pulse is off, stretch and stretch ratio must be 0 now
101  miif->gdata[delLambda]->set(0.0);
102  miif->gdata[Lambda]->set(1.);
103  }
104  }
105 }
106 
107 } // namespace limpet
pulseStretch pulse
Definition: stretch.h:52
void apply_stretch_pulse(MULTI_IF *miif, pulseStretch *s, timer_manager *tm)
Definition: stretch.cc:73
s_prtcl prtcl
Definition: stretch.h:51
void apply_stretch(MULTI_IF *miif, stretch *s, timer_manager *tm)
Definition: stretch.cc:55
void initializePulseStretch(float strain, float onset, float duration, float rise, float fall, stretch *s)
Definition: stretch.cc:38
virtual void set(const vector< T > &idx, const vector< S > &vals, const bool additive=false)=0
opencarp::sf_vec * gdata[NUM_IMP_DATA_TYPES]
data used by all IMPs
Definition: MULTI_ION_IF.h:216
void log_msg(FILE_SPEC out, int level, unsigned char flag, const char *fmt,...)
Definition: basics.cc:72