Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
arbor-sim
arbor
Commits
327bd21b
Commit
327bd21b
authored
5 years ago
by
Nora Abi Akar
Committed by
Benjamin Cumming
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Modcc: Allow solving kinetic schemes at steady-state from intial block (#893)
Fixes #892
parent
25759e6f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modcc/module.cpp
+12
-3
12 additions, 3 deletions
modcc/module.cpp
with
12 additions
and
3 deletions
modcc/module.cpp
+
12
−
3
View file @
327bd21b
...
...
@@ -277,6 +277,7 @@ bool Module::semantic() {
auto
initial_api
=
make_empty_api_method
(
"nrn_init"
,
"initial"
);
auto
api_init
=
initial_api
.
first
;
auto
proc_init
=
initial_api
.
second
;
auto
&
init_body
=
api_init
->
body
()
->
statements
();
for
(
auto
&
e
:
*
proc_init
->
body
())
{
...
...
@@ -284,7 +285,7 @@ bool Module::semantic() {
if
(
solve_expression
)
{
// Grab SOLVE statements, put them in `body` after translation.
std
::
set
<
std
::
string
>
solved_ids
;
std
::
unique_ptr
<
SolverVisitorBase
>
solver
=
std
::
make_unique
<
SparseSolverVisitor
>
()
;
std
::
unique_ptr
<
SolverVisitorBase
>
solver
;
// The solve expression inside an initial block can only refer to a linear block
auto
solve_proc
=
solve_expression
->
procedure
();
...
...
@@ -292,9 +293,14 @@ bool Module::semantic() {
if
(
solve_proc
->
kind
()
==
procedureKind
::
linear
)
{
solver
=
std
::
make_unique
<
LinearSolverVisitor
>
(
state_vars
);
linear_rewrite
(
solve_proc
->
body
(),
state_vars
)
->
accept
(
solver
.
get
());
}
else
if
(
solve_proc
->
kind
()
==
procedureKind
::
kinetic
&&
solve_expression
->
variant
()
==
solverVariant
::
steadystate
)
{
solver
=
std
::
make_unique
<
SparseSolverVisitor
>
(
solverVariant
::
steadystate
);
kinetic_rewrite
(
solve_proc
->
body
())
->
accept
(
solver
.
get
());
}
else
{
error
(
"A SOLVE expression in an INITIAL block can only be used to solve a LINEAR block, which"
+
solve_expression
->
name
()
+
"is not."
,
solve_expression
->
location
());
error
(
"A SOLVE expression in an INITIAL block can only be used to solve a "
"LINEAR block or a KINETIC block at steadystate and "
+
solve_expression
->
name
()
+
" is neither."
,
solve_expression
->
location
());
return
false
;
}
...
...
@@ -307,6 +313,9 @@ bool Module::semantic() {
}
solved_ids
.
insert
(
id
);
}
solve_block
=
remove_unused_locals
(
solve_block
->
is_block
());
// Copy body into nrn_init.
for
(
auto
&
stmt
:
solve_block
->
is_block
()
->
statements
())
{
init_body
.
emplace_back
(
stmt
->
clone
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment