With FiPy (Python library) I want to solve the coupled of pdes system shown below. The code below works, but doesn't give the correct solution.
p, q, r, s = 2, 1, 2, 0
Du, Dv = 0.0004, 0.04
mesh = Grid1D(nx=500, Lx=5.)
U = CellVariable(name = 'U',mesh=mesh, hasOld=True, value=1.)
V = CellVariable(name = 'V',mesh=mesh, hasOld=True, value=2.)
eqU = TransientTerm(var=U) == DiffusionTerm(coeff=Du, var=U) - U + (U**p)/(V**q)
eqV = TransientTerm(var=V) == DiffusionTerm(coeff=Dv, var=V) - V + (U**r)/(V**s)
viewerV = Viewer(vars=V)
viewerU = Viewer(vars=U)
timeStepDuration = 0.1
steps = 1000
eqn = eqU & eqV
for t in range(500):
U.updateOld()
V.updateOld()
eqn.solve(dt=1.e-3)
viewerV.plot()
viewerU.plot()
In line with some code I saw I also tried to replace the CellVariables with ImplicitSourceTerm, but this gives an error, since taking a ImplicitSourceTerm to the power p can't be done in this way. However I can't find any documentation on how it should be done:
eqU = TransientTerm(var=U) == DiffusionTerm(coeff=Du, var=U) - ImplicitSourceTerm(var=U) + ((ImplicitSourceTerm(var=U)**p)/(ImplicitSourceTerm(var=V)**q))
eqV = TransientTerm(var=V) == DiffusionTerm(coeff=Dv, var=V) - ImplicitSourceTerm(var=V) + ((ImplicitSourceTerm(var=U)**r)/(ImplicitSourceTerm(var=V)**s))
Trying to raise U.value**p also gives errors.