Thanks - the time dependence is working, however I am still at loss in terms
of the actual simulation process. I will explain:

My model is a rectangular block of silicon, Z=180 um, X and Y = 1000um.
Laser strikes top surface (top XY plane) at time zero and remains on
for a fixed time (say 3mS) and thus heats a circular (or cylindrical in 3D)
section.
The heat starts diffusing immediately. I am ignoring for now convection
and radiation from surfaces.

I have succeeded in:

1) modeling the heated section by using higher initial value in cellVariable
over
that section. Thus solution however does not take into account the fact that
this section is heated actively for 3mS after time zero.
2) modeling the assuming heat flux across the heated section boundary, but
I use some "arbitrary" simple flux (non-zero for t<3mS and zero for t>3mS).

Both files are included below.

I really need a way to model more closely the fact that this whole circular
section is heated
by an external source for 3mS.

I am assuming (for time being) complete uniformity over Z and so turn
this into a 2D problem.

======== attempt # 1 ===========
#!/usr/bin/env python
"""
     Wood (Maple)   0.00128
     Stone (Marble) 0.0120
     Iron           0.2034
     Aluminum       0.8418
     Silver         1.7004
     Silicon        0.8
"""

from fipy import *

## my mesh and subdivisions
## units are in terms of cm (wrong units for now)
 Side = 1.0
Radius = 0.1
cellSize = Radius/5.0

# Using this and not uniform mesh since want a circular core in center of
body
# by through symmetry can use half (or quarter) of whole body.
m2D = GmshImporter2D('''
    cellSize = %(cellSize)g;
    side = %(Side)g;
    radius = %(Radius)g;
    Point(1) = {0,0,0,cellSize};
    Point(2) = {side,0,0,cellSize};
    Point(3) = {side,side/2 - radius,0,cellSize};
    Point(4) = {side-radius,side/2,0,cellSize};
    Point(5) = {side,side/2+radius,0,cellSize};
    Point(6) = {side,side/2,0,cellSize};
    Point(7) = {side,side,0,cellSize};
    Point(8) = {0,side,0,cellSize};
    Line(11) = {1,2};
    Line(12) = {2,3};
    Circle(13) = {3,6,4};
    Circle(14) = {4,6,5};
    Line(15) = {5,7};
    Line(16) = {7,8};
    Line(17) = {8,1};
    Line Loop(20) = {11,12,13,14,15,16,17};
    Plane Surface(21) = {20};
    ''' % locals())

t = Variable(value=0.0)
initialTemp = 20.0

x, y = m2D.getFaceCenters()
cv = CellVariable(mesh=m2D, value = initialTemp)

D = 0.8

eq = TransientTerm() == ImplicitDiffusionTerm(coeff=D)
facesHeaters = (m2D.getExteriorFaces() & (x > Side-Radius) & (y > Side/2 -
Radius) & (y < Side/2 + Radius)  )
facesOthers = (m2D.getExteriorFaces() & ((x < Side/10.) | (y > 0.9*Side) |
(y < 0.1*Side) ) )
BCs = (
    FixedValue(faces=facesHeaters, value = 50.0),
    FixedValue(faces=facesOthers, value = initialTemp) ## heat sink on other
faces
    )

dt1 = 0.5e-3
dt = dt1

totalTime=1.0 # seconds
viewer=Viewer(vars=cv, datamin=19., datamax = 51.)

while t() < totalTime:
     eq.solve(var=cv, boundaryConditions=BCs, dt=dt)
     viewer.plot()
     t.setValue(t()+dt)
     print t, dt

raw_input("Press <return> to proceed...")

======== attempt # 2 ===========

#!/usr/bin/env python
"""
     Wood (Maple)   0.00128
     Stone (Marble) 0.0120
     Iron           0.2034
     Aluminum       0.8418
     Silver         1.7004
     Silicon        0.8
"""

from fipy import *

## units are in terms of cm
Lx = 1.
Ly = 1.
nx = 50
ny = 50
dx = Lx/nx
dy = Ly/ny
m2D = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)

 t = Variable(value=0.0)
initialTemp = 20.0

## create mesh
x, y = m2D.getCellCenters()
cv = CellVariable(mesh=m2D, value = initialTemp)
cv.setValue(50.0, where = ( (x-0.5)**2 + (y-0.5)**2 < 0.04) )

D = 0.8

eq = TransientTerm() == ImplicitDiffusionTerm(coeff=D)

# time steps
dt1 = 0.2e-3
dt2 = 5e-3
dt = dt1

## setup viewer and end-time
totalTime=1.0 # seconds
viewer=Viewer(vars=cv, datamin=19., datamax = 51.)

while t() < totalTime:
     eq.solve(var=cv,  dt=dt)
     viewer.plot()
     t.setValue(t()+dt)
     print t, dt

raw_input("Press <return> to proceed...")

Any help will be greatly appreciated.

Last question for now - is there any way , a-priori of choosing the
"correct" timestep?

Thanks

David

Reply via email to