Help with the biharmonic equation #2481
-
Hello Everyone, I manage to obtain a result but the boundary conditions are not correctly implemented. The boundary conditions are implemented via the penalty method. Could you please take a look at the enclosed code and tell me what is wrong? Sorry, I was not able to format the code correctly using the quotes. Thanks in advance for your help. from ast import Expression
from pyclbr import Function
import math
import sympy as sym
import matplotlib as plt
from matplotlib import pyplot
import numpy as np
from firedrake import *
mesh2 = RectangleMesh(100, 100, math.pi, 2.0)
f = Constant(0.1)
W = FunctionSpace(mesh2,"Argyris",5)
#W = FunctionSpace(mesh2,"Morley",2)
nu = FacetNormal(mesh2)
u_tr = TrialFunction(W)
u_test = TestFunction(W)
tgv=10000
a=inner(div(grad(u_tr)),div(grad(u_test)))*dx+tgv*inner(grad(u_tr),nu)*u_test*ds+tgv*u_tr*u_test*ds
L=f*u_test*dx
u=Function(W)
#bc = boundary_L(W, Constant(0), "on_boundary")
#bc = DirichletBC(W, Constant(0.0),"on_boundary")
solve(a == L, u)
File("helmholtz.pvd").write(u) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
I cut this back to remove all the unnecessary imports: from firedrake import *
mesh2 = RectangleMesh(100, 100, pi, 2.0)
f = Constant(0.1)
W = FunctionSpace(mesh2,"Argyris",5)
#W = FunctionSpace(mesh2,"Morley",2)
nu = FacetNormal(mesh2)
u_tr = TrialFunction(W)
u_test = TestFunction(W)
tgv=10000
a=inner(div(grad(u_tr)),div(grad(u_test)))*dx+tgv*inner(grad(u_tr),nu)*u_test*ds+tgv*u_tr*u_test*ds
L=f*u_test*dx
u=Function(W)
#bc = boundary_L(W, Constant(0), "on_boundary")
#bc = DirichletBC(W, Constant(0.0),"on_boundary")
solve(a == L, u)
File("helmholtz.pvd").write(u) It runs for me and the answer doesn't look obviously wrong. There is some error in achieving the boundary conditions but given that you have a uniform forcing function which will be pushing against the boundary conditions, I'm not sure this is obviously incorrect. This is the danger with trying to assess the correctness of a solution without an anaytic solution. I suggest you use the method of manufactured solutions (MMS) to create a forcing function for a solution which satisfies the equation and BCs. I might choose |
Beta Was this translation helpful? Give feedback.
-
@rckirby and @wence- have archived code for solving the biharmonic equation in a bunch of ways here: https://zenodo.org/record/3381901/files/code-data.tar.gz?download=1 (relevant links: https://arxiv.org/abs/1808.05513 , https://zenodo.org/record/3381901 ) |
Beta Was this translation helpful? Give feedback.
-
Thank you very much, @dham and @pefarrell , for your help. @dham : The theory of the biharmonic equation (cf., e.g., Section 6.8 of P. G. Ciarlet - Linear and Nonlinear Functional Analysis with Applications (2013)) states that under the sole assumption that the force is of class L^2, there exists a unique solution with Dirichlet and Neumann boundary conditions on the contour. Therefore, it should work. @pefarrell Thank you for the links. I have the folder with the code discussed in Kirby's paper. My idea is to extend the biharmonic equation code to a more complex one describing deformations in elasticity. Unfortunately, the code does not function well. When I tried to implement the boundary conditions of Dirichlet type in the standard way, I am prompted a message stating that this feature is not implemented yet and that I have to resort to the penalization machinery, that we saw is not exactly as precise as it ought to be. Any ideas to improve my code? |
Beta Was this translation helpful? Give feedback.
Thank you very much, @dham and @pefarrell , for your help.
@dham : The theory of the biharmonic equation (cf., e.g., Section 6.8 of P. G. Ciarlet - Linear and Nonlinear Functional Analysis with Applications (2013)) states that under the sole assumption that the force is of class L^2, there exists a unique solution with Dirichlet and Neumann boundary conditions on the contour. Therefore, it should work.
@pefarrell Thank you for the links. I have the folder with the code discussed in Kirby's paper. My idea is to extend the biharmonic equation code to a more complex one describing deformations in elasticity. Unfortunately, the code does not function well. When I tried to implement the bounda…