-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BBPBGLIB-854] Implement a CLI option to run coreneuron in direct mod…
…e without writing model data to disk (#100) ## Context This PR implements a new CLI option "--coreneuron-direct-mode" that enables to run the coreneuron simulation using direct memory transfer from neuron, without writing intermediate model data to disk. ## Scope - When "--coreneuron-direct-mode", we set the Coreneuron parameter`coreneuron.file_mode=False`. - And Coreneuron writes the element reports but not the spike report. So we still create `sim.conf`, `report.conf` and an empty folder `coreneuron_input`. The spike report is created explicitly in neurodamus via `sonata_spikes()` just like the Neuron runs. - Enable fast membrane current calculation `Nd.cvode.use_fast_imem(1)` for `i_membrane` and `lfp` reports. ## Testing New test file `test_coreneuron_directmode.py`. The blueconfig pipeline tests with "--coreneuron-direct-mode" enabled have been done manually with the blueconfig branch (https://bbpgitlab.epfl.ch/hpc/sim/blueconfigs/-/merge_requests/114). ## Review * [x] PR description is complete * [x] Coding style (imports, function length, New functions, classes or files) are good * [x] Unit/Scientific test added * [ ] Updated Readme, in-code, developer documentation
- Loading branch information
Showing
5 changed files
with
86 additions
and
11 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
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,37 @@ | ||
import os | ||
import numpy.testing as npt | ||
import numpy as np | ||
|
||
|
||
def test_coreneuron_no_write_model(USECASE3): | ||
from libsonata import SpikeReader, ElementReportReader | ||
from neurodamus import Neurodamus | ||
from neurodamus.core.configuration import SimConfig | ||
nd = Neurodamus( | ||
str(USECASE3 / "simulation_sonata_coreneuron.json"), | ||
keep_build=True, | ||
coreneuron_direct_mode=True | ||
) | ||
nd.run() | ||
coreneuron_data = SimConfig.coreneuron_datadir | ||
assert not next(os.scandir(coreneuron_data), None), f"{coreneuron_data} should be empty." | ||
|
||
spikes_path = os.path.join(SimConfig.output_root, nd._run_conf.get("SpikesFile")) | ||
spikes_reader = SpikeReader(spikes_path) | ||
pop_A = spikes_reader["NodeA"] | ||
pop_B = spikes_reader["NodeB"] | ||
spike_dict = pop_A.get_dict() | ||
npt.assert_allclose(spike_dict["timestamps"][:10], np.array([0.2, 0.3, 0.3, 2.5, 3.4, | ||
4.2, 5.5, 7., 7.4, 8.6])) | ||
npt.assert_allclose(spike_dict["node_ids"][:10], np.array([0, 1, 2, 0, 1, 2, 0, 0, 1, 2])) | ||
assert not pop_B.get() | ||
|
||
soma_reader = ElementReportReader(SimConfig.reports.get("soma_report").get('FileName')) | ||
soma_A = soma_reader["NodeA"] | ||
soma_B = soma_reader["NodeB"] | ||
data_A = soma_A.get(tstop=0.5) | ||
data_B = soma_B.get(tstop=0.5) | ||
npt.assert_allclose(data_A.data, np.array([[-75.], [-39.78627], [-14.380434], [15.3370695], | ||
[1.7240616], [-13.333434]])) | ||
npt.assert_allclose(data_B.data, np.array([[-75.], [-75.00682], [-75.010414], [-75.0118], | ||
[-75.01173], [-75.010635]])) |