# EnergyProfile

> A reaction's energy along its progress: the reactants' level, the hump of the transition state and the products' level, in unit.

Page: https://fframes-kit.pages.dev/docs/chemistry/energy-profile/
Cargo feature: `chemistry` (`fframes-kit = { version = "..", features = ["chemistry"] }`)

A reaction's energy along its progress: the reactants' level, the hump of the transition state
and the products' level, in `unit`. Arrows mark the activation energy (`activation()`) and the
enthalpy change (`enthalpy()`, negative when the reaction releases heat). A dashed guide
carries the reactants' level across. A `catalyst` gives a second, lower peak. Its dashed path
draws at `catalyst_at`. Gallery scene: `EnergyProfile`.

Gallery clip of `EnergyProfile`: https://fframes-kit.pages.dev/media/scenes/EnergyProfile-ad1f5951.mp4

```rust
use fframes_kit::prelude::*;

fn figure<'a>(ui: &mut Ui<'a, '_, '_>) -> Svgr<'a> {
    ui.show(EnergyProfile {
        reactants: 50.0,
        transition: 150.0,
        products: 10.0,
        catalyst: Some(95.0),
        catalyst_at: 2.0,
        enter: Some(Create::default().into()),
        ..ui.defaults()
    })
}
```

## API

Components are plain structs. Set the fields you need and fill the rest with `..ui.defaults()`: the defaults below come from the current theme (`theme.` values are fields of `Theme`).

### EnergyProfile

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `reactants` | `f64` | `50.0` | Energy of the reactants, the flat start of the path, in `unit`. |
| `transition` | `f64` | `150.0` | Energy at the top of the hump (the transition state), in `unit`; the activation energy is this less `reactants`. |
| `products` | `f64` | `10.0` | Energy of the products, the flat end of the path, in `unit`; the enthalpy change is this less `reactants`. |
| `catalyst` | `Option<f64>` | `None` | Energy at the top of a lower catalysed path, drawn dashed; `None` for no catalyst. |
| `catalyst_at` | `f32` | `0.0` | Seconds after the container's start when the catalysed path draws. |
| `unit` | `Cow<str>` | `Cow::Borrowed("kJ/mol")` | Energy unit written after the `Ea` and `∆H` values. |
| `center` | `(f64, f64)` | `(0.0, 0.0)` | The middle of the plot, in units of `ui.space`. |
| `width` | `f32` | `1100.0` | Width of the plot in pixels, axes included. |
| `height` | `f32` | `620.0` | Height of the plot in pixels, axes included. |
| `labels` | `bool` | `true` | Draws the `Ea` and `∆H` arrows and the level and axis names; `false` for the bare path. |
| `axis_color` | `Color` | `theme.colors.muted` | Colour of the axes and the dashed level guide. |
| `path_color` | `Color` | `theme.colors.accent` | Colour of the energy path. |
| `catalyst_color` | `Color` | `Color::hex("#69db7c")` | Colour of the catalysed path. |
| `arrow_color` | `Color` | `theme.colors.highlight` | Colour of the `Ea` and `∆H` arrows. |
| `text_color` | `Color` | `theme.colors.text` | Colour of the labels. |
| `stroke_width` | `f32` | `theme.stroke.regular` | Width in pixels of the energy path lines. |
| `enter` | `Option<EnterAnim>` | `None` | How the axes and the path draw; `None` shows them from the start. |
| `exit` | `Option<ExitAnim>` | `None` | How the axes and the path leave at the end of the container; `None` stays. |
| `parts_enter` | `Option<FadeIn>` | `None` | Fade in of the arrows and labels; `None` for none. |
| `parts_exit` | `Option<FadeOut>` | `None` | Fade out of the arrows and labels before the end; `None` for none. |

Methods:

- `fn activation(&self) -> f64`: The activation energy: the transition state over the reactants.
- `fn enthalpy(&self) -> f64`: The enthalpy change: the products less the reactants, negative when it releases heat.

Feature `chemistry` · [Source](https://github.com/khanhthanhdev/fframes-kit/blob/main/fframes-kit/src/kits/chemistry/energy_profile.rs#L26)
