import textwrap


def _params_string(pm):
    """
    Print parameters defined in the parameters module.
    """
    sp = ', '.join(pm.gas['sp'])
    x = ', '.join([str(gx) for gx in pm.gas['x']])
    w = 12  # width specifier

    pm_string = f"""
    {pm.case['case_system']}
    {pm.case['case_reactor']}
    Case {pm.case['case_num']} - {pm.case['case_desc']}

    {'*':*^40}
    {'Parameters':^40}
    {'*':*^40}

    {' Bed Particle ':-^40}\n
    {pm.bed['sample_desc']:<{w}}
    {pm.bed['sample_id']:<{w}}\n
    {'dp':<{w}} {pm.bed['dp']:<{w}} Mean particle diameter [m]
    {'dp_min':<{w}} {pm.bed['dp_min']:<{w}} Minimum particle diameter [m]
    {'dp_max':<{w}} {pm.bed['dp_max']:<{w}} Maximum particle diameter [m]
    {'phi':<{w}} {pm.bed['phi']:<{w}} Sphericity [-]
    {'rho':<{w}} {pm.bed['rho']:<{w}} Density [kg/m³]

    {' Biomass Particle ':-^40}\n
    {pm.biomass['sample_desc']:<{w}}
    {pm.biomass['sample_id']:<{w}}\n
    {'dp':<{w}} {pm.biomass['dp']:<{w}} Mean particle diameter [m]
    {'phi':<{w}} {pm.biomass['phi']:<{w}} Particle sphericity [-]
    {'rho':<{w}} {pm.biomass['rho']:<{w}} Density of loblolly pine [kg/m³]
    {'b':<{w}} {pm.biomass['b']:<{w}} Shape factor for particle transient heat conduction[-]
    {'h':<{w}} {pm.biomass['h']:<{w}} Heat transfer coefficient for convection [W/m²K]
    {'k':<{w}} {pm.biomass['k']:<{w}} Thermal conductivity of loblolly pine [W/mK]
    {'m':<{w}} {pm.biomass['m']:<{w}} Number of nodes from particle center (m=0) to surface (m)
    {'mc':<{w}} {pm.biomass['mc']:<{w}} Moisture content [%]
    {'nt':<{w}} {pm.biomass['nt']:<{w}} Number of time steps for particle temperature profile [-]
    {'tki':<{w}} {pm.biomass['tk_init']:<{w}} Initial particle temperature [K]
    {'t_max':<{w}} {pm.biomass['t_max']:<{w}} Time duration to calculate particle temperature profile [s]

    {' Gas Properties ':-^40}\n
    {'sp':<{w}} {sp:<{w}} Components of gas mixture [-]
    {'x':<{w}} {x:<{w}} Mole fractions of components in gas mixture [-]
    {'p':<{w}} {pm.gas['p']:<{w},} Gas pressure in reactor [Pa]
    {'tk':<{w}} {pm.gas['tk']:<{w}} Gas temperature in reactor [K]

    {' Reactor Geometry and Conditions ':-^40}\n
    {'di':<{w}} {pm.reactor['di']:<{w}} Inner diameter of reactor [m]
    {'ep':<{w}} {pm.reactor['ep']:<{w}} Void fraction of bed [-]
    {'ht':<{w}} {pm.reactor['ht']:<{w}} Total height of reactor [m]
    {'q':<{w}} {pm.reactor['q']:<{w}} Volumetric flowrate of gas into reactor [SLM]
    {'zmf':<{w}} {pm.reactor['zmf']:<{w}} Bed height at minimum fluidization [m]
    """
    return textwrap.dedent(pm_string)