mercurial.simulation.engine module

Main simulation engine combining all modules.

class mercurial.simulation.engine.SimulationEngine(dim: int = 50)[source]

Bases: object

Orchestrates multi‑branch, multi‑pattern simulations.

Methods

add_branch([label, level])

Add a new reality branch with specified LADDER level.

add_neural_branch([label, level])

Add a branch with Wilson‑Cowan neural dynamics.

apply_empirical_parameters()

Apply literature‑sourced parameters to all modules.

compute_entanglement(field_results, mode1, mode2)

Compute Pearson correlation coefficient between two spatial modes of a Klein‑Gordon field.

compute_manifestations(branch_id, time)

Return manifestation probabilities for a branch at given time.

run(t_span[, dt, lambda_reg])

Run simulation with pattern evolution equation.

run_auditory_transduction(t_span[, dt, ...])

Simulate auditory hair cell transduction.

run_dirac(t_span[, nx, dx, m, save_every])

Run 1+1D Dirac simulation.

run_fdtd(t_span[, nx, ny, dx, dy, ...])

Run FDTD simulation using empirical biological tissue dielectric properties.

run_hopf(t_span[, dt, n_oscillators, ...])

Run a simulation of a Hopf oscillator network.

run_jansen_rit(t_span[, dt, n_columns, ...])

Run a Jansen‑Rit neural mass model simulation.

run_klein_gordon(t_span[, nx, ny, dx, m, ...])

Run 2D Klein‑Gordon simulation.

run_neural(t_span[, dt, lambda_reg])

Run simulation with Wilson‑Cowan dynamics for neural branches.

run_neural_field(t_span[, dt, nx, ny, dx, ...])

Run a 2D neural field simulation using empirical lateral connectivity parameters.

run_neural_with_kuramoto(t_span[, dt, ...])

Run neural simulation with Kuramoto coupling between branches.

run_pattern_completion(t_span[, dt, ...])

Simulate Hopfield pattern completion network using empirical olfactory bulb parameters.

run_plastic_jr(t_span[, dt, p_ext])

Run Jansen‑Rit with plastic connectivity.

run_plastic_wc(t_span[, dt, P_ext, Q_ext])

Run Wilson‑Cowan with Hebbian plasticity.

run_visual_transduction(t_span[, dt, ...])

Simulate visual transduction for a time‑varying light intensity.

set_alignment_from_levels([base_similarities])

Initialize alignment using branch levels.

create_neural_branch

run_coupled_fields

set_alignment_matrix

add_branch(label: str = '', level: int = 7) int[source]

Add a new reality branch with specified LADDER level.

add_neural_branch(label: str = '', level: int = 9) int[source]

Add a branch with Wilson‑Cowan neural dynamics.

apply_empirical_parameters() None[source]

Apply literature‑sourced parameters to all modules.

compute_entanglement(field_results: Dict, mode1: Tuple[int, int], mode2: Tuple[int, int]) float[source]

Compute Pearson correlation coefficient between two spatial modes of a Klein‑Gordon field. Returns value in [0, 1] (absolute correlation).

compute_manifestations(branch_id: int, time: float) Dict[Modality, float][source]

Return manifestation probabilities for a branch at given time.

create_neural_branch(label: str = '', level: int = 9, wc_params: WilsonCowanParams | None = None) int[source]
run(t_span: Tuple[float, float], dt: float = 0.1, lambda_reg: float = 0.0) Dict[source]

Run simulation with pattern evolution equation.

run_auditory_transduction(t_span: Tuple[float, float], dt: float = 0.001, displacement_func: Callable[[float], float] | None = None) Dict[source]

Simulate auditory hair cell transduction.

run_coupled_fields(t_span: Tuple[float, float], dt: float = 0.001, nx: int = 64, ny: int = 64, dx: float | None = None, coupling_strength: float | None = None, stimulus_A: Callable[[float], ndarray] | None = None, stimulus_B: Callable[[float], ndarray] | None = None, save_history_every: int = 10) Dict[source]
run_dirac(t_span: Tuple[float, float], nx: int = 256, dx: float = 0.05, m: float = 1.0, save_every: int = 10) Dict[source]

Run 1+1D Dirac simulation.

run_fdtd(t_span: Tuple[float, float], nx: int = 100, ny: int = 100, dx: float | None = None, dy: float | None = None, tissue_type: str | None = None, source: Callable[[int, int, float], float] | None = None, save_every: int = 10) Dict[source]

Run FDTD simulation using empirical biological tissue dielectric properties.

run_hopf(t_span: Tuple[float, float], dt: float = 0.001, n_oscillators: int = 10, kuramoto_coupling: float = 0.0, diffusive_coupling: float = 0.0, time_varying_alpha: Callable[[float, int], float] | None = None) Dict[source]

Run a simulation of a Hopf oscillator network.

Parameters:
t_spantuple

(t_start, t_end) in seconds.

dtfloat

Time step.

n_oscillatorsint

Number of oscillators.

kuramoto_couplingfloat

Phase coupling strength K.

diffusive_couplingfloat

Amplitude coupling strength ε.

time_varying_alphacallable, optional

Function alpha(t, oscillator_index) returning bifurcation parameter.

Returns:
dict

Contains times, amplitudes, phases, and order parameter.

run_jansen_rit(t_span: Tuple[float, float], dt: float = 0.001, n_columns: int = 1, coupling_strength: float = 0.0, external_input: Callable[[float], float] | None = None) Dict[source]

Run a Jansen‑Rit neural mass model simulation.

Parameters:
t_spantuple

(t_start, t_end) in seconds.

dtfloat

Time step.

n_columnsint

Number of coupled columns.

coupling_strengthfloat

Diffusive coupling strength.

external_inputcallable, optional

Function of time returning external input p(t) (for one column, applied to all).

Returns:
dict

Contains times and EEG signals.

run_klein_gordon(t_span: Tuple[float, float], nx: int = 64, ny: int = 64, dx: float = 0.1, m: float = 1.0, initial_phi: ndarray | None = None, source_func: Callable[[float], ndarray] | None = None, save_every: int = 10) Dict[source]

Run 2D Klein‑Gordon simulation.

run_neural(t_span: Tuple[float, float], dt: float = 0.001, lambda_reg: float = 0.0) Dict[source]

Run simulation with Wilson‑Cowan dynamics for neural branches. Enforces non‑negative activity by clamping after each step.

run_neural_field(t_span: Tuple[float, float], dt: float = 0.001, nx: int = 64, ny: int = 64, dx: float | None = None, wc_params: dict | None = None, external_stimulus: Callable[[float], ndarray] | None = None, save_history_every: int = 10) Dict[source]

Run a 2D neural field simulation using empirical lateral connectivity parameters.

run_neural_with_kuramoto(t_span: Tuple[float, float], dt: float = 0.001, coupling_strength: float = 0.5, phase_noise: float = 0.05, kuramoto_feedback: float = 0.1, lambda_reg: float = 0.0) Dict[source]

Run neural simulation with Kuramoto coupling between branches.

Parameters:
t_spantuple

(t_start, t_end) in seconds.

dtfloat

Maximum integration step (used by ODE solver).

coupling_strengthfloat

K in Kuramoto equation.

phase_noisefloat

σ_φ.

kuramoto_feedbackfloat

κ_Kuramoto (scaling of coupling term added to Wilson‑Cowan P_ext).

lambda_regfloat

Regularisation (unused here, for compatibility).

run_pattern_completion(t_span: Tuple[float, float], dt: float = 0.001, n_neurons: int | None = None, stored_patterns: List[ndarray] | None = None, input_function: Callable[[float], ndarray] | None = None) Dict[source]

Simulate Hopfield pattern completion network using empirical olfactory bulb parameters.

run_plastic_jr(t_span: Tuple[float, float], dt: float = 0.0005, p_ext: float = 100.0) Dict[source]

Run Jansen‑Rit with plastic connectivity.

run_plastic_wc(t_span: Tuple[float, float], dt: float = 0.001, P_ext: float = 100.0, Q_ext: float = 0.0) Dict[source]

Run Wilson‑Cowan with Hebbian plasticity.

run_visual_transduction(t_span: Tuple[float, float], dt: float = 0.001, intensity_func: Callable[[float], float] | None = None) Dict[source]

Simulate visual transduction for a time‑varying light intensity.

set_alignment_from_levels(base_similarities: ndarray | None = None)[source]

Initialize alignment using branch levels.

Parameters:
base_similaritiesnp.ndarray, optional

Base isomorphism matrix (N_branches x N_branches) before level adjustment. If None, assumes identity (perfect isomorphism).

set_alignment_matrix(similarity_matrix: ndarray)[source]