Intermediate state vars
Created by: dionperd
In this pull request from branch intermediate_state_vars, Lionel and I introduce state variables that:
- are not integrated,
- but correspond to intermediate results (e.g., the current I and rate R of the ReducedWongWang models),
- which can be computed by model methods either before or after integration of a time step.
To this end, we had to modify
- the Base model to include
- a list of variables that have to be integrated, which defaults to all the state variables,
- and a related state variables mask, which is True (False) for the state variables that ARE (NOT) integrated, respectively,
- as well as possible methods to update such non-integrated state variables either before integration (in which case all the arguments of the Integrator.scheme are also considered here (i.e., coupling, local coupling, stimulus), or after the integration, in which case the only argument is the state itself,
- the integrator to add methods that compute the next time step with or without updating such state variables,
- the simulator to configure the integrator by choosing the correct method for integration, with or without updating such state variables, and to use the resulting method inside the call method.
I have added the following tests:
- a specific test model with 3 state variables and 2 non-integrated state variables, which are given before integration following: state[3] += state[0] state[4] += state[1] + state[2] and after integration reversing the above: state[3] -= state[0] state[4] -= state[1] + state[2], so that together with a dfun: 0.0*state, the state should be left unaltered if the test is succesful,
- an integration test testing all integrators in computing 1 step following the above model methods/equations,
- a simulator test configuring the simulator, and the model, for the above scenario, and testing that the configuration is successful, e.g. the correct integrator method is selected and the state variables mask is formed correctly.
Given that this addition to TVB is considered necessary for CoSimulation, we would appreciate a quick review!