Deterministic mechanical tolerance stack-up analysis for MoonBit.
moon test --target wasm-gc --deny-warn
moon run cmd/mainlet chain = @moonbitTolerance.Chain::new("shaft", [
@moonbitTolerance.Dimension::new("housing", 20.0, 0.05),
@moonbitTolerance.Dimension::new(
"cover", 0.2, 0.02,
direction=@moonbitTolerance.negative_direction(),
),
])
let result = chain.monte_carlo(10000, seed=42U)moon run cmd/mainmoon fmt --check
moon check --deny-warn
moon test --target wasm-gc --deny-warn
moon test --target native --deny-warn
moon infopub struct BenchmarkCase {
name : String
dimensions : Int
tolerance : Double
seed : UInt
} derive(Debug)pub struct CalibrationPoint {
instrument : String
axis : String
nominal : Double
bias : Double
repeatability : Double
confidence : Double
} derive(Debug)pub struct ConstraintReport {
passed : Int
failed : Int
inconclusive : Int
statuses : Array[(String, ConstraintStatus)]
} derive(Debug)pub struct ProcessCapability {
lower_spec : Double
upper_spec : Double
mean : Double
standard_deviation : Double
} derive(Debug)fn ProcessCapability::new(lower_spec : Double, upper_spec : Double, mean : Double, standard_deviation : Double) -> ProcessCapabilityfn ProjectedDimension::new(name : String, vector : Vector2, tolerance : Double) -> ProjectedDimensionpub struct ReferenceVector {
dimensions : Int
tolerance : Double
nominal : Double
worst_lower : Double
worst_upper : Double
rss_sigma : Double
} derive(Debug)pub struct SamplingPolicy {
distribution : Distribution
sigma_factor : Double
seed : UInt
} derive(Debug)fn SamplingPolicy::new(distribution? : Distribution, sigma_factor? : Double, seed? : UInt) -> SamplingPolicypub struct StandardProfile {
code : String
family : String
nominal_mm : Double
tolerance_mm : Double
cpk_target : Double
sample_count : Int
} derive(Debug)fn evaluate_constraints(result : AnalysisResult, constraints : Array[GapConstraint]) -> ConstraintReportDeterministic mechanical tolerance stack-up analysis for MoonBit.