Hello Everyone,
I would like to define Inital Conditions for a mixed Element Problem. I have found this post: https://fenicsproject.org/qa/13118/specifying-initial-values-for-mixed-vector-and-scalar-fields/
and tried to implement it in my Code, which runs without errors. But when I compare the results with the ones, were I dont have the Inital Conditions they are the same. (I used tkdiff and there was no singel diffrence in the files I looked at).
I would really appreciate it, if you could tell me what I did wrong.
Here is a running example: I hope its not to long
from fenics import *
import matplotlib.pyplot as pltElasticity parameters
E= 10010**6 # E in Pa
nu = 0.25 # Querkontraktionszahl
n_por = 0.01 # PorositÀt wird zu 0 gesetzt da sie bei ihnen garnicht erst vorkommt
k0= 110**(-14)
visk = 1 * 10**(-5)
k = k0/visk # PermeabilitÀt in m^4/Ns
b = 1 # Biot Koefficent
M = 10**14 # Biot Modul
F = 1000 # Kraft welche auf die Platte wirkt
a = 1 # LĂ€nge des Plattenabschnitts
G = Constant(E/(2*(1 + nu))) # Schubmodul
K = Constant((1+nu)/(3*(1-nu))2G*(1-nu)/(1-2nu))
B_big = Constant(bM/(K+pow(b,2)M))
nu_u = Constant((3nu+bB_big(1-2nu))/(3-bB_big*(1-2*nu)))Zeitvariablen
T = 1.0 # final time
num_steps = 1000 # number of time steps
dt = T / num_steps # time step size
#dt = 0.01Create mesh and define function space
nx0 = 0
ny0 = 0
nx1 = 1
ny1 = 1mesh = RectangleMesh(Point(nx0, ny0), Point(nx1, ny1), 30,30)
P2 = VectorElement(âLagrangeâ, mesh.ufl_cell(), 2) # fĂŒr die Verschiebung quadratisch
P1 = FiniteElement(âLagrangeâ, mesh.ufl_cell(), 1) # fĂŒr den Druck linearMake a mixed space V.sub(0)- FiniteElement
V.sub(1) - VectorElement
TH = P2 * P1
V = FunctionSpace(mesh, TH)Mark boundary subdomians
class rechts(SubDomain):
def inside(self, x, on_boundary):
tol = 1E-14
return on_boundary and near(x[0],1,tol)
class links(SubDomain):
def inside(self, x, on_boundary):
tol = 1E-14
return on_boundary and near(x[0],0,tol)
class oben(SubDomain):
def inside(self, x, on_boundary):
tol = 1E-14
return on_boundary and near(x[1],1,tol)
class unten(SubDomain):
def inside(self, x, on_boundary):
tol = 1E-14
return on_boundary and near(x[1],0,tol)right = rechts()
left = links()
top = oben()
bottom = unten()boundaries = MeshFunction(âsize_tâ,mesh,mesh.topology().dim()-1)
boundaries.set_all(0)left.mark(boundaries,1)
right.mark(boundaries,2)
top.mark(boundaries,3)
bottom.mark(boundaries,4)Define functions
(u, p) = TrialFunctions(V)
(v, r) = TestFunctions(V)
du = Function(V)
u0, p0 = split(du)Define Constants
n = FacetNormal(mesh)
n_por = Constant(n_por) # PorositÀt
k = Constant(k) # PermeabilitÀt
nu = Constant(nu) # Querkontraktionszahl
b = Constant(b)
M = Constant(M)
F = Constant(F)
a = Constant(a)
mu = Constant(E/(2*(1 + nu)))
lam = Constant(E * nu/( (1+nu)(1-2 nu)))Fluidfluss am Rand
q = 0 # -q_vektor*n= q
Kinematics
d = u.geometric_dimension()
I = Identity(d) # Identity tensorlinearer Spannungstensor
def epsilon(u):
return 0.5*(nabla_grad(u) + nabla_grad(u).T)
return sym(nabla_grad(u))
Spur des Spannungstensors
def tr_epsilon(u):
return tr(epsilon(u))lineare Festkörperspannung
def sigma_s(u):
return lam* tr_epsilon(u)* Identity(d) + 2* mu * epsilon(u)Spannungstensor aus Festkörper und Fluidanteil
def sigma(u,p):
return (1-n_por) * sigma_s(u) -n_por* p*Ids_test = ds(domain=mesh, subdomain_data=boundaries)
Impulsbilanz + Darcy und Fluidmassenbilanz
T1 = Expression((â1000â, â0â),degree =2)
T2 = Expression((â-1000â, â0â),degree =2)Imp =inner(sigma(u,p),nabla_grad(v)) * dx -inner(T1,v) * ds_test(3) -inner(T2,v) * ds_test(4)
Fl = qrds_test(3) +qrds_test(4) - k * inner(nabla_grad( p ),nabla_grad( r )) * dx -
(tr_epsilon(u) - tr_epsilon(u0))/dt *r *dxeqn = Imp + Fl
Fluid +Verschiebungsrandbedingung - free-slip BC
bcu_B = DirichletBC(V.sub(0).sub(1), Constant((0)), bottom)
bcu_L = DirichletBC(V.sub(0).sub(0), Constant((0)), left)
bcp_R = DirichletBC(V.sub(1), Constant((0)), right) >
bc_ges = [bcu_L, bcu_B, bcp_R]Initial Conditions:
e_p0 = Expression(â1/(3a) * B_big * (1+nu_u) * Fâ, degree =2, F=F, a=a, B_big=B_big,nu_u=nu_u)
e_u0 = Expression(('(Fnu_u/(2*G))x[0]/aâ , '-F(1-2 * nu_u)/(2 * G) * (x[1]/a)â), degree =2, F=F, a=a, G=G ,nu_u=nu_u)p_0 = interpolate(e_p0, V.sub(1).collapse())
u_0 = interpolate(e_u0, V.sub(0).collapse())
w = Function(V)
assign(w, [u_0, p_0])Aufteilen der Gleichung in linke und rechte Seite
l = lhs(eqn)
r = rhs(eqn)Solve variational problem
Step in time
t = 0
for n in range(num_steps):
# Update current time
t += dt
solve(l == r, w, bc_ges) (u,p) = w.split(True) assign(du.sub(0), u)