Bounded constant-scatterer reciprocal diffraction and powder spectra
git clone https://github.com/shangwuxi/moondiffraction.git
cd moondiffraction
moon test --deny-warn
moon run cmd/cubic
moon run cmd/extinction
moon run cmd/powder
python scripts/oracle.py wasm-gcmoon add shangwuxi/moondiffractionimport { "shangwuxi/moondiffraction" @diff }
pkgtype(kind: "executable")fn main {
let m = @diff.reciprocal(3.0, 3.0, 3.0, 90.0, 90.0, 90.0).unwrap()
let points = [@diff.site(0.0, 0.0, 0.0, 1.0).unwrap()]
let reflections = m.simulate(points, 1.0, 1.0).unwrap()
let peaks = @diff.powder(reflections).unwrap()
println(peaks.length())
}| API | 语义 |
|---|---|
| reciprocal / hkl / site | 验证输入并构造只读字段模型 |
| Metric.q2 / spacing / plane_angle | 倒易度量、间距、带方向晶面角 |
| reflections / zone | 有界完整枚举、整数区轴过滤 |
| amplitude / sensitivity | 补偿求和复振幅;单点六参数强度局部导数 |
| Centering.allows / translations | P/I/F/A/B/C/R(R obverse hex)平移规则/点 |
| two_theta / spacing_from_angle | 一阶 Bragg;不可达返回 Ok(None) |
| simulate | 同时限制候选数和相位项数;保留相消/不可达反射 |
| powder | 拒绝重复 hkl 和混合波长;锚点分组,不做链式聚类 |
| gaussian_profile / Profile.area | 单位连续面积 Gaussian;有限窗口梯形积分 |
| match_peaks | 所有容差内候选及残差;不做物相识别 |
| reflections_csv / reflections_json / Profile.csv | 数值导出,JSON 带版本和模型声明 |
moon fmt --check
moon check --target wasm-gc --deny-warn
moon build --target wasm-gc --deny-warn
moon test --target wasm-gc --deny-warn
python scripts/oracle.py wasm-gcpub struct Metric {
aa : Double
bb : Double
cc : Double
ab : Double
ac : Double
bc : Double
a : Double
b : Double
c : Double
} derive(Debug)pub struct Sensitivity {
dx : Double
dy : Double
dz : Double
occupancy : Double
weight : Double
b_iso : Double
} derive(Debug)pub struct Site {
x : Double
y : Double
z : Double
weight : Double
occupancy : Double
b_iso : Double
} derive(Debug)Install
Download zipBounded constant-scatterer reciprocal diffraction and powder spectra