Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
openCARP
experiments
Commits
62153c7e
Commit
62153c7e
authored
Sep 21, 2021
by
teo.puig
Browse files
First version of the population model example
parent
e706a0e8
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
tutorials/01_EP_single_cell/11_model_population/run.py
0 → 100755
View file @
62153c7e
#!/usr/bin/env python2
"""
.. _tutorial_model_population:
EXAMPLE FOR MODEL POPULATION IN BENCH USING A POLLING FILE
================
"""
from
__future__
import
division
import
os
import
sys
import
ast
import
argparse
import
shutil
import
warnings
warnings
.
filterwarnings
(
"ignore"
,
category
=
RuntimeWarning
)
from
datetime
import
date
from
numpy
import
*
from
numpy.linalg
import
norm
import
pandas
as
pd
from
carputils
import
settings
from
carputils
import
bench
from
carputils
import
testing
from
carputils
import
tools
from
carputils
import
mesh
def
parser
():
parser
=
tools
.
standard_parser
()
# Generate the standard command line parser
parser
.
add_argument
(
'--tolerance'
,
type
=
float
,
default
=
0.5
,
help
=
'Tolerance to reach limit cycle (%)'
)
parser
.
add_argument
(
'--model'
,
type
=
str
,
default
=
"TT2"
,
help
=
'ionic model name '
)
parser
.
add_argument
(
'--SV-init'
,
type
=
str
,
default
=
''
,
help
=
'Initialization file from where to start the simulation to limit cycle'
)
parser
.
add_argument
(
'--bcl'
,
type
=
float
,
default
=
1000.0
,
help
=
'basic cycle length'
)
parser
.
add_argument
(
'--dt'
,
type
=
float
,
default
=
0.01
,
help
=
'simulation time step (ms)'
)
parser
.
add_argument
(
'--parameter'
,
type
=
ast
.
literal_eval
,
default
=
[
'GNa'
,
'Gkr'
,
'Gto'
],
help
=
'Name of parameters that will be modified for the population models'
)
parser
.
add_argument
(
'--use_polling_file'
,
type
=
str
,
default
=
"None"
,
help
=
'ionic model name '
)
return
parser
def
jobID
(
args
):
ID
=
'population_model_{}'
.
format
(
args
.
model
)
return
ID
@
tools
.
carpexample
(
parser
,
jobID
)
def
run
(
args
,
job
):
print
args
.
polling_file
if
args
.
use_polling_file
==
"None"
:
cmd
=
tools
.
carp_cmd
()
job
.
carp
(
cmd
)
return
polled_param
=
loadtxt
(
args
.
use_polling_file
,
dtype
=
'str'
)
num_param
=
shape
(
polled_param
)[
1
]
polled_param
=
polled_param
[:,
arange
(
1
,
num_param
,
2
)]
polled_param
.
astype
(
'float'
)
num_combinations
=
len
(
polled_param
)
for
combination
in
range
(
num_combinations
):
polled_combination
=
polled_param
[
combination
,
:]
for
k
in
range
(
len
(
args
.
parameter
)):
if
k
!=
len
(
args
.
parameter
)
-
1
:
modelpar
=
args
.
parameter
[
k
]
+
'*'
+
str
(
float
(
polled_combination
[
k
])
/
100
)
+
','
else
:
modelpar
=
modelpar
+
args
.
parameter
[
k
]
+
'*'
+
str
(
float
(
polled_combination
[
k
])
/
100
)
cmd
=
[
settings
.
execs
.
BENCH
,
'--imp'
,
args
.
model
,
'--imp-par'
,
modelpar
,
'--bcl'
,
args
.
bcl
,
'--dt-out'
,
1
,
'--stim-curr'
,
16
,
'--stim-dur'
,
5
,
'--numstim'
,
1
,
'--duration'
,
args
.
bcl
,
'--stim-start'
,
0
,
'--fout={}/tVI_{}'
.
format
(
os
.
path
.
join
(
job
.
ID
),
combination
),
'--no-trace'
,
'on'
'--dt'
,
args
.
dt
#'-R', args.SV_init,
]
print
cmd
job
.
bash
(
cmd
)
if
__name__
==
'__main__'
:
run
()
tutorials/01_EP_single_cell/11_model_population/test_large.poll
0 → 100644
View file @
62153c7e
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment