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