Last change
on this file since 31482 was
31482,
checked in by Ivan Raikov, 6 years ago
|
nemo: refactoring nest backend into templates
|
File size:
874 bytes
|
Line | |
---|
1 | |
---|
2 | extern "C" int {{modelName}}_event (double t, N_Vector y, N_Vector yp, double *g, void* pnode) |
---|
3 | { |
---|
4 | double v, vt; v = -1.0; vt = 0.0; |
---|
5 | |
---|
6 | // S is shorthand for the type that describes the model state |
---|
7 | typedef {{modelName}}::State_ S; |
---|
8 | |
---|
9 | // cast the node ptr to an object of the proper type |
---|
10 | assert(pnode); |
---|
11 | const {{modelName}} & node = *(reinterpret_cast<{{modelName}}*>(pnode)); |
---|
12 | |
---|
13 | // params is a reference to the model parameters |
---|
14 | const struct {{modelName}}::Parameters_ *params; |
---|
15 | params = &(node.P_); |
---|
16 | |
---|
17 | // state is a reference to the model state |
---|
18 | const struct {{modelName}}::State_ *state; |
---|
19 | state = &(node.S_); |
---|
20 | |
---|
21 | {% if (haskey(stateIndexMap,"v") and haskey(defaults,"V_t") %} |
---|
22 | v = Ith (y, {{attr(stateIndexMap,"v")}}); |
---|
23 | vt = params->{{attr(defaults,"V_t")}}; |
---|
24 | g[0] = v - vt; |
---|
25 | {% else %} |
---|
26 | g[0] = -1.0; |
---|
27 | {% endif %} |
---|
28 | |
---|
29 | return 0; |
---|
30 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.