Please help, I want to change my f expression into a different equation I don’t know how…
Currently the f expression is
f = Expression(“x[2] > w && (x[0] < w || x[0] > X-w || x[1] < w || x[1] > Y-w) ? q / k : 0.0”, w=wf, X=R_radius, Y=R_radius, q=q0, k=k_Al, degree=2)
Here is the code
from dolfin import *
from mshr import *
C0_K = 273.15
T0 = 305.0
T_cool = C0_K
# K
T_air = 300.0
# W/m^3
q0 = 15
# W/m/K
k_Al = 205.0
# W/ m^2 /K
h_air = 12.12
# m
#L=16
#xmax=12
#ymax=12
#wf=0.01
L =0.15
R_radius=0.06
#ymax = 0.06
wf=0.01
#Making a cylindrical geometry 10 cm radius and 15 cm height in S.I
c1 = Cylinder(Point(0.0,0.0,0.0),Point(0.0,0.0,L),R_radius,R_radius)
geometry = c1
mesh = generate_mesh(geometry, 50)
V = FunctionSpace(mesh, "Lagrange", 1)
# Define Dirichlet boundary (x = 0 or x = 1)
def boundary(x):
return x[2] < DOLFIN_EPS
# Define boundary condition
uC = Constant(T_cool)
bc = DirichletBC(V, uC, boundary)
# Define variational problem
#u0 = project(Constant(T0),V)
u = TrialFunction(V)
v = TestFunction(V)
f = Expression("x[2] > w && (x[0] < w || x[0] > X-w || x[1] < w || x[1] > Y-w) ? q / k : 0.0", w=wf, X=R_radius, Y=R_radius, q=q0, k=k_Al, degree=2)
g = Expression(" h * (t0 - ta)", k=k_Al, tc= T_cool,h=h_air, t0=T0, ta=T_air, degree=2)
a = inner(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds
# Compute solution
u = Function(V)
solve(a == L, u, bc)
nsteps=1
for i in range(nsteps):
u1 = u.copy()
g1 = Expression(" h * (uu - ta)", uu=u1,k=k_Al, tc= T_cool,h=h_air, t0=T0, ta=T_air, degree=2)
solve(a == L, u, bc)
# Save solution in VTK format
file = File("neumann_poisson.pvd")
file << u
# Plot solution
#import matplotlib.pyplot as plt
#plot(u)
#plt.show()