|
|
-
-
- ```python
- #1 Loading functions and modules
- from fenics import *
- import matplotlib.pyplot as plt
- T = 2.0
- num_steps = 20
- dt = T/num_steps
- rho = 7500
- Cp = 500
- k = 50
- alpha = k/(rho*Cp)
- ```
-
-
- ```python
- #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()
-
- ```
-
-
- 
-
-
-
- ```python
- # Boundary conditions
- u0 = Constant(100)
- def boundary(x, on_boundary):
- return on_boundary
-
- bc = DirichletBC(V,u0, boundary)
- ```
-
-
- ```python
- 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)
- ```
-
- Calling FFC just-in-time (JIT) compiler, this may take some time.
-
-
-
- ```python
- 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()
- u_n.assign(u)
- ```
-
- Calling FFC just-in-time (JIT) compiler, this may take some time.
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- 
-
-
-
- ```python
- 1E-7
- ```
-
-
-
-
- 1e-07
-
-
-
-
- ```python
- 1e2
- ```
-
-
-
-
- 100.0
-
-
-
-
- ```python
- 1E-7+1e2
- ```
-
-
-
-
- 100.0000001
-
-
-
-
- ```python
-
- ```
|