1 |
""" |
2 |
Author: Lutz Gross, l.gross@uq.edu.au |
3 |
Author: John Ngui, john.ngui@uq.edu.au |
4 |
""" |
5 |
|
6 |
# Import the necessary modules. |
7 |
from esys.escript import * |
8 |
from esys.escript.linearPDEs import LinearPDE |
9 |
from esys.finley import Rectangle |
10 |
from esys.pyvisi import Scene, DataCollector, Map, Camera |
11 |
from esys.pyvisi.constant import * |
12 |
import os |
13 |
|
14 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
15 |
X_SIZE = 400 |
16 |
Y_SIZE = 400 |
17 |
JPG_RENDERER = Renderer.ONLINE_JPG |
18 |
|
19 |
#... set some parameters ... |
20 |
xc=[0.02,0.002] |
21 |
r=0.001 |
22 |
qc=50.e6 |
23 |
Tref=0. |
24 |
rhocp=2.6e6 |
25 |
eta=75. |
26 |
kappa=240. |
27 |
tend=5. |
28 |
# ... time, time step size and counter ... |
29 |
t=0 |
30 |
h=0.1 |
31 |
i=0 |
32 |
|
33 |
#... generate domain ... |
34 |
mydomain = Rectangle(l0=0.05,l1=0.01,n0=250, n1=50) |
35 |
#... open PDE ... |
36 |
mypde=LinearPDE(mydomain) |
37 |
mypde.setSymmetryOn() |
38 |
mypde.setValue(A=kappa*kronecker(mydomain),D=rhocp/h,d=eta,y=eta*Tref) |
39 |
# ... set heat source: .... |
40 |
x=mydomain.getX() |
41 |
qH=qc*whereNegative(length(x-xc)-r) |
42 |
# ... set initial temperature .... |
43 |
T=Tref |
44 |
|
45 |
# Create a Scene. |
46 |
s = Scene(renderer = JPG_RENDERER, x_size = X_SIZE, y_size = Y_SIZE) |
47 |
|
48 |
# Create a DataCollector reading directly from escript objects. |
49 |
dc = DataCollector(source = Source.ESCRIPT) |
50 |
|
51 |
# Create a Map. |
52 |
m = Map(scene = s, data_collector = dc, \ |
53 |
viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, \ |
54 |
cell_to_point = False, outline = True) |
55 |
|
56 |
# Create a Camera. |
57 |
c = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
58 |
|
59 |
# ... start iteration: |
60 |
while t<0.4: |
61 |
i+=1 |
62 |
t+=h |
63 |
mypde.setValue(Y=qH+rhocp/h*T) |
64 |
T=mypde.getSolution() |
65 |
|
66 |
dc.setData(temp = T) |
67 |
|
68 |
# Render the object. |
69 |
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \ |
70 |
"diffusion%02d.jpg") % i) |
71 |
|