I am looking for an efficient way to solve multiple equations at once from python. I want to solve
$$ \frac{dI(x,E)}{dx} + \alpha(E)I(x,E) = 0 $$
For a given E, I can solve it easily like with the code snippet below. My problem is that if I want to solve it for several E's I need a for loop which is very inefficient in python. The solution I am after can be written as
$$ I(x) = \int{ I(x,E)dE } $$
Any idea would be appreciated.
from dolfin import *
m1 = IntervalMesh(10,0.0, 1.0)
Q1 = FunctionSpace(m1,'CG',1)
v1 = TestFunction(Q1)
du1 = TrialFunction(Q1)
dx = Measure('dx')
def inside_left_m1(x, on_boundary):
return near(x[0],0.0)
left_m1_domain = AutoSubDomain(inside_function=inside_left_m1)
left_m1_bc = DirichletBC(Q1,1.0,left_m1_domain)
alpha = Constant(1.0)
F = du1.dx(0)*v1 + alpha(1.0)*du1*v1
F *= dx
a = lhs(F)
L = rhs(F)
u1 = Function(Q1)
parameters = LinearVariationalSolver.default_parameters()
parameters['linear_solver'] = 'lu'
solve(a == L, u1, [left_m1_bc,],
solver_parameters=parameters)
plot(u1)