///|
fn constant_heat_capacity(
  value : Double,
  t_min_k : Double,
  t_max_k : Double,
  source : String,
) -> HeatCapacityPolynomial raise VleError {
  HeatCapacityPolynomial::new(coefficients=[value], t_min_k~, t_max_k~, source~)
}

///|
pub fn water_thermo_property() -> ThermoProperty raise VleError {
  ThermoProperty::new(
    component=water(),
    molecular_weight_g_per_mol=18.01528,
    liquid_heat_capacity=HeatCapacityPolynomial::new(
      coefficients=[74.30, 0.0100],
      t_min_k=250.0,
      t_max_k=500.0,
      source="NIST WebBook liquid-water heat-capacity approximation for educational use.",
    ),
    vapor_heat_capacity=constant_heat_capacity(
      33.60, 250.0, 700.0, "NIST WebBook ideal-gas water heat-capacity approximation.",
    ),
    reference_temperature_k=298.15,
    normal_boiling_temperature_k=373.15,
    latent_heat_j_per_mol=40650.0,
    source="NIST Chemistry WebBook SRD 69; rounded educational property record.",
  )
}

///|
pub fn ethanol_thermo_property() -> ThermoProperty raise VleError {
  ThermoProperty::new(
    component=ethanol(),
    molecular_weight_g_per_mol=46.06844,
    liquid_heat_capacity=HeatCapacityPolynomial::new(
      coefficients=[90.0, 0.055],
      t_min_k=250.0,
      t_max_k=450.0,
      source="NIST WebBook liquid ethanol heat-capacity approximation.",
    ),
    vapor_heat_capacity=constant_heat_capacity(
      65.0, 250.0, 650.0, "NIST WebBook ideal-gas ethanol heat-capacity approximation.",
    ),
    reference_temperature_k=298.15,
    normal_boiling_temperature_k=351.45,
    latent_heat_j_per_mol=38560.0,
    source="NIST Chemistry WebBook SRD 69; rounded educational property record.",
  )
}

///|
pub fn benzene_thermo_property() -> ThermoProperty raise VleError {
  ThermoProperty::new(
    component=benzene(),
    molecular_weight_g_per_mol=78.114,
    liquid_heat_capacity=HeatCapacityPolynomial::new(
      coefficients=[100.0, 0.035],
      t_min_k=260.0,
      t_max_k=500.0,
      source="NIST WebBook liquid benzene heat-capacity approximation.",
    ),
    vapor_heat_capacity=constant_heat_capacity(
      82.0, 260.0, 650.0, "NIST WebBook ideal-gas benzene heat-capacity approximation.",
    ),
    reference_temperature_k=298.15,
    normal_boiling_temperature_k=353.25,
    latent_heat_j_per_mol=30800.0,
    source="NIST Chemistry WebBook SRD 69; rounded educational property record.",
  )
}

///|
pub fn toluene_thermo_property() -> ThermoProperty raise VleError {
  ThermoProperty::new(
    component=toluene(),
    molecular_weight_g_per_mol=92.140,
    liquid_heat_capacity=HeatCapacityPolynomial::new(
      coefficients=[120.0, 0.025],
      t_min_k=260.0,
      t_max_k=520.0,
      source="NIST WebBook liquid toluene heat-capacity approximation.",
    ),
    vapor_heat_capacity=constant_heat_capacity(
      103.0, 260.0, 700.0, "NIST WebBook ideal-gas toluene heat-capacity approximation.",
    ),
    reference_temperature_k=298.15,
    normal_boiling_temperature_k=383.75,
    latent_heat_j_per_mol=33400.0,
    source="NIST Chemistry WebBook SRD 69; rounded educational property record.",
  )
}

///|
pub fn methanol_thermo_property() -> ThermoProperty raise VleError {
  ThermoProperty::new(
    component=methanol(),
    molecular_weight_g_per_mol=32.04186,
    liquid_heat_capacity=constant_heat_capacity(
      81.0, 250.0, 450.0, "NIST WebBook liquid methanol heat-capacity approximation.",
    ),
    vapor_heat_capacity=constant_heat_capacity(
      44.0, 250.0, 650.0, "NIST WebBook ideal-gas methanol heat-capacity approximation.",
    ),
    reference_temperature_k=298.15,
    normal_boiling_temperature_k=337.85,
    latent_heat_j_per_mol=35200.0,
    source="NIST Chemistry WebBook SRD 69; rounded educational property record.",
  )
}

///|
pub fn acetone_thermo_property() -> ThermoProperty raise VleError {
  ThermoProperty::new(
    component=acetone(),
    molecular_weight_g_per_mol=58.080,
    liquid_heat_capacity=constant_heat_capacity(
      126.0, 240.0, 430.0, "NIST WebBook liquid acetone heat-capacity approximation.",
    ),
    vapor_heat_capacity=constant_heat_capacity(
      75.0, 240.0, 650.0, "NIST WebBook ideal-gas acetone heat-capacity approximation.",
    ),
    reference_temperature_k=298.15,
    normal_boiling_temperature_k=329.45,
    latent_heat_j_per_mol=29500.0,
    source="NIST Chemistry WebBook SRD 69; rounded educational property record.",
  )
}

///|
pub fn chloroform_thermo_property() -> ThermoProperty raise VleError {
  ThermoProperty::new(
    component=chloroform(),
    molecular_weight_g_per_mol=119.378,
    liquid_heat_capacity=constant_heat_capacity(
      115.0, 240.0, 450.0, "NIST WebBook liquid chloroform heat-capacity approximation.",
    ),
    vapor_heat_capacity=constant_heat_capacity(
      82.0, 240.0, 650.0, "NIST WebBook ideal-gas chloroform heat-capacity approximation.",
    ),
    reference_temperature_k=298.15,
    normal_boiling_temperature_k=334.35,
    latent_heat_j_per_mol=29400.0,
    source="NIST Chemistry WebBook SRD 69; rounded educational property record.",
  )
}

///|
pub fn ethyl_acetate_thermo_property() -> ThermoProperty raise VleError {
  ThermoProperty::new(
    component=ethyl_acetate(),
    molecular_weight_g_per_mol=88.106,
    liquid_heat_capacity=constant_heat_capacity(
      170.0, 260.0, 470.0, "NIST WebBook liquid ethyl acetate heat-capacity approximation.",
    ),
    vapor_heat_capacity=constant_heat_capacity(
      105.0, 260.0, 680.0, "NIST WebBook ideal-gas ethyl acetate heat-capacity approximation.",
    ),
    reference_temperature_k=298.15,
    normal_boiling_temperature_k=350.25,
    latent_heat_j_per_mol=31000.0,
    source="NIST Chemistry WebBook SRD 69; rounded educational property record.",
  )
}

///|
pub fn n_hexane_thermo_property() -> ThermoProperty raise VleError {
  ThermoProperty::new(
    component=n_hexane(),
    molecular_weight_g_per_mol=86.177,
    liquid_heat_capacity=constant_heat_capacity(
      195.0, 260.0, 470.0, "NIST WebBook liquid n-hexane heat-capacity approximation.",
    ),
    vapor_heat_capacity=constant_heat_capacity(
      150.0, 260.0, 700.0, "NIST WebBook ideal-gas n-hexane heat-capacity approximation.",
    ),
    reference_temperature_k=298.15,
    normal_boiling_temperature_k=341.85,
    latent_heat_j_per_mol=28700.0,
    source="NIST Chemistry WebBook SRD 69; rounded educational property record.",
  )
}

///|
pub fn cyclohexane_thermo_property() -> ThermoProperty raise VleError {
  ThermoProperty::new(
    component=cyclohexane(),
    molecular_weight_g_per_mol=84.161,
    liquid_heat_capacity=constant_heat_capacity(
      156.0, 260.0, 480.0, "NIST WebBook liquid cyclohexane heat-capacity approximation.",
    ),
    vapor_heat_capacity=constant_heat_capacity(
      137.0, 260.0, 700.0, "NIST WebBook ideal-gas cyclohexane heat-capacity approximation.",
    ),
    reference_temperature_k=298.15,
    normal_boiling_temperature_k=353.75,
    latent_heat_j_per_mol=29900.0,
    source="NIST Chemistry WebBook SRD 69; rounded educational property record.",
  )
}

///|
pub fn public_thermo_property_catalog() -> Array[ThermoProperty] raise VleError {
  [
    water_thermo_property(),
    ethanol_thermo_property(),
    methanol_thermo_property(),
    benzene_thermo_property(),
    toluene_thermo_property(),
    acetone_thermo_property(),
    chloroform_thermo_property(),
    ethyl_acetate_thermo_property(),
    n_hexane_thermo_property(),
    cyclohexane_thermo_property(),
  ]
}