def test_species_initial_condition_in_mixture():

    S1 = Species("S1")
    S2 = Species("S2")

    C = ChemicalComplex([S1, S2], name="C")
    S3 = C.get_species()

    mixture_name = "M"
    key1 = ParameterKey(mechanism="initial concentration",
                        part_id=mixture_name,
                        name=str(S1))
    key2 = ParameterKey(mechanism="initial concentration",
                        part_id=mixture_name,
                        name=C.name)

    M = Mixture(name=mixture_name,
                components=[C],
                parameters={
                    key1: 10,
                    key2: 2.2
                })

    #Initial condition found under the Species name
    assert parameter_to_value(M.get_initial_concentration(S1)[S1]) == 10

    #Initial condition defaults to 0
    assert parameter_to_value(M.get_initial_concentration(S2)[S2]) == 0

    #Initial condition found under the Component name
    assert parameter_to_value(M.get_initial_concentration(S3, C)[S3]) == 2.2
def test_species_initial_condition_defaulting():

    S1 = Species("S1")
    S2 = Species("S2")

    C = ChemicalComplex([S1, S2], name="C")
    S3 = C.get_species()

    mixture_name = "M"
    key1 = ParameterKey(mechanism="initial concentration",
                        part_id=mixture_name,
                        name=str(S1))
    key2 = ParameterKey(mechanism="initial concentration",
                        part_id=mixture_name,
                        name=str(S2))
    key3 = ParameterKey(mechanism="initial concentration",
                        part_id=mixture_name,
                        name=str(S3))

    C = ChemicalComplex([S1, S2],
                        name="C",
                        parameters={
                            key1: .11,
                            key2: .22
                        },
                        initial_concentration=.33)
    M = Mixture(name=mixture_name,
                components=[C],
                parameters={
                    key1: 1.1,
                    key2: 2.2,
                    key3: 3.3
                })

    #Initial condition found under the Species name, in the Component, not Mixture
    assert parameter_to_value(M.get_initial_concentration(S1, C)[S1]) == .11
    assert parameter_to_value(M.get_initial_concentration(S2, C)[S2]) == .22
    assert parameter_to_value(M.get_initial_concentration(S3, C)[S3]) == .33