Initial conditions
Minor problem with initial conditions: I am supposed to use the q0 dictionary but I am not sure if I am doing it correctly. The initial conditions __init__ is called, I know that much, but the value of u_1 is never set. I am sure I am doing this wrong as it does work in the CahnHilliard example. Any idea what I am doing wrong?
from cbc.pdesys import *
mesh = UnitSquare(10, 10)
# setup the problem parameters
problem_
problem = Problem(mesh, problem_parameters)
# setup the solver parameters
solver_
solver_
# setup the pdesystem
poisson = PDESystem([['u']], problem, solver_parameters) # Creates FunctionSpace, Functions etc.
class Poisson(
def form(self, u, v_u, u_, u_1, dt, **kwargs): # v_u is the TestFunction
return inner(grad(u), grad(v_u))*dx + 1.0/dt*u*v_u*dx -1.0/dt*u_1*v_u*dx
bcs = DirichletBC(
# add the pdesubsystem
poisson.
# Initial conditions setup
class InitialConditio
def __init__(self):
print "initialized initial conditions"
def eval(self, values, x):
values = Expression(
def value_shape(self):
return (1,)
problem.q0 = {'u':InitialCon
def update(self):
plot(
Problem.update = update
problem.prm['T'] = 0.3
problem.solve()
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- CBC.PDESys Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Mikael Mortensen
- Solved:
- Last query:
- Last reply: