import type { CompositionType } from '../composition'; import type { GasSpecies, GasThermodynamicsProvider, PhaseData } from '../convex-hull/types'; import type { ElementSymbol } from '../element/types'; export interface SynthesisConditions { temperature?: number; open_species?: GasSpecies[]; partial_pressures?: Partial>; gas_provider?: GasThermodynamicsProvider; } export interface PrecursorPoolOptions { allow?: string[]; block?: string[]; max_e_above_hull?: number; only_common?: boolean; max_elements?: number; } export interface ScoreWeights { selectivity: number; inverse_hull: number; driving_force: number; competition: number; practicality: number; simplicity: number; } export interface SynthesisPlanRequest { entries: PhaseData[]; target: string; precursors?: PrecursorPoolOptions; conditions?: SynthesisConditions; max_precursors?: number; two_step?: boolean; scoring?: Partial; max_routes?: number; target_mass_g?: number; } export interface SynthesisPlanProgress { stage: `preparing` | `direct_routes` | `two_step_routes` | `ranking`; current: number; total: number; } export interface PhaseRef { id: string; formula: string; composition: CompositionType; energy_per_atom: number; e_above_hull: number; n_atoms_per_fu: number; molar_mass: number; is_gas: boolean; common_name?: string; } export interface ReactionSpecies { phase: PhaseRef; coefficient: number; } export interface SynthesisReaction { reactants: ReactionSpecies[]; products: ReactionSpecies[]; equation: string; energy_per_atom: number; energy_per_fu: number; driving_force: number; } export interface CompetingPhase { phase: PhaseRef; driving_force: number; more_favorable_than_target: boolean; mixture: Record; } export interface PairwiseInterface { precursors: [PhaseRef, PhaseRef]; first_product: CompetingPhase | null; forms_target: boolean; } export interface SelectivityMetrics { target_driving_force: number; inverse_hull_energy: number; competitors: CompetingPhase[]; selectivity_margin: number; n_more_favorable: number; target_is_most_favorable: boolean; interfaces: PairwiseInterface[]; } export interface RouteThermodynamics { onset_temperature: number | null; gas_exchange: Partial>; atmosphere: string; } export interface PracticalityAssessment { score: number; notes: string[]; } export interface RecipeItem { phase: PhaseRef; role: `precursor` | `atmosphere` | `target` | `byproduct`; moles: number; mass_g: number; mass_fraction?: number; } export interface Recipe { target_mass_g: number; items: RecipeItem[]; mass_loss_percent: number; temperature_window: { min_K: number | null; max_K: number | null; basis: string[]; }; procedure: string[]; } export type RejectReason = `unbalanced` | `redundant_precursor` | `uphill`; export interface SynthesisRoute { id: string; kind: `direct` | `two_step`; reaction: SynthesisReaction; intermediate_step?: SynthesisReaction; selectivity: SelectivityMetrics; thermodynamics: RouteThermodynamics; practicality: PracticalityAssessment; score: number; score_breakdown: Record; rationale: string[]; recipe: Recipe; } export interface TargetStability { e_above_hull: number; is_stable: boolean; decomposition: { phase: PhaseRef; atom_fraction: number; }[]; } export interface SynthesisPlan { target: PhaseRef; chemical_system: string; elements: ElementSymbol[]; conditions: Required> & { partial_pressures: Partial>; }; target_stability: TargetStability; weights: ScoreWeights; routes: SynthesisRoute[]; rejected: Record; n_candidates: number; precursor_pool: PhaseRef[]; warnings: string[]; }