Skip to main content

KuramotoSolver

Struct KuramotoSolver 

Source
pub struct KuramotoSolver {
    pub n: usize,
    pub omega: Vec<f64>,
    pub coupling: Vec<f64>,
    pub phases: Vec<f64>,
    pub noise_amp: f64,
    pub field_pressure: f64,
    dtheta: Vec<f64>,
    sin_diff: Vec<f64>,
    noise: Vec<f64>,
    cos_theta: Vec<f64>,
    geo_coupling: Vec<f64>,
    pgbo_coupling: Vec<f64>,
}
Expand description

High-performance Kuramoto oscillator solver.

Baseline equation: dθ_n/dt = ω_n + Σ_m K_nm sin(θ_m - θ_n) + noise

SSGF extension (step_ssgf) adds geometry/PGBO/field terms: + σ_g Σ_m W_nm sin(θ_m - θ_n) + pgbo_w Σ_m h_nm sin(θ_m - θ_n) + F cos(θ_n).

Fields§

§n: usize

Number of oscillators.

§omega: Vec<f64>

Natural frequencies ω_n, shape (n,).

§coupling: Vec<f64>

Baseline coupling matrix K_nm, row-major shape (n*n).

§phases: Vec<f64>

Current phase vector θ_n, shape (n,).

§noise_amp: f64

Gaussian noise amplitude.

§field_pressure: f64

Field pressure strength F used by step_ssgf.

§dtheta: Vec<f64>

Scratch: per-oscillator phase derivative.

§sin_diff: Vec<f64>

Scratch: sin(θ_m - θ_n) matrix, row-major (n*n).

§noise: Vec<f64>

Scratch: per-step standard normal draws.

§cos_theta: Vec<f64>

Scratch: cos(θ_n) vector for field-pressure term.

§geo_coupling: Vec<f64>

Scratch: geometry coupling contribution per oscillator.

§pgbo_coupling: Vec<f64>

Scratch: PGBO coupling contribution per oscillator.

Implementations§

Source§

impl KuramotoSolver

Source

pub fn new( omega: Vec<f64>, coupling_flat: Vec<f64>, initial_phases: Vec<f64>, noise_amp: f64, ) -> Self

Create a new solver with preallocated scratch buffers.

Source

pub fn set_field_pressure(&mut self, f: f64)

Set external field pressure F for SSGF mode.

Source

pub fn step(&mut self, dt: f64, seed: u64) -> f64

Advance one baseline Euler step.

Returns Kuramoto order parameter R ∈ [0, 1].

Source

pub fn run(&mut self, n_steps: usize, dt: f64, seed: u64) -> Vec<f64>

Advance N baseline steps and return R after each step.

Source

pub fn step_ssgf( &mut self, dt: f64, seed: u64, w_flat: &[f64], sigma_g: f64, h_flat: &[f64], pgbo_weight: f64, ) -> f64

SSGF-compatible step with geometry and PGBO coupling.

w_flat: row-major geometry matrix W (n*n). Empty slice disables geometry term. sigma_g: geometry coupling gain. h_flat: row-major PGBO tensor h (n*n). Empty slice disables PGBO term. pgbo_weight: PGBO coupling gain.

Returns Kuramoto order parameter R ∈ [0, 1].

Source

pub fn run_ssgf( &mut self, n_steps: usize, dt: f64, seed: u64, w_flat: &[f64], sigma_g: f64, h_flat: &[f64], pgbo_weight: f64, ) -> Vec<f64>

Run N SSGF-compatible steps and return R after each step.

Source

pub fn order_parameter(&self) -> f64

Compute Kuramoto order parameter R = sqrt(mean(cos θ)^2 + mean(sin θ)^2).

Source

pub fn get_phases(&self) -> &[f64]

Borrow current phase vector.

Source

pub fn set_phases(&mut self, phases: Vec<f64>)

Replace phase vector.

Source

pub fn set_coupling(&mut self, coupling_flat: Vec<f64>)

Replace baseline coupling matrix.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Ungil for T
where T: Send,