Replies: 1 comment 1 reply
-
I can reproduce the behavior and I think it is expected (and thus not a bug). You are correct that the Laplace operator applied to a linearly varying field should yield zero. However, at the boundary different values emerge since the boundary condition is applied there, too. This can be seen from the following evaluation of the laplacian alone: from pde.tools.expressions import evaluate
res = evaluate(f"laplace({cells})", {"u": state}, bc=[bc_x, bc_y, bc_z])
res.plot() In the plot, you can see that the term vanishes everywhere, except at the boundaries, where the boundary conditions result in non-zero values. You can define a special operator with different boundary conditions using the following trick: res2 = evaluate(
f"laplace_neumann({cells})",
{"u": state},
bc=[bc_x, bc_y, bc_z],
user_funcs={"laplace_neumann": grid.make_operator("laplace", "neumann")},
)
res2.plot() |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello. I am modeling a type of diffusion equation, and I have a spatially dependent concentration proportional to z, which has terms where it is operated on by a Laplacian or gradient operator. I would expect for the Laplacian operator that the term would go to zero, as a second derivative of z => 0; however, this is not the case and very different behavior occurs depending on whether the term is included or not (as shown below). The problem is defined with Dirichlet boundary conditions of 1 on all surfaces except for a subsection of the x=0,y=0 plane. I would appreciate guidance on the mathematical or coding issue going on here. Thanks.
This is the code with the term set to 0 explicitly.
This is the code with the function (cells = z/32) being operated on by the Laplacian, which I would expect to be identical to the above result. In actuality, very different behavior occurs.
Beta Was this translation helpful? Give feedback.
All reactions