mcs#
Classes
|
Difference equations simulation. |
|
ODEs simulation. |
|
Cellular automata simulation. |
|
PDEs simulation. |
|
Dynamical networks simulation. |
- class mcs.DE(max_step: int, dim: int)[source]#
Difference equations simulation.
- max_step#
The max step.
- dim#
The number of variables.
- step#
The current step.
- initialize(*, x0: List[float] | None = None)[source]#
Sets up the initial values for the state variables.
- Parameters:
x0 – A list of initial states.
- update(*, f: Callable | None = None)[source]#
Updates the states in the next step.
- Parameters:
f – A function, \(x_t = f(x_{t-1})\).
- class mcs.ODE(max_step: int, dim: int, dt: float)[source]#
ODEs simulation.
- max_step#
The max step.
- dim#
The number of variables.
- dt#
The time step.
- step#
The current step.
- initialize(*, x0: List[float] | None = None)[source]#
Sets up the initial values for the state variables.
- Parameters:
x0 – A list of initial states.
- update(*, f: Callable | None = None)[source]#
Updates the states in the next step.
- Parameters:
f – A function, \(dx/dt = f(x)\).
- class mcs.CA(max_step: int, size_x: int, size_y: int = 1, seed: int = 42)[source]#
Cellular automata simulation.
Override this class to customize configuration and state-transition function.
- max_step#
The max step.
- size_x#
Number of cells in x dimension.
- size_y#
Number of cells in y dimension.
- seed#
NumPy random seed.
- step#
The current step.
- update(*, F: Callable | None = None)[source]#
Updates the states in the next step.
- Parameters:
F – A state transition function which returns an
ndarray
.
- visualize(*, step: int = -1)[source]#
Visualizes the states of the system using an image of shape (step, size_x) or (size_y, size_x).
- Parameters:
step – The step to plot.
- Returns:
A
matplotlib.figure.Figure
object.
- class mcs.PDE(max_step: int, dim: int, dt: float, dh: float, size: int)[source]#
PDEs simulation.
Override this class to customize.
- max_step#
The max step.
- dim#
The number of variables.
- dt#
The time step.
- dh#
Spatial resolution.
- size#
Size of grid.
- step#
The current step.
- update(*, F: Callable | None = None)[source]#
Updates the states in the next step.
- Parameters:
F – A state transition function corresponding to \(\partial f/\partial t = F(f,...,x,y,t)\).
- static turing(a, b, c, d, h, k, Du, Dv, dh)[source]#
Reaction-diffusion equations:
\[ \begin{align}\begin{aligned}\partial u/\partial t = a(u-h) + b(v-k) + D_u \Delta u\\\partial v/\partial t = c(u-h) + d(v-k) + D_v \Delta v.\end{aligned}\end{align} \]
- class mcs.Net(max_step: int)[source]#
Dynamical networks simulation.
Override this class to customize.
- max_step#
The max step.
- graphs#
A list of
networkx.Graph
objects.
- step#
The current step.
- coupled_oscillators(a, b, dt)[source]#
Linearly coupled dynamical nodes:
\[d\theta_i/dt = b\theta_i + a\sum_{j\in N_i}(\theta_j-\theta_i).\]
- visualize(*, step: int = -1)[source]#
Visualizes the states of the network.
- Parameters:
step – The step to plot.
- Returns:
A
matplotlib.figure.Figure
object.