forked from leongraham/monodomain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPointStim.cc
44 lines (38 loc) · 928 Bytes
/
PointStim.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* Point Stimulus Electrode */
#include <assert.h>
#include "PointStim.h"
#include "Types.h"
#include "Constants.h"
PointStim::PointStim()
{
}
void PointStim::setStim(ARRAY2D& stim, double radius, double stim_strength)
{
isStimOn=true;
for (size_t r=0; r<stim.size(); ++r)
{
for (size_t c=0; c<stim[r].size(); ++c)
{
if (((c*dx-0.5)*(c*dx-0.5)+(r*dy-0.5)*(r*dy-0.5)) <= radius)
{
stim[r][c] = stim_strength;
}
}
}
}
void PointStim::turnOffStim(ARRAY2D& stim, double t, double stim_duration)
{
//ensure stimulation duration is valid
assert(stim_duration>=0 && "Stimulus duration not positive");
if ((t>=stim_duration)&&(isStimOn==true))
{
for (size_t r=0; r<stim.size(); ++r)
{
for (size_t c=0; c<stim[r].size(); ++c)
{
stim[r][c]=0;
}
}
isStimOn=false;
}
}