221 lines
4.9 KiB
Rust
221 lines
4.9 KiB
Rust
//! Prelude module for convenient imports
|
|
//!
|
|
//! This module re-exports the most commonly used types, traits, and functions
|
|
//! from RTX Science for convenient access.
|
|
|
|
// Core error handling
|
|
pub use crate::error::{Result, ScienceError};
|
|
|
|
// Physics-informed neural networks
|
|
#[cfg(feature = "pinn")]
|
|
pub use crate::physics::{
|
|
AdaptiveSampling,
|
|
BoundaryConditions,
|
|
BurgersEquation,
|
|
ConservationLaw,
|
|
|
|
ConservationLoss,
|
|
ConservationValidator,
|
|
// Boundary condition types
|
|
DirichletBC,
|
|
EnergyConservation,
|
|
// Common PDE types
|
|
HeatEquation,
|
|
KdVEquation,
|
|
// Conservation laws
|
|
MassConservation,
|
|
MaxwellEquations,
|
|
MomentumConservation,
|
|
MultiPhysicsPINN,
|
|
NavierStokes,
|
|
NeumannBC,
|
|
PINN,
|
|
// Training utilities
|
|
PINNTrainer,
|
|
PeriodicBC,
|
|
|
|
PhysicsInformedNetwork,
|
|
|
|
PhysicsLoss,
|
|
PoissonEquation,
|
|
ResidualSampling,
|
|
RobinBC,
|
|
Schrodinger,
|
|
WaveEquation,
|
|
create_pde,
|
|
};
|
|
|
|
// Chemistry applications
|
|
#[cfg(feature = "chemistry")]
|
|
pub use crate::chemistry::{
|
|
// Property calculators
|
|
ADMET,
|
|
AtomicFeatures,
|
|
BondFeatures,
|
|
DrugDiscovery,
|
|
Lipinski,
|
|
MolecularDataset,
|
|
|
|
MolecularGNN,
|
|
MolecularOptimization,
|
|
MolecularTransformer,
|
|
// Data structures
|
|
Molecule,
|
|
PropertyPredictor,
|
|
ReactionPredictor,
|
|
|
|
Solubility,
|
|
Toxicity,
|
|
};
|
|
|
|
// Biology applications
|
|
#[cfg(feature = "biology")]
|
|
pub use crate::biology::{
|
|
AminoAcid,
|
|
BLAST,
|
|
DNASequence,
|
|
GenomicsToolkit,
|
|
HMM,
|
|
// Analysis tools
|
|
MSA,
|
|
MetabolicNetwork,
|
|
PhylogenomicsAnalyzer,
|
|
Phylogeny,
|
|
ProteinFolding,
|
|
|
|
// Data structures
|
|
ProteinSequence,
|
|
ProteinStructurePredictor,
|
|
RNASequence,
|
|
SecondaryStructure,
|
|
SequenceAnalyzer,
|
|
StructurePredictionModel,
|
|
|
|
TertiaryStructure,
|
|
};
|
|
|
|
// Materials science applications
|
|
#[cfg(feature = "materials")]
|
|
pub use crate::materials::{
|
|
AtomPosition,
|
|
BasisSet,
|
|
CatalysisOptimizer,
|
|
// Data structures
|
|
CrystalLattice,
|
|
CrystalStructurePredictor,
|
|
// DFT integration
|
|
DFTCalculator,
|
|
DefectAnalyzer,
|
|
|
|
ElectronicBand,
|
|
|
|
ElectronicStructure,
|
|
ExchangeCorrelation,
|
|
MaterialProperty,
|
|
MaterialsPropertyModel,
|
|
PhononCalculator,
|
|
PointGroup,
|
|
SpaceGroup,
|
|
UnitCell,
|
|
};
|
|
|
|
// Scientific computing infrastructure
|
|
#[cfg(feature = "computing")]
|
|
pub use crate::computing::{
|
|
AdamsBashforth,
|
|
CG,
|
|
|
|
CrankNicolson,
|
|
DistributedSolver,
|
|
EigenSolver,
|
|
FFTProcessor,
|
|
GMRES,
|
|
GPUKernel,
|
|
LinearSolver,
|
|
ODESolver,
|
|
OptimizationEngine,
|
|
|
|
PDESolver,
|
|
// Parallel computing
|
|
ParallelSolver,
|
|
// Numerical methods
|
|
RungeKutta,
|
|
StatisticalAnalyzer,
|
|
};
|
|
|
|
// Integration utilities
|
|
pub use crate::integration::{
|
|
AutoDiff, BenchmarkSuite, DataLoader, GradientCompute, MatMulBenchmark, RTXDevice,
|
|
ScientificTensor, ValidationMetrics,
|
|
};
|
|
|
|
// Common mathematical functions and constants
|
|
pub use std::f64::consts::{E, LN_2, LN_10, PI, SQRT_2, TAU};
|
|
|
|
// Re-export essential tensor operations
|
|
pub use rtx_tensor::{DType, Device, Shape, Tensor};
|
|
|
|
// Re-export common traits for ergonomics
|
|
pub use async_trait::async_trait;
|
|
pub use serde::{Deserialize, Serialize};
|
|
|
|
/// Commonly used result type for scientific computing operations
|
|
pub type SciResult<T> = Result<T>;
|
|
|
|
/// Convenience macro for creating validation bounds
|
|
#[macro_export]
|
|
macro_rules! validate_range {
|
|
($value:expr, $min:expr, $max:expr, $param:literal) => {
|
|
if $value < $min || $value > $max {
|
|
return Err(ScienceError::InvalidParameters {
|
|
parameter: $param.to_string(),
|
|
value: $value as f64,
|
|
min: $min as f64,
|
|
max: $max as f64,
|
|
});
|
|
}
|
|
};
|
|
}
|
|
|
|
/// Convenience macro for physics error creation
|
|
#[macro_export]
|
|
macro_rules! physics_error {
|
|
($domain:expr, $($arg:tt)*) => {
|
|
ScienceError::physics(format!($($arg)*), $domain)
|
|
};
|
|
}
|
|
|
|
/// Convenience macro for numerical error creation
|
|
#[macro_export]
|
|
macro_rules! numerical_error {
|
|
($method:expr, $($arg:tt)*) => {
|
|
ScienceError::numerical(format!($($arg)*), $method, None)
|
|
};
|
|
}
|
|
|
|
/// Convenience macro for conservation law validation
|
|
#[macro_export]
|
|
macro_rules! check_conservation {
|
|
($law:expr, $value:expr, $tolerance:expr) => {
|
|
if $value.abs() > $tolerance {
|
|
return Err(ScienceError::conservation_violation(
|
|
$law,
|
|
$value.abs(),
|
|
$tolerance,
|
|
));
|
|
}
|
|
};
|
|
}
|
|
|
|
/// Common type aliases for convenience
|
|
pub type Float = f64;
|
|
pub type Complex = num_complex::Complex64;
|
|
pub type Matrix = nalgebra::DMatrix<Float>;
|
|
pub type Vector = nalgebra::DVector<Float>;
|
|
|
|
// Re-export commonly used external types
|
|
pub use dashmap::DashMap;
|
|
pub use indexmap::IndexMap;
|
|
pub use nalgebra::{DMatrix, DVector, Matrix3, Matrix4, Vector3, Vector4};
|
|
pub use num_complex::Complex64;
|