-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of subworlds in CoreNEURON (#2185)
Co-authored-by: Alexandru Săvulescu <alexandru.savulescu@epfl.ch> Co-authored-by: nrnhines <michael.hines@yale.edu>
- Loading branch information
1 parent
3adaa7d
commit d2a76ab
Showing
12 changed files
with
230 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 22.1.0 | ||
rev: 22.12.0 | ||
hooks: | ||
- id: black | ||
language_version: python3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import sys | ||
from neuron import h | ||
|
||
h("""objref cvode""") | ||
h.cvode = h.CVode() | ||
|
||
use_coreneuron = True | ||
subsize = 3 | ||
|
||
if use_coreneuron: | ||
from neuron import coreneuron | ||
|
||
coreneuron.enable = True | ||
coreneuron.verbose = 0 | ||
|
||
|
||
def test_subworlds(): | ||
h.nrnmpi_init() | ||
pc = h.ParallelContext() | ||
pc.subworlds(subsize) | ||
rank = int(pc.id()) | ||
nhost = int(pc.nhost()) | ||
|
||
ibbs = pc.id_world() // subsize | ||
nbbs = pc.nhost_world() // subsize | ||
x = 0 if pc.nhost_world() % subsize == 0 else 1 | ||
assert pc.nhost_bbs() == ((nbbs + x) if pc.id() == 0 else -1) | ||
assert pc.id_bbs() == (ibbs if pc.id() == 0 else -1) | ||
|
||
if rank == 0: | ||
soma = h.Section(name="soma") | ||
soma.L = 20 | ||
soma.diam = 20 | ||
soma.insert("hh") | ||
iclamp = h.IClamp(soma(0.5)) | ||
iclamp.delay = 2 | ||
iclamp.dur = 0.1 | ||
|
||
if pc.id_bbs() == 0: | ||
iclamp.amp = 0.0 | ||
elif pc.id_bbs() == 1: | ||
iclamp.amp = 0.9 | ||
else: | ||
raise RuntimeError(f"Invalid subworld index {pc.id_bbs()}") | ||
|
||
rec_v = h.Vector() | ||
rec_t = h.Vector() | ||
rec_v.record(soma(0.5)._ref_v) # Membrane potential vector | ||
rec_t.record(h._ref_t) | ||
syn = h.ExpSyn(soma(0.5)) | ||
spike_detector = h.NetCon(soma(0.5)._ref_v, None, sec=soma) | ||
netstim = h.NetStim() | ||
netstim.number = 1 | ||
netstim.start = 0 | ||
nc = h.NetCon(netstim, syn) | ||
gid = 1 | ||
pc.set_gid2node(gid, pc.id()) | ||
pc.cell(gid, spike_detector) | ||
|
||
h.cvode.cache_efficient(1) | ||
h.finitialize(-65) | ||
pc.set_maxstep(10) | ||
pc.psolve(250.0) | ||
if rank == 0: | ||
if pc.id_bbs() == 0: | ||
assert rec_v.max() < 0.0 | ||
elif pc.id_bbs() == 1: | ||
assert rec_v.max() > 0.0 | ||
else: | ||
raise RuntimeError(f"Invalid subworld index {pc.id_bbs()}") | ||
|
||
print(f"subworld {pc.id_bbs()}: {rec_v.max()}") | ||
|
||
pc.done() | ||
h.quit() | ||
|
||
|
||
if __name__ == "__main__": | ||
test_subworlds() |
Oops, something went wrong.