feat(simul-core): Add StateSpace trait

- Define StateSpace trait with const DIM, Point, Momentum types
- Add zero_point() and zero_momentum() factory methods
- Core abstraction for Euclidean and Lattice spaces
This commit is contained in:
2026-01-10 23:55:13 +09:00
parent 671cc2f497
commit f54f7c20d5
3 changed files with 71 additions and 0 deletions

14
simul-core/Cargo.toml Normal file
View File

@@ -0,0 +1,14 @@
[package]
name = "simul-core"
description = "Core traits and abstractions for the simul simulation framework"
version.workspace = true
edition.workspace = true
license.workspace = true
[dependencies]
nalgebra = { workspace = true }
thiserror = { workspace = true }
rand = { workspace = true }
[dev-dependencies]
approx = { workspace = true }

23
simul-core/src/lib.rs Normal file
View File

@@ -0,0 +1,23 @@
//! simul-core: Core traits and abstractions for the simul simulation framework
//!
//! This crate provides the foundational traits that all simulation types build upon:
//! - `StateSpace` - defines the geometric structure (Euclidean, Lattice, etc.)
//! - `Dynamics` - defines time evolution rules (Verlet, Langevin, Metropolis, etc.)
//! - `Interaction` - defines driving forces/rates (L-J, Ising, etc.)
pub mod dynamics;
pub mod error;
pub mod interaction;
pub mod space;
pub mod state;
pub mod units;
pub mod prelude {
//! Convenient re-exports for common use
pub use crate::dynamics::{Dynamics, TimeType};
pub use crate::error::SimulationError;
pub use crate::interaction::Interaction;
pub use crate::space::StateSpace;
pub use crate::state::SystemState;
pub use crate::units::*;
}

34
simul-core/src/space.rs Normal file
View File

@@ -0,0 +1,34 @@
//! State space abstraction
//!
//! The `StateSpace` trait defines the geometric/topological structure of the configuration space.
use std::fmt::Debug;
/// Defines the geometric/topological structure of the state space
///
/// This trait abstracts over different types of spaces:
/// - `Euclidean<D>`: Continuous D-dimensional space (for MD, Brownian)
/// - `Lattice<D>`: Discrete D-dimensional lattice (for Ising, random walk)
pub trait StateSpace: Clone + Send + Sync + 'static {
/// Compile-time dimension of the space
const DIM: usize;
/// Type representing a point/position in this space
type Point: Clone + Send + Sync + Debug;
/// Type representing momentum/velocity
/// Use `()` for systems without momentum (e.g., overdamped, discrete)
type Momentum: Clone + Send + Sync + Debug;
/// Create a zero point (origin)
fn zero_point() -> Self::Point;
/// Create a zero momentum
fn zero_momentum() -> Self::Momentum;
/// Whether this is a continuous space
fn is_continuous() -> bool;
/// Human-readable name of the space
fn name() -> &'static str;
}