Discrete Element Method (DEM) library for granular media in MoonBit focusing on particle mechanics, contact models, and micro-macro statistics.
src/
├── math/ 向量、矩阵、四元数、随机数与应力数学工具
├── particle/ 球形颗粒、材料属性、PSD 与多球团簇
├── contact/ Hertz–Mindlin、Hooke、JKR、Parallel Bond
├── boundary/ 平面/圆柱/周期/网格边界与伺服控制
├── spatial/ 空间哈希网格与 Verlet 邻域表
├── integrator/ Velocity–Verlet 与自适应子步
├── simulation/ 仿真世界、接触推进和轨迹导出
├── stats/ 微宏观应力、织构、力链、配位数和堆积统计
├── analysis/ 能量、质量、时间序列和摘要报告
├── app/ 直剪、漏斗、三轴、粮仓和旋转鼓案例
├── bench/ 确定性算法基准库
└── main/ 可运行的 CLI 演示
cmd/benchmark/ native 基准入口
benchmarks/ 本机基准证据
scripts/ 本地复现脚本moon version --all
moon update
moon check --target all
moon test --target all
moon run --target native src/main./scripts/benchmark.ps1 -Runs 5
./scripts/benchmark.ps1 -Runs 5 -OutputPath benchmarks/latest-native.mdimport {
"ssqzerz/moonbit-granular/src/analysis"
"ssqzerz/moonbit-granular/src/math"
"ssqzerz/moonbit-granular/src/particle"
"ssqzerz/moonbit-granular/src/simulation"
}
let world = @simulation.SimulationWorld::new(
0.02,
512,
0.005,
0.0001,
@math.Vec3::new(0.0, -9.81, 0.0),
)
let particle = @particle.Particle3D::new(
1,
@math.Vec3::new(0.0, 0.01, 0.0),
0.005,
2650.0,
0,
)
world.add_particle(particle)
for _step = 0; _step < 100; _step = _step + 1 {
world.step()
}
let report = @analysis.AnalysisReport::from(
world.particles(),
@math.Vec3::new(-0.1, -0.1, -0.1),
@math.Vec3::new(0.1, 0.1, 0.1),
)
println(report.to_string())moon fmt
moon check --deny-warn
moon test --deny-warn
moon test --target all
moon infoInstall
Download zipDiscrete Element Method (DEM) library for granular media in MoonBit focusing on particle mechanics, contact models, and micro-macro statistics.