phasesmith_engine/lib.rs
1//! Native composition boundary for crystallography and powder profiles.
2//!
3//! `phasesmith-engine` turns crystallographic definitions into calculated
4//! powder patterns by composing `phasesmith-crystallography` with
5//! `phasesmith-core`. It has no Python, file-format, persistence, refinement,
6//! or GUI dependency. Applications normally use it through
7//! [`phasesmith::engine`](https://docs.rs/phasesmith/latest/phasesmith/).
8//!
9//! # Choosing an entry point
10//!
11//! - [`calculate_structural_pattern`] is the direct one-phase, one-wavelength
12//! calculation.
13//! - [`calculate_structural_tof_pattern`] is the direct one-phase, one-bank
14//! neutron TOF calculation with explicit bank geometry and correction.
15//! - [`PreparedStructuralPhase`] validates and caches topology for repeated
16//! phase evaluations.
17//! - [`PreparedStructuralSpectrum`] adds fixed wavelength components.
18//! - [`PreparedStructuralMultiphase`] composes multiple structural phases.
19//! - [`PreparedStructuralModel`] is the reusable high-level structural model.
20//!
21//! Values, dense-Jacobian, JVP, and VJP paths share the same physical model.
22//! Prepared types are the intended choice for optimizers and interactive hosts:
23//! construct them when topology changes, then reuse them while numerical
24//! parameters vary.
25//!
26//! # Data boundary
27//!
28//! Inputs use borrowed array views and explicit physical definitions. Results
29//! own their values, reflection metadata, and derivative products. File parsing
30//! belongs to `phasesmith-io`; application records belong to
31//! `phasesmith-model`; refinement orchestration belongs to
32//! `phasesmith-workflows`.
33//!
34//! See the facade's
35//! [pattern-composition mathematics](https://docs.rs/phasesmith/latest/phasesmith/guide/mathematics/pattern_composition/)
36//! for the multi-phase, multi-wavelength, sample-physics, and derivative sums.
37
38pub use phasesmith_core as profile;
39pub use phasesmith_crystallography as crystallography;
40
41mod prepared_structural_phase;
42mod structural_multiphase;
43pub mod structural_pattern;
44mod structural_spectrum;
45pub mod structural_tof;
46
47pub use prepared_structural_phase::{
48 PreparedStructuralPatternInputView, PreparedStructuralPhase, StructuralPhaseDefinition,
49};
50pub use structural_multiphase::{
51 PreparedStructuralModel, PreparedStructuralModelInputView, PreparedStructuralMultiphase,
52 StructuralCalculationRequest, StructuralCalculationResult, StructuralModelInput,
53 StructuralMultiphaseError, StructuralMultiphaseResult,
54};
55pub use structural_spectrum::{
56 PreparedStructuralSpectrum, PreparedStructuralSpectrumInputView, StructuralSpectrumError,
57};
58pub use structural_tof::{
59 StructuralTofDenseResult, StructuralTofError, StructuralTofInputView, StructuralTofJvpResult,
60 StructuralTofResult, StructuralTofVjpResult, calculate_structural_tof_pattern,
61 calculate_structural_tof_pattern_dense, calculate_structural_tof_pattern_dense_with_context,
62 calculate_structural_tof_pattern_jvp, calculate_structural_tof_pattern_jvp_with_context,
63 calculate_structural_tof_pattern_vjp, calculate_structural_tof_pattern_vjp_with_context,
64 calculate_structural_tof_pattern_with_context,
65};
66
67pub use structural_pattern::{
68 BuiltInScatteringModel, MonochromaticPositionCorrection, MonochromaticReflectionGeometry,
69 StructuralPatternDenseResult, StructuralPatternError, StructuralPatternInputView,
70 StructuralPatternJvpResult, StructuralPatternResult, StructuralPatternVjpResult,
71 calculate_monochromatic_reflection_geometry, calculate_structural_pattern,
72 calculate_structural_pattern_dense, calculate_structural_pattern_dense_with_context,
73 calculate_structural_pattern_jvp, calculate_structural_pattern_jvp_with_context,
74 calculate_structural_pattern_vjp, calculate_structural_pattern_vjp_with_context,
75 calculate_structural_pattern_with_context,
76};