I am attempting to solve two coupled 1D advection-dispersion-reaction equations:
∂[CO2]/∂t = -v∂[CO2] + D∂^2[CO2]/dx^2 - k([CO2]air - [CO2]w) - alpha([Ca2+]eq - [Ca2+]),
and
∂[Ca2+]/∂t = -v∂[Ca2+] + D∂^2[Ca2+]/dx^2 + alpha([Ca2+]eq - [Ca2+]),
where v, k, and alpha are constants.
The equilibrium concentration of Ca2+ ([Ca2+]Eq) depends non-linearly on [CO2]. To incorporate this into my equation I've created a CellVariable CaEq. The equations are then:
CO2Eqn = TransientTerm(var=CO2) == ConvectionTerm(coeff=-v, var=CO2) + \
DiffusionTerm(coeff=D_L, var=CO2) - \
k*ConcCO2Air + ImplicitSourceTerm(coeff=k, var=CO2) - \
alpha*CaEq + \
ImplicitSourceTerm(coeff=alpha, var=Ca)
CaEqn = TransientTerm(var=Ca) == ConvectionTerm(coeff=-v, var=Ca) +\
DiffusionTerm(coeff=D_L, var=CO2) + \
alpha*CaEq - \
ImplicitSourceTerm(coeff=alpha, var=Ca)
eqn = CO2Eqn & CaEqn
and I am calculating CaEq by:
CaEq.setValue(concCaEqFromPCO2(numerix.array(pConc(CO2)), T_C)).
The function concCaEqFromPCO2 finds [Ca2+]Eq from [CO2] and temperature via root finding.
When I run the solver it errors with: The coefficient must be a vector value. This occurs when v is set to an integer. When I set it to a tuple a different error arises on the line with alpha*CaEq: bad operand for unary -: 'tuple'.
Is there a way to resolve this? Or, more generally, is there a simple way to incorporate a non-linear dependence on one of the variables?