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:
14
simul-core/Cargo.toml
Normal file
14
simul-core/Cargo.toml
Normal 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
23
simul-core/src/lib.rs
Normal 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
34
simul-core/src/space.rs
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user