Kuramoto model
Implements the Kuramoto model in three different versions. The instatiated model already includes the method for its integration called by the method simulate().
Clasical Kuramoto
Delayed Kuramoto
Partially Forced Delayed Kuramoto
An online tutorial could be found in Tutorial Kuramoto model.
- class model.KuramotoClassFor.Kuramoto(struct_connectivity=None, delays_matrix=None, K=5, dt=0.0001, simulation_period=100, StimTstart=0, StimTend=0, StimFreq=0, StimWeigth=0, n_nodes=90, natfreqs=None, nat_freq_mean=0, nat_freq_std=2, GenerateRandom=True, SEED=2, mean_delay=0.1)
Bases:
object
Kuramoto model class
- Parameters
struct_connectivity (float 2D array, optional) – Structural connectivty matrix, a weighted adjacency matrix. The default is the AAL90 matrix
delays_matrix (float 2D array, optional) – Matrix of the delays between connections. The default is the AAL90 distances matrix in meters.
K (float, optional) – Global coupling parameter K (it will be normalized by the number of nodes). The default is 5.
dt (float, optional) – Integration time step. The default is 1e-4 seconds.
simulation_period (float, optional) – Total time of the simulation. The default is 100 seconds.
StimTstart (float, optional.) – Starting time of the stimulaiton (PFDK only! The default is 0 seconds.)
StimTend (float, optional.) – Final time of the stimulation (PFDK only! The default is 0 seconds.)
StimFreq (float, optional.) – Stimulation frequency, sigma (PFDK only! The default is 0 seconds.)
StimWeigth (float, optional.) – Stimulation force amplitude, F PFDK only! The default is 0 seconds.)
n_nodes (int, optional.) – Number of oscillatory nodes. The default is 90 nodes.
natfreqs (float 1D array, optional.) – Natural frequencies, omega_n, of the system oscillators. The default is None, in order to use the nat_freq_mean and nat_freq_std to build the array.
nat_freq_mean (float, optional.) – Average natural frequency. The default is 0 Hz (only used if natfreqs is None).
nat_freq_std (float, optional.) – The standard deviation for a Gaussian distribution. The dafult is 2 Hz (only used if natfreqs is None).
GenerateRandom (boolean, optional.) – Set if the natural frequencies comes from the same random seed for each simulation.
SEED (int, optional.) – The simulation seed. The default is 2.
mean_delay (float, optional.) – The mean delay to scale the distance matrix. It also could be seen as the inverse of the conduction speed. The default is 0.1 seconds/meter.
- Returns
model – Kuramoto model that implements itself integration method
- Return type
Methods
Jitcdde solver (integration) function.
Scale the delays matrix by the mean_delay factor.
calculateOrderParameter
(dynamics)Calculate Kuramoto order parameter
gui_interact
(K)Jupyter notebook function for "online" change of the K parameter (Note that this method can be used to change any model parameter with the appropiate modifications)
Set the initial values of the variables
initializeForcingNodes
(forcingNodes)Set the binary vector of forcing/no-forcing nodes
initializeNatFreq
(natfreqs)Set the vector of the natural frequencies of the oscillators with:
Initialize the default matrix D: the delays matrix of AAL90.
Delayed Kuramoto model (from Jitcdde documentation)
Forced and delayed Kuramoto model
kuramotosZero
(y, t)Easiest way to define in python the classical Kuramoto model It works (and solves faster) with scipy ODE solvers
loadParameters
(parameters)Load the parameters of the model
Intialize the default structural connectivity matrix C from AAL90 Only if the matrix was not specified in the input parameters
param
(y, arg)Auxiliar function in order to present the stimulation from StimTstart to StimTend Add the maximum of the delays matrix, because for the stored data t_0=max(delays_matrix).
phase_coherence
(angles_vec)Calculate the Kuramoto Order parameter for each time step
Set the global coupling parameter K
setMeanTimeDelay
(mean_delay)Set the mean_delay parameter
simulate
([Forced])Main function.
Test the Delayed Kuramoto
Test the Partially forced and delayed model
setNoiseSD
Methods:
Jitcdde solver (integration) function.
Scale the delays matrix by the mean_delay factor.
calculateOrderParameter
(dynamics)Calculate Kuramoto order parameter
gui_interact
(K)Jupyter notebook function for "online" change of the K parameter (Note that this method can be used to change any model parameter with the appropiate modifications)
Set the initial values of the variables
initializeForcingNodes
(forcingNodes)Set the binary vector of forcing/no-forcing nodes
initializeNatFreq
(natfreqs)Set the vector of the natural frequencies of the oscillators with:
Initialize the default matrix D: the delays matrix of AAL90.
Delayed Kuramoto model (from Jitcdde documentation)
Forced and delayed Kuramoto model
kuramotosZero
(y, t)Easiest way to define in python the classical Kuramoto model It works (and solves faster) with scipy ODE solvers
loadParameters
(parameters)Load the parameters of the model
Intialize the default structural connectivity matrix C from AAL90 Only if the matrix was not specified in the input parameters
param
(y, arg)Auxiliar function in order to present the stimulation from StimTstart to StimTend Add the maximum of the delays matrix, because for the stored data t_0=max(delays_matrix).
phase_coherence
(angles_vec)Calculate the Kuramoto Order parameter for each time step
Set the global coupling parameter K
setMeanTimeDelay
(mean_delay)Set the mean_delay parameter
simulate
([Forced])Main function.
Test the Delayed Kuramoto
Test the Partially forced and delayed model
- IntegrateDD()
Jitcdde solver (integration) function.
- Returns
output – Oscillator phases at the sampling times. T x N array.
- Return type
float 2D array
- applyMean_Delay()
Scale the delays matrix by the mean_delay factor. If mean_delay ==0, the delay matrix becomes a zeros matrix in other case, the delays matrix is divided by the its mean valuem and then multiplied by the scaling factor.
- Return type
None.
- calculateOrderParameter(dynamics)
Calculate Kuramoto order parameter
R=abs((1/N)* sum_{n} ( e^{(i*theta_{n})}))
- Parameters
dynamics (float 2D array) – T x N matrix with the oscillators phases.
- Returns
R – Kuramoto order parameter.
- Return type
float 1D array
- gui_interact(K)
Jupyter notebook function for “online” change of the K parameter (Note that this method can be used to change any model parameter with the appropiate modifications)
- Parameters
K (float) – Global coupling parameter (it will be normalized by the number of nodes).
- Return type
None.
- initial_phases()
Set the initial values of the variables
- Returns
Initial_values – Array with the initial values of the ocillators’ phases.
- Return type
float 1D array
- initializeForcingNodes(forcingNodes)
Set the binary vector of forcing/no-forcing nodes
- Parameters
forcingNodes (list) – List of the indexes of the forcing nodes.
- Return type
None.
- initializeNatFreq(natfreqs)
- Set the vector of the natural frequencies of the oscillators with:
Single value por all nodes
- Parameters
natfreqs (float (single | 1D array)) – Natural frequencies of the oscillators, could be a single value if it is the same for all the nodes.
- Returns
natfreqs – N x 1 array with the natural frequencies of the oscillators.
- Return type
float 1D array
- initializeTimeDelays()
Initialize the default matrix D: the delays matrix of AAL90. Only if the matrix was not specified in the input parameters
- Returns
D – Delays matrix.
- Return type
float 2D array
- kuramotos()
Delayed Kuramoto model (from Jitcdde documentation)
- Yields
Jitcdde Model – Delayed Kuramoto. Structural connectivity and delays matrices are required.
- kuramotosForced()
Forced and delayed Kuramoto model
- Yields
Jitcdde Model – Forced and Delayed Kuramoto model. The stimulation parameters are required.
- kuramotosZero(y, t)
Easiest way to define in python the classical Kuramoto model It works (and solves faster) with scipy ODE solvers
- Parameters
y (float 1D array) – Current (previous) value of the oscillators phases.
t (float) – Current time (actually not used, but usefull to plot or further analysis).
- Returns
dphi_dt – derivate value at the current time step.
- Return type
float 1D array
- loadParameters(parameters)
Load the parameters of the model
- Parameters
parameters (dict) – Dictionary with the parameters.
- Return type
None.
- load_struct_connectivity()
Intialize the default structural connectivity matrix C from AAL90 Only if the matrix was not specified in the input parameters
- Returns
C – Structural connectivity matrix.
- Return type
float 2D array
- param(y, arg)
Auxiliar function in order to present the stimulation from StimTstart to StimTend Add the maximum of the delays matrix, because for the stored data t_0=max(delays_matrix).
- Parameters
y (Not needed, internal function of Jitcdde) –
arg (Not needed, internal function of Jitcdde) –
- Returns
True if the simulation time is inside the stimulation window.
- Return type
int(boolean)
- static phase_coherence(angles_vec)
Calculate the Kuramoto Order parameter for each time step
- Parameters
angles_vec (float 1D array) – Phases of the oscillators at time t.
- Returns
R(t) – A time point of the Kuramoto order parameter: abs(exp{(theta_n(t))})
- Return type
float
- setGlobalCoupling(K)
Set the global coupling parameter K
- Parameters
K (float) – Scaling factor for the structural connectivity matrix C. The value using this function is scaled by the number of nodes then K =K/N.
- Return type
None.
- setMeanTimeDelay(mean_delay)
Set the mean_delay parameter
- Parameters
mean_delay (float) – Mean delay value that scales the delays matrix D.
- Return type
None.
- simulate(Forced=False)
Main function. Simulate the Kuramoto model. To avoid the additional overload from using the Partially Forced Kuramoto you shoul pass False in the Forced argument. On the other hand, if you need to apply stimulation, use Forced=True
- Parameters
Forced (boolean, optional) – Set if the simulation is going to use or not the Partially Forced Kuramoto. The default is False.
- Returns
R (float 1D array) – Kuramoto order parameter. Array with dimensions T x 1.
dynamics (float 2D array) – Kuramoto oscillators phases. Array with dimensions T x N
- testIntegrate()
Test the Delayed Kuramoto
- Return type
None.
- testIntegrateForced()
Test the Partially forced and delayed model
- Return type
None.