torchref.scripts.generate_scattering_table module

Generate pre-computed ITC92 scattering factor table.

This script creates a .pt file containing scattering factor parameters for all elements (Z=1 to 103) and available ions. The generated file removes the need for runtime gemmi dependency for scattering parameter lookup.

Usage:

python -m torchref.scripts.generate_scattering_table

Output:

torchref/data/itc92_scattering_factors.pt

torchref.scripts.generate_scattering_table.get_element_to_z_from_csv(csv_path)[source]

Build element-to-Z mapping from atomic_vdw_radii.csv.

Parameters:

csv_path (str) – Path to the CSV file with element data.

Returns:

Mapping of element symbol to atomic number.

Return type:

dict

torchref.scripts.generate_scattering_table.get_itc92_params(element, charge=0)[source]

Get ITC92 scattering parameters for an element with optional charge.

Parameters:
  • element (str) – Element symbol (e.g., ‘C’, ‘Fe’).

  • charge (int, optional) – Ionic charge. Default is 0.

Returns:

(A, B) tensors of shape (5,) each, or None if not available.

Return type:

tuple or None

torchref.scripts.generate_scattering_table.generate_scattering_table(output_path, csv_path, verbose=True)[source]

Generate the complete scattering factor table.

Parameters:
  • output_path (str) – Path to save the .pt file.

  • csv_path (str) – Path to atomic_vdw_radii.csv for element-to-Z mapping.

  • verbose (bool, optional) – Print progress information. Default is True.

torchref.scripts.generate_scattering_table.main()[source]

Main entry point for the script.