def build_reagent_vectors(portion_reagents, portion_chemicals):
    """Write the reagents in a vector form, where the vectors live in the complete portion basis

    The basis is spanned by all chemicals in all reagents in the portion (sans solvent)

    :param portion_reagents: a list of all reagents in the portion
    :param portion_chemicals: a list of all chemical names in the poriton
    :param rdict:
    :return:
    """

    # find the vector representation of the reagents in concentration space
    reagent_vectors = {}
    if isinstance(portion_reagents, dict):
        portion_reagents = [v for v in portion_reagents.values()]

    for reagent in portion_reagents:
        name = 'Reagent{} (ul)'.format(reagent.name)
        comp_dict = reagent.component_dict
        vec = [comp_dict.get(elem, 0) for elem in portion_chemicals]
        reagent_vectors[name] = vec

    return reagent_vectors