VariationalProblem(J, F, bc, nonlinear=True) do not work
The test program nlPoisson_vp2.py do not work. I got the following error message
Traceback (most recent call last):
File "nlPoisson_vp2.py", line 55, in <module>
problem = VariationalProb
TypeError: __init__() got an unexpected keyword argument 'nonlinear'
I am using Ubuntu 10.10, python 2.6.6 and dolfin 0.9.10
On a different computer, using Ubuntu 10.04, python 2.6.5 and dolfin 0.9.9, this test program worked perfectly fine.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Johan Hake
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Anne,
I think you should remove the nonlinear keyword.
Kent
On 3 May 2011 16:23, Anne Kværnø <email address hidden>wrote:
> New question #155708 on DOLFIN:
> https:/
>
> The test program nlPoisson_vp2.py do not work. I got the following error
> message
>
> Traceback (most recent call last):
> File "nlPoisson_vp2.py", line 55, in <module>
> problem = VariationalProb
> TypeError: __init__() got an unexpected keyword argument 'nonlinear'
>
> I am using Ubuntu 10.10, python 2.6.6 and dolfin 0.9.10
>
> On a different computer, using Ubuntu 10.04, python 2.6.5 and dolfin 0.9.9,
> this test program worked perfectly fine.
>
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
>
Revision history for this message
|
#2 |
On Tuesday May 3 2011 07:23:20 Anne Kværnø wrote:
> New question #155708 on DOLFIN:
> https:/
>
> The test program nlPoisson_vp2.py do not work. I got the following error
> message
>
> Traceback (most recent call last):
> File "nlPoisson_vp2.py", line 55, in <module>
> problem = VariationalProb
> TypeError: __init__() got an unexpected keyword argument 'nonlinear'
>
> I am using Ubuntu 10.10, python 2.6.6 and dolfin 0.9.10
>
> On a different computer, using Ubuntu 10.04, python 2.6.5 and dolfin 0.9.9,
> this test program worked perfectly fine.
The interface to a nonlinear VariationalProblem changed between these two
releases. Take a look at the docstring of VariationalProblem.
In essence: Just change the order of the forms. Put the nonlinear (linear in
the test function) form first, and the linearised Jacobian as the second form.
Then will the VariationalProblem be interpreted as a Nonlinear problem. Also
skip the "nonlinear" argument.
If you ask me, I think this change is abit too magic and it is not clear at
all that this is what to do ;)
Johan
Revision history for this message
|
#3 |
On 03/05/11 17:15, Johan Hake wrote:
> Question #155708 on DOLFIN changed:
> https:/
>
> Johan Hake proposed the following answer:
> On Tuesday May 3 2011 07:23:20 Anne Kværnø wrote:
>> New question #155708 on DOLFIN:
>> https:/
>>
>> The test program nlPoisson_vp2.py do not work. I got the following error
>> message
>>
>> Traceback (most recent call last):
>> File "nlPoisson_vp2.py", line 55, in <module>
>> problem = VariationalProb
>> TypeError: __init__() got an unexpected keyword argument 'nonlinear'
>>
>> I am using Ubuntu 10.10, python 2.6.6 and dolfin 0.9.10
>>
>> On a different computer, using Ubuntu 10.04, python 2.6.5 and dolfin 0.9.9,
>> this test program worked perfectly fine.
>
> The interface to a nonlinear VariationalProblem changed between these two
> releases. Take a look at the docstring of VariationalProblem.
>
> In essence: Just change the order of the forms. Put the nonlinear (linear in
> the test function) form first, and the linearised Jacobian as the second form.
> Then will the VariationalProblem be interpreted as a Nonlinear problem. Also
> skip the "nonlinear" argument.
>
> If you ask me, I think this change is abit too magic and it is not clear at
> all that this is what to do ;)
>
I agree. I think that it's very unclear.
Why not just have
LinearVaria
and
NonlinearVa
They could share common code behind the scenes.
Garth
> Johan
>
Revision history for this message
|
#4 |
After reading Johan's post I was able to get past the nonlinear problem but now my program crashes. Could anyone help me with this?
Here is my program:
#!/usr/bin/python
from dolfin import *
import numpy, sys
# MESHING
mesh = Rectangle(0.0, -0.5, 1.0, 0.5, 10, 10, "right/left")
# FUNCTION SPACE
scalar = FunctionSpace(mesh, "CG", 1) #Pressure
vector = VectorFunctionS
system = vector * scalar #Mixed Function Space
# BOUNDARIES
right = compile_
left = compile_
top = compile_
bottom = compile_
# INFLOW VELOCITY BC FOR TOP
bc1 = DirichletBC(
# NO-SLIP BC FOR TOP-BOTTOM
noslip = Constant((0.0, 0.0))
bc0 = DirichletBC(
bc3 = DirichletBC(
bc2 = DirichletBC(
# STORAGE OF BCs
bcs = [bc1, bc2, bc0, bc3]
# VARIATIONAL PROBLEM
ts = TestFunction(
ds = TrialFunction(
s = Function(system)
v, q = split(ts)
dv, dq = split(ds)
u , p = split(s)
f = Constant((0, 0))
nu = 0.001
#F = (nu*inner(grad(v), grad(u)) - div(v)*p + q*div(u) - inner(v,f))*dx # Stokes
F = (nu*inner(grad(v), grad(u)) - div(v)*p + q*div(u) + inner(dot(
J = derivative(F,s,ds)
# SET UP PDE
problem = VariationalProb
#problem.
# SOLVE PDE
(U, P) = problem.
# FILES FOR PARAVIEW
ufile_pvd = File("velocity.
ufile_pvd << U
pfile_pvd = File("pressure.
pfile_pvd << P
# PLOTS
plot(U)
plot(P)
interactive()
Revision history for this message
|
#5 |
On 03/05/11 17:12, Kent-Andre Mardal wrote:
>
> Anne,
>
> I think you should remove the nonlinear keyword.
>
This change will make the code work, but it will produce an incorrect
result. DOLFIN will assume that the equation is linear, based on the
order of J and F (which as I've already posted I think is bad).
Garth
> Kent
>
> On 3 May 2011 16:23, Anne Kværnø <<email address hidden>
> <mailto:<email address hidden>>> wrote:
>
> New question #155708 on DOLFIN:
> https:/
>
> The test program nlPoisson_vp2.py do not work. I got the following
> error message
>
> Traceback (most recent call last):
> File "nlPoisson_vp2.py", line 55, in <module>
> problem = VariationalProb
> TypeError: __init__() got an unexpected keyword argument 'nonlinear'
>
> I am using Ubuntu 10.10, python 2.6.6 and dolfin 0.9.10
>
> On a different computer, using Ubuntu 10.04, python 2.6.5 and dolfin
> 0.9.9, this test program worked perfectly fine.
>
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
> _______
> Mailing list: https:/
> <https:/
> Post to : <email address hidden>
> <mailto:<email address hidden>>
> Unsubscribe : https:/
> <https:/
> More help : https:/
>
>
>
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
Revision history for this message
|
#6 |
Kyle,
you will get faster answers if you post
the error messages you get in addition
to the program. :)
Martin
On 3 May 2011 18:27, Kyle <email address hidden> wrote:
> Question #155708 on DOLFIN changed:
> https:/
>
> Kyle requested more information:
> After reading Johan's post I was able to get past the nonlinear problem
> but now my program crashes. Could anyone help me with this?
>
> Here is my program:
>
> #!/usr/bin/python
>
> from dolfin import *
> import numpy, sys
>
> # MESHING
> mesh = Rectangle(0.0, -0.5, 1.0, 0.5, 10, 10, "right/left")
>
> # FUNCTION SPACE
> scalar = FunctionSpace(mesh, "CG", 1) #Pressure
> vector = VectorFunctionS
> system = vector * scalar #Mixed Function Space
>
> # BOUNDARIES
> right = compile_
> left = compile_
> top = compile_
> bottom = compile_
>
> # INFLOW VELOCITY BC FOR TOP
> bc1 = DirichletBC(
>
> # NO-SLIP BC FOR TOP-BOTTOM
> noslip = Constant((0.0, 0.0))
> bc0 = DirichletBC(
> bc3 = DirichletBC(
> bc2 = DirichletBC(
>
> # STORAGE OF BCs
> bcs = [bc1, bc2, bc0, bc3]
>
> # VARIATIONAL PROBLEM
> ts = TestFunction(
> ds = TrialFunction(
> s = Function(system)
>
> v, q = split(ts)
> dv, dq = split(ds)
> u , p = split(s)
>
> f = Constant((0, 0))
> nu = 0.001
>
> #F = (nu*inner(grad(v), grad(u)) - div(v)*p + q*div(u) - inner(v,f))*dx # Stokes
> F = (nu*inner(grad(v), grad(u)) - div(v)*p + q*div(u) + inner(dot(
> J = derivative(F,s,ds)
>
> # SET UP PDE
> problem = VariationalProb
> #problem.
>
> # SOLVE PDE
> (U, P) = problem.
>
> # FILES FOR PARAVIEW
> ufile_pvd = File("velocity.
> ufile_pvd << U
> pfile_pvd = File("pressure.
> pfile_pvd << P
>
> # PLOTS
> plot(U)
> plot(P)
> interactive()
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
>
Revision history for this message
|
#7 |
Thanks Johan Hake, that solved my question.
Revision history for this message
|
#8 |
Thanks, this solved the problem.