You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Gerardo Marx Chávez-Campos 7ddb278b10 Both models Working 2 years ago
solution Both models Working 2 years ago
.gitignore a small piece sourranded 2 years ago
Readme.md Both models Working 2 years ago
main.ipynb Both models Working 2 years ago
output_1_0.png a small piece sourranded 2 years ago
output_4_1.png a small piece sourranded 2 years ago
output_4_2.png a small piece sourranded 2 years ago
output_4_3.png a small piece sourranded 2 years ago
output_4_4.png a small piece sourranded 2 years ago
output_4_5.png a small piece sourranded 2 years ago
output_4_6.png a small piece sourranded 2 years ago
output_4_7.png a small piece sourranded 2 years ago
output_4_8.png a small piece sourranded 2 years ago
output_4_9.png a small piece sourranded 2 years ago
output_4_10.png a small piece sourranded 2 years ago
output_4_11.png a small piece sourranded 2 years ago
output_4_12.png a small piece sourranded 2 years ago
output_4_13.png a small piece sourranded 2 years ago
output_4_14.png a small piece sourranded 2 years ago
output_4_15.png a small piece sourranded 2 years ago
output_4_16.png a small piece sourranded 2 years ago
output_4_17.png a small piece sourranded 2 years ago
output_4_18.png a small piece sourranded 2 years ago
output_4_19.png a small piece sourranded 2 years ago
output_4_20.png a small piece sourranded 2 years ago
output_10_0.png Both models Working 2 years ago

Readme.md

#1 Loading functions  and modules
from fenics import *
import matplotlib.pyplot as plt
T = 0.1
num_steps = 20
dt = T/num_steps
rho = 7500
Cp = 500
k = 50
alpha = k/(rho*Cp)
#2 Create mesh and define function space
nx = 0.008
ny = 0.003
mesh = RectangleMesh(Point(0,0),Point(nx,ny),30, 30,'left')
V = FunctionSpace(mesh, 'Lagrange', 1) #Lagrange are triangular elements
plot(mesh)
plt.show()

png

# Boundary conditions
u0 = Constant(100)
def boundary(x, on_boundary):
    return on_boundary

bc = DirichletBC(V,u0, boundary)
u_n = project(1, V)
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(0.0)
F = u*v*dx + alpha*dt*dot(grad(u), grad(v))*dx-u_n*v*dx
a, L = lhs(F), rhs(F)
vtkfile = File('solution/solution.pvd')
u = Function(V)
t = 0
for n in range(num_steps):
    t += dt
    #u0.t = t
    solve(a == L, u, bc)
    #c = plot(u,)
    #plt.colorbar(c)
    #plt.show()
    ####
    vtkfile << (u, t)
    u_n.assign(u)
1E-13
1e-13
1e2
100.0
1E-13+1e2
100.0000000000001

Boundary conditions

#1 Loading functions  and modules
from fenics import *
import matplotlib.pyplot as plt
T = 4
num_steps = 200
dt = T/num_steps
rho = 7500
Cp = 500
k = 50
alpha = k/(rho*Cp)
#2 Create mesh and define function space
nx = 0.008
ny = 0.003
mesh = RectangleMesh(Point(0,0),Point(nx,ny),8, 8,'left')
V = FunctionSpace(mesh, 'Lagrange', 1) #Lagrange are triangular elements
plot(mesh)
plt.show()


png

#Boundary Conditions
tol = 1E-14

def BC1(x, on_boundary):
    return on_boundary and abs(x[0]-nx) < tol

def BC2(x, on_boundary):
    return on_boundary and abs(x[0]-0) < tol

bc1=DirichletBC(V,Constant(25),BC1)
bc2=DirichletBC(V,Constant(800),BC2)
bc=(bc1,bc2)
u_n = project(25, V)
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(0.0)
F = u*v*dx + alpha*dt*dot(grad(u), grad(v))*dx-u_n*v*dx
a, L = lhs(F), rhs(F)
vtkfile = File('solution/solution2.pvd')
u = Function(V)
t = 0
for n in range(num_steps):
    t += dt
    #u0.t = t
    solve(a == L, u, bc)
    vtkfile << (u, t)
    #c = plot(u,)
    #plt.colorbar(c)
    #plt.show()
    u_n.assign(u)