Setting initial H concentration

I’m afraid I’m a little confused again about sources and initial conditions. I can now use ‘sources’, that introduce some H/m3/s (so the total H continually increases throughout the simulation). I now want to put in just an amount of H in volume 1 at the start of the simulation (and see it migrate during the simulation til equilibrium is reached).
I’ve read everything on initial conditions:

My_model.initial_conditions = F. InitialCondition(Field=0, value =10)

But I can’t find an example of the syntax to make my model run with that initial condition, or how I can put H in solution initial values into the different volumes. Is that feasible, please?

Hi @HelenS!

You can set the initial concentration in a specific domain with sympy.Piecewise(...) function:

my_model.initial_conditions = [
    F.InitialCondition(field=0, value=10*sympy.Piecewise((1, F.x <= L), (0, True))),
]

where L is the length of the first domain, for example. See this topic for additional details.

Please, let me know if it is what you’ve asked about.

Hi @HelenS you can find a example in the pre-loaded slab verification case where the initial concentration in x=[0, 10] is set to 1 and then diffuses:

This is the part of the code for the initial condition:

initial_concentration = sp.Piecewise((C_0, F.x <= preloaded_length), (0, True))
model.initial_conditions = [
    F.InitialCondition(field="solute", value=initial_concentration)
]