 # How to solve ODE in FEniCS?

Hi everyone,

I am trying to solve a set of PDEs coupled with one ODE. I was able to solve the system of PDEs assuming the variable defined by the ODE stays constant. However, when I try to add the ODE, I am getting a syntax error. To reproduce the error, I have added a minimal script to just solve the ODE. I tried to follow the example in the post Can one solve system of ODE with fenics?. But I get a syntax error for my problem. Here is a minimal code.

``````from fenics import *
mesh = IntervalMesh(200, 0, 2)
V = FunctionSpace(mesh,'CG',1)
v = TestFunctions(V)
u = Function(V)

dp = Constant(0.002)         # Diameter of catalyst particle m
eps = Constant(0.40)         # epsilon
muf = Constant(3.78E-5)    # Average viscosity of gas, Pa.s
rof = Constant(1565.85)  # Average density

Vz_in = Constant(1.0)        # Inlet superficial velocity m/s
P_in = 5.0E+5   # Inlet Pressure Pa

bc = DirichletBC(V,P_in,'near(x, 0)')

F_P = u.dx(0)*v*dx + (150*(1-eps)**2*muf/(dp**2*eps**3))*Vz_in*v*dx + \
1.75*(1-eps)*rof*1e-3*Vz_in**2/(dp*eps**3)*v*dx
``````

``````TypeError                                 Traceback (most recent call last)
<ipython-input-19-399fb5bf64b8> in <module>
----> 1 F_P = u.dx(0)*v*dx + (150*(1-eps)**2*muf/(dp**2*eps**3))*Vz_in*v*dx + \
2       1.75*(1-eps)*rof*1e-3*Vz_in**2/(dp*eps**3)*v*dx

TypeError: can't multiply sequence by non-int of type 'Indexed'
``````

Thank you.

Thanks Dokken. I was not aware of the text encapsulation. Formatted the code for better readability.

Looks like you have a typo:

``````TestFunctions(V)
``````

which gives you a list of test functions should probably be

``````TestFunction(V)
``````

which is the single test function associated with V^h.

Thank you. It was an overlook on my part. It resolved my problem.