I have a problem with trying to use strang splitting with fipy to solve for stiff systems. Here is a sample code attached. At steady state I have balance issues. Would there be any problem with the implementation? Thanks.
import numpy
import scipy
import math
import fipy
def fun(t,u):
return 20.
nx=50
dx=0.02
u_b=1.
dt=dx/u_b*0.5
mesh=fipy.Grid1D(nx=nx,dx=dx)
X=mesh.cellCenters
u=fipy.CellVariable(mesh=mesh,name="Var",value=0.,hasOld=True)
u.constrain(1.,where=mesh.facesLeft)
u.faceGrad.constrain((0.,),where=mesh.facesRight)
eq=fipy.TransientTerm(var=u) == -fipy.ExponentialConvectionTerm(coeff=(u_b,),var=u)
time_steps=120
for i in range(0,time_steps):
eq.solve(dt=dt/2)
u.updateOld()
u_temp=u.value.copy()
result=scipy.integrate.solve_ivp(fun, [0,dt], u_temp)
for o in range(0,nx):
u.setValue(result.y[o][-1],where=((X>=o*dx) & (X<=(o+1)*dx)))
u.updateOld()
eq.solve(dt=dt/2)
u.updateOld()