from typing import OrderedDict


def secondary_settings(structure,form,primary_settings):
    """Return secondary settings, along with sensible default values.

    Secondary settings depend on the structure, form,
    and possibly primary setting values.
    Primary settings are defined by xrsdkit.definitions.structure_settings
    and xrsdkit.definitions.form_factor_settings.

    Parameters
    ----------
    structure : str
        Population structure designation, for fetching valid structure settings
    form : str
        Population form factor designation, for fetching valid form factor settings
    primary_settings : dict
        Dict of primary settings

    Returns
    -------
    sec_stgs : OrderedDict
        Dict of secondary settings along with sensible default values
    """
    sec_stgs = OrderedDict() 
    for stg_nm,stg_val in primary_settings.items():
        if stg_nm == 'n_atoms':
            for iat in range(stg_val):
                sec_stgs['symbol_{}'.format(iat)] = 'H'
        if stg_nm == 'integration_mode':
            if stg_val == 'spherical':
                sec_stgs['q_min'] = 0.
                sec_stgs['q_max'] = 1.
        if stg_nm == 'distribution' and form == 'spherical':
            if stg_val == 'r_normal':
                sec_stgs['sampling_width']=3.5
                sec_stgs['sampling_step']=0.05
    return sec_stgs