r"""
Plot thermodynamic and transport data vs. temperature for a plasma of H2, O2, N2, Ar, He in LTE.
================================================================================================

This example plots the thermodynamic and transport data of H2, O2, N2, Ar, and He
as a function of temperature.

References data
---------------

- [Boulos2023]_


.. tags:: transport, H2, O2, N2, Ar, He, plasma, thermal conductivity, electrical conductivity, viscosity
"""  # noqa: D205

# %%
# Import the required libraries.
# ------------------------------

import matplotlib.pyplot as plt

from rizer.io.thermo_transport_data_reader import ThermoTransportDataReader
from rizer.misc.plt_utils import set_mpl_style

# Set the style of the plots.
set_mpl_style()


# %%
# Load reference data.
# --------------------

data_H2_Boulos2023 = ThermoTransportDataReader(
    gas_name="H2", pressure_atm=1, source="Boulos2023"
)
data_N2_Boulos2023 = ThermoTransportDataReader(
    gas_name="N2", pressure_atm=1, source="Boulos2023"
)
data_O2_Boulos2023 = ThermoTransportDataReader(
    gas_name="O2", pressure_atm=1, source="Boulos2023"
)
data_Ar_Boulos2023 = ThermoTransportDataReader(
    gas_name="Ar", pressure_atm=1, source="Boulos2023"
)
data_He_Boulos2023 = ThermoTransportDataReader(
    gas_name="He", pressure_atm=1, source="Boulos2023"
)

datas = [
    data_H2_Boulos2023,
    data_N2_Boulos2023,
    data_O2_Boulos2023,
    data_Ar_Boulos2023,
    data_He_Boulos2023,
]

# Plot options for all the plots.
plot_options = [
    {"ls": "-", "lw": 4, "color": "black", "label": r"$\mathregular{H_2}$"},
    {"ls": "-", "lw": 3, "color": "red", "label": r"$\mathregular{N_2}$"},
    {"ls": "-", "lw": 2, "color": "blue", "label": r"$\mathregular{O_2}$"},
    {"ls": "-", "lw": 3, "color": "green", "label": r"$\mathregular{Ar}$"},
    {"ls": "-", "lw": 3, "color": "orange", "label": r"$\mathregular{He}$"},
]

# %%
# Plot all physical properties vs. temperature.
# ----------------------------------------------

physical_properties = ["rho", "cp", "h", "kappa", "sigma", "mu"]

for physical_property in physical_properties:
    fig, ax = plt.subplots(figsize=(12, 8), layout="constrained")

    for data, options in zip(datas, plot_options):
        data.plot(
            x="T",
            y=physical_property,
            fig_ax=(fig, ax),
            show=False,
            yscale="log",
            ax_title="1 atm, LTE, Boulos2023",
            **options,  # type: ignore
        )

    ax.legend()
    plt.show()

# %%
