| from __future__ import annotations |
|
|
| """ |
| Explicit group-translation mapping layer between ugropy's Dortmund-UNIFAC |
| fragmentation output and thermo's bundled DOUFSG parameter table. |
| |
| This resolves nomenclature collisions (e.g. "CHO" belonging to both an |
| aldehyde main group and an ether linker main group) and maps ugropy's |
| idiosyncratic subgroup names to thermo's integer subgroup IDs. |
| """ |
|
|
| |
| |
| |
| |
| UGROPY_TO_THERMO_NAME: dict[str, str] = { |
| |
| "HCO": "CHO", |
| "CH=O": "CHO", |
| |
| "OH (P)": "OH(P)", |
| "OH (S)": "OH(S)", |
| "OH (T)": "OH(T)", |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| EXPLICIT_THERMO_ID: dict[str, int] = { |
| "HCO": 20, |
| "CH=O": 20, |
| "CHO__ALDEHYDE": 20, |
| "CHO__ETHER": 26, |
| } |
|
|
|
|
| def map_ugropy_to_thermo_id( |
| name: str, |
| name_to_id: dict[str, int], |
| ) -> int | None: |
| """ |
| Translate a ugropy subgroup name to the thermo DDB UNIFAC subgroup ID. |
| |
| Parameters |
| ---------- |
| name : str |
| ugropy subgroup name (e.g. "HCO", "OH (P)", "CH3"). |
| name_to_id : dict[str, int] |
| Mapping from thermo subgroup label to thermo subgroup ID. |
| |
| Returns |
| ------- |
| int | None |
| Thermo subgroup ID, or None if the group is not representable. |
| """ |
| |
| if name in EXPLICIT_THERMO_ID: |
| return EXPLICIT_THERMO_ID[name] |
|
|
| |
| normalised = UGROPY_TO_THERMO_NAME.get(name, name).replace(" ", "") |
| if normalised in EXPLICIT_THERMO_ID: |
| return EXPLICIT_THERMO_ID[normalised] |
|
|
| return name_to_id.get(normalised) |
|
|