Browse Source

a small piece sourranded

master
parent
commit
c3da27b4a5
25 changed files with 398 additions and 294 deletions
  1. +1
    -0
      .gitignore
  2. +0
    -264
      .ipynb_checkpoints/main-checkpoint.ipynb
  3. +206
    -30
      main.ipynb
  4. +191
    -0
      main.md
  5. BIN
      output_1_0.png
  6. BIN
      output_4_1.png
  7. BIN
      output_4_10.png
  8. BIN
      output_4_11.png
  9. BIN
      output_4_12.png
  10. BIN
      output_4_13.png
  11. BIN
      output_4_14.png
  12. BIN
      output_4_15.png
  13. BIN
      output_4_16.png
  14. BIN
      output_4_17.png
  15. BIN
      output_4_18.png
  16. BIN
      output_4_19.png
  17. BIN
      output_4_2.png
  18. BIN
      output_4_20.png
  19. BIN
      output_4_3.png
  20. BIN
      output_4_4.png
  21. BIN
      output_4_5.png
  22. BIN
      output_4_6.png
  23. BIN
      output_4_7.png
  24. BIN
      output_4_8.png
  25. BIN
      output_4_9.png

+ 1
- 0
.gitignore View File

@ -0,0 +1 @@
.ipynb_checkpoints

+ 0
- 264
.ipynb_checkpoints/main-checkpoint.ipynb
File diff suppressed because it is too large
View File


+ 206
- 30
main.ipynb
File diff suppressed because it is too large
View File


+ 191
- 0
main.md View File

@ -0,0 +1,191 @@
```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()
```
![png](output_1_0.png)
```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.
![png](output_4_1.png)
![png](output_4_2.png)
![png](output_4_3.png)
![png](output_4_4.png)
![png](output_4_5.png)
![png](output_4_6.png)
![png](output_4_7.png)
![png](output_4_8.png)
![png](output_4_9.png)
![png](output_4_10.png)
![png](output_4_11.png)
![png](output_4_12.png)
![png](output_4_13.png)
![png](output_4_14.png)
![png](output_4_15.png)
![png](output_4_16.png)
![png](output_4_17.png)
![png](output_4_18.png)
![png](output_4_19.png)
![png](output_4_20.png)
```python
1E-7
```
1e-07
```python
1e2
```
100.0
```python
1E-7+1e2
```
100.0000001
```python
```

BIN
output_1_0.png View File

Before After
Width: 388  |  Height: 160  |  Size: 46 KiB

BIN
output_4_1.png View File

Before After
Width: 364  |  Height: 241  |  Size: 11 KiB

BIN
output_4_10.png View File

Before After
Width: 393  |  Height: 248  |  Size: 15 KiB

BIN
output_4_11.png View File

Before After
Width: 393  |  Height: 248  |  Size: 15 KiB

BIN
output_4_12.png View File

Before After
Width: 393  |  Height: 248  |  Size: 16 KiB

BIN
output_4_13.png View File

Before After
Width: 399  |  Height: 248  |  Size: 14 KiB

BIN
output_4_14.png View File

Before After
Width: 393  |  Height: 248  |  Size: 15 KiB

BIN
output_4_15.png View File

Before After
Width: 399  |  Height: 248  |  Size: 15 KiB

BIN
output_4_16.png View File

Before After
Width: 399  |  Height: 248  |  Size: 16 KiB

BIN
output_4_17.png View File

Before After
Width: 399  |  Height: 248  |  Size: 15 KiB

BIN
output_4_18.png View File

Before After
Width: 405  |  Height: 248  |  Size: 16 KiB

BIN
output_4_19.png View File

Before After
Width: 420  |  Height: 248  |  Size: 16 KiB

BIN
output_4_2.png View File

Before After
Width: 380  |  Height: 241  |  Size: 14 KiB

BIN
output_4_20.png View File

Before After
Width: 376  |  Height: 248  |  Size: 13 KiB

BIN
output_4_3.png View File

Before After
Width: 371  |  Height: 241  |  Size: 13 KiB

BIN
output_4_4.png View File

Before After
Width: 380  |  Height: 241  |  Size: 15 KiB

BIN
output_4_5.png View File

Before After
Width: 380  |  Height: 241  |  Size: 15 KiB

BIN
output_4_6.png View File

Before After
Width: 387  |  Height: 241  |  Size: 14 KiB

BIN
output_4_7.png View File

Before After
Width: 387  |  Height: 241  |  Size: 16 KiB

BIN
output_4_8.png View File

Before After
Width: 393  |  Height: 241  |  Size: 16 KiB

BIN
output_4_9.png View File

Before After
Width: 393  |  Height: 241  |  Size: 16 KiB

Loading…
Cancel
Save