-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCell.h
173 lines (127 loc) · 2.89 KB
/
Cell.h
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#ifndef _____CELL______RYR
#define _____CELL______RYR
#include <list>
#include <vector>
#include <set>
#include <iostream>
#include "models/TT06_RRG.h"
namespace ryr
{
namespace cell
{
template <class C>
class Cell : public C
{
public:
void init_cell(double dt) {
this->init_cell_base(dt);
}
double& dv() {
return this->dv_base();
}
};
class CellBase
{
public:
unsigned& matrix_index() {
return matrix_index_;
}
unsigned& original_index() {
return original_index_;
}
double& v() {
return v_;
}
double& Ca() {
return Ca_;
}
double& dv_base() {
return dv_;
}
bool& share_calcium() {
return share_calcium_;
}
protected:
unsigned param_id_;
double v_, dv_, Ca_;
bool share_calcium_;
private:
unsigned original_index_, matrix_index_;
};
class MainCellBase : public CellBase
{
protected:
double calcalate_dv(double dt) {
return 0;
}
public:
//output
void set_output(const std::vector<std::string>& save) {
model_->set_output(save);
}
void output_header(std::ostream& file) {
model_->output_header(file);
}
void output_data(std::ostream& file) {
model_->output_data(file);
}
unsigned& get_param_id() {
return param_id_;
}
MainCellBase() {
}
void clone_model(IonicModel* model) {
model_ = model->clone();
v_ = model_->get_default_voltage();
Ca_ = model_->get_calcium();
share_calcium_ = model_->share_calcium();
model_->set_id(this->original_index());
}
void add_cell(CellBase* cell, double res) {
adj_cell_container_.push_back(std::make_pair(cell, res));
}
void integrate(double time, double dt) {
v_ += model_->integrate(time, dt, v_) * dt;
}
void get_n_matrix_entry(std::vector<unsigned>& e);
void calc_matrix_entry_operator_spliting(double dt, unsigned offset, std::vector<double>& mat_value);
void calc_rhs_operator_spliting(double dt, double& value);
void integrate() {
}
void write_restart(std::ostream& o) {
o << v_ << " ";
model_->write_restart(o);
}
void read_restart(std::istream& i) {
i >> v_;
model_->read_restart(i);
}
void update_calcium();
void update_calcium_from_model();
void calc_calcium_explicit_method(double resistance_factor, double& dCa, double& dv);
void set_id(unsigned cell_id) {
model_->set_id(cell_id);
}
void set_resistance() {
double cap = model_->get_capacitance();
for(std::list<std::pair<CellBase*, double> >::iterator it = adj_cell_container_.begin();
it != adj_cell_container_.end(); it++) {
it->second *= cap;
}
}
private:
std::list<std::pair<CellBase*, double> > adj_cell_container_;
// std::set<unsigned> matrix_index_;
//std::vector<unsigned> cell_entry_index_;
IonicModel *model_;
};
class HaloCellBase : public CellBase
{
protected:
private:
};
typedef Cell<MainCellBase> MainCell;
typedef Cell<HaloCellBase> HaloCell;
}
}
#endif