Giter Club home page Giter Club logo

nestml's Introduction

astropy Build Status

PyNestML - The NEST Modelling Language @Python

NestML is a domain specific language that supports the specification of neuron models in a precise and concise syntax, based on the syntax of Python. Model equations can either be given as a simple string of mathematical notation or as an algorithm written in the built-in procedural language. The equations are analyzed by NESTML to compute an exact solution if possible or use an appropriate numeric solver otherwise.

Directory structure

models - Example neuron models in NestML format.

pynestml - The source code of PyNestML.

tests - A collection of tests for testing of the toolchains behavior.

doc - The documentation of the modeling language NestML as well as processing toolchain PyNestML.

Installing and running NESTML

In order to execute the language tool-chain, Python in version 2 or 3 is required. A setup file is provided and can be installed by

python2 setup.py install --user

For Python in version 3, respectively:

python3 setup.py install --user

Correct installation can be tested by

python2 setup.py test
\# respectively python3 setup.py test 

In order to ensure correct installation and resolving of dependencies, Python's package manager pip, the distribution tool setuptools as well as the python-dev package are required and should be installed in advance. The setup file additionally installs the following components:

In the case that no 'enum' package is found, additionally, enum34 has to be updated by

pip install --upgrade pip enum34

All requirements are stored in the requirements.txt and can be installed in one step by pip

pip install -r requirements.txt

After the installation, the toolchain can be executed by the following command.

python PyNestML.py -ARGUMENTS

where arguments are:

Command Description
-h or --help Print help message.
-path Path to the source file or directory containing the model.
-target (Optional) Path to target directory where models will be generated to. Default is /target .
-dry (Optional) Executes the analysis of the model without generating target code. Default is OFF.
-logging_level (Optional) Sets the logging level, i.e., which level of messages should be printed. Default is ERROR, available are [INFO, WARNING, ERROR, NO]
-module_name (Optional) Sets the name of the module which shall be generated. Default is the name of the directory containing the models.
-store_log (Optional) Stores a log.txt containing all messages in JSON notation. Default is OFF.
-dev (Optional) Executes the toolchain in the development mode where errors in models are ignored. Default is OFF.

Generated artifacts are copied to the selected target directory (default is /target). In order to install the models into NEST, the following commands have to be executed:

cmake -Dwith-nest=<nest_install_dir>/bin/nest-config .
make all
make install

where nest_install_dir points to the installation directory of NEST (e.g. work/nest-install). Subsequently, PyNEST can be used to set up and execute a simulation.

PyNestML is also available as a component and can therefore be used from within other Python tools and scripts. After the PyNestML has been installed, the following modules have to be imported:

from pynestml.frontend.pynestml_frontend import to_nest,install_nest

Subsequently, it is possible to call PyNestML from other Python tools and scripts via:

to_nest(path, target, dry, logging_level, module_name, store_log, dev)    

This operation expects the same set of arguments as in the case of the shell/CMD call, with the following default values being used, where only the path is mandatory:

Argument Type Default
path string -no default-
target string None
dry boolean False
logging_level string 'ERROR'
module_name string None
store_log boolean False
dev boolean False

where no values provided indicates the same behavior as listed for default values in arguments table. If no errors occur, the output will be generated to the specified target directory. In order to avoid an execution of all required module-installation routines by hand, PyNestML features a function for an installation of NEST models directly into NEST:

install_nest(models_path,nest_path)

where the models_path has to point as previously selected for the target argument, while nest_path has to point to the directory where NEST is installed (e.g., "/home/nest/work/nest-install"). The second argument is hereby equivalent to the nest_install_dir argument from the manual installation of models (see above). The simulation can then be started. A typical script, therefore, can look like the following:

from pynestml.frontend.pynestml_frontend import to_nest,install_nest

to_nest(path="/home/nest/work/pynestml/models", target="/home/nest/work/pynestml/target",dev=True)

install_nest("/home/nest/work/pynestml/target", "/home/nest/work/nest-install")

nest.install(<the module name>)    
...
nest.Simulate(400.0)

For an in-depth introduction to the underlying modeling language NestML, we refer to the following introduction. For those interested in the implementation of PyNestML or the general structure of a DSL-processing toolchain, a documentation of all implemented components is provided.

nestml's People

Contributors

ptraeder avatar jougs avatar kperun avatar dimitriplotnikov avatar tammoippen avatar silmathoron avatar gtrensch avatar vogdb avatar jakobj avatar ingablundell avatar

Watchers

 avatar

nestml's Issues

NullPointerException with jLEMS and models without EventOut

There seems to be a problem with models which declare an out-EventPort without using the EventOut directive. In this case the interpreter throws a NullPointerException. In order to avoid such problems, do not declare ports/buffers which are not explicitly used in the model (by means of event out).

This seems to be a problem with jLEMS rather then the transformation process itself. A routine which reports not used ports is an option to avoid this problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.