| Hi Terry, I have taken the liberty of editing your file a little. The TSVViewer can only save variables, just as a viewer does, it can't save arbitrary data. It is meant to behave like our standard viewers but just write to a file. Instead of saving all the data in one file, I have set it up to save a file for each time step and save the time data in the file name. Hope that is okay. If you want to do it differently then let me know. I have also added a few lines that allow you to refine your mesh while maintaining your chosen mesh intervals. Hope this helps ... |
# twm 8/2,5u/06 - change spatial scale to ~10mm # DW reworked 8/7/06; twm tweaked thereafter # Has higher resolution plotting along x # Use different thermal path above/below disk; Shorter computation time (twm - 8/8/06)
shift = 4.444440e-3 # x position of TOP of disk
bot = 5.688901e-3 # x position of BOT of dis
intervals = (0.0, 4.444440e-3, 4.444446e-3, 4.444461e-3, 5.688901e-3, 10.488901e-3)
dx = (1.e-10,3.e-3,1.e-3,3.e-4,1.e-4,3.e-5,1.e-5,3.e-6,1.e-6,3.e-7,1.e-7,3.e-8,1.e-8,3.e-9,3.e-9,3.e-9,3.e-9,3.e-9,3.e-9,3.e-9,1.e-8,3.e-8,1.e-7,3.e-7,1.e-6,3.e-6,1.e-5,3.e-5,1.e-4,3.e-4,8.e-4,2.4e-3,2.4e-3,1.e-10) # define thicknesses: TOP=4.444440mm SUBSTRATE=1.244440mm BOT=4.800000mm
#dx = x[1:] - x[:-1] # define node intervals
#dx = (1.e-10,1.e-3,1.e-3,1.e-3,1.e-3,.5e-3,.3e-3,.1e-3,.05e-3,.05e-3,3.e-9,3.e-9,3.e-9,3.e-9,3.e-9,3.e-9,3.e-9,20.e-9,60.e-9,200.e-9,500.e-9,3000.e-9,1.e-5,3.e-5,1.e-4,3.e-4,5.e-4,1.e-3,1.e-3,1.e-3,1.e-3,1.e-10)
#dt = 0.1e-3 # orig. 2.e-5, then 0.05e-3
dt = 125.0e-6 # Use with 'tf1'
ab = 0.412
alpha = 1 / 30.e-9
Fl = 30.e4
tf = 25.e-3
tf1 = 25.e-3
go = 2. / tf
gxo = ab * alpha * Fl
#specificHeat = (0.9268E3, 2.52E6, 3.56E6, 1.88E6, 0.9268E3)
#specificHeat = (0.9268E4, 2.52E6, 3.56E6, 1.88E6, 0.9268E4)
specificHeat = (0.9268E3, 2.52E6, 3.56E6, 1.88E6, 2.83E5) #TOP:Ar gas; BOT:effective buffer of parallel Ar + quartz rods
#conductivity = (0.02, 2.0, 20.0, 0.7, 0.02)
#conductivity = (0.05, 2.0, 20.0, 0.7, 0.05)
conductivity = (0.02, 2.0, 20.0, 0.7, 0.287) #effective buffer of parallel Ar + quartz rods
from fipy.meshes.grid1D import Grid1D
## refine the grid
refine = True
from fipy import numerix
dx = numerix.array(dx)
while refine:
print "There are %i cells" % len(dx)
flag = raw_input("Do you want to refine (y/n)?")
if 'y' in flag:
dx = numerix.transpose(numerix.resize(dx, (2, len(dx))))
dx = numerix.array(dx).flat / 2.
else:
refine = False
mesh = Grid1D(dx=dx)
from fipy.variables.cellVariable import CellVariable
from fipy.variables.variable import Variable
var = CellVariable(mesh=mesh)
transientCoeff = CellVariable(mesh=mesh)
diffusionCoeff = CellVariable(mesh=mesh)
time = Variable(0)
for i in range(len(specificHeat)):
mask = mesh.getCellCenters()[...,0] > intervals[i]
transientCoeff.setValue(specificHeat[i], where=mask)
diffusionCoeff.setValue(conductivity[i], where=mask)
from fipy.terms.transientTerm import TransientTerm
from fipy.terms.diffusionTerm import DiffusionTerm
from fipy.tools import numerix
X = mesh.getCellCenters()[...,0]
Xmask = (X >= shift) * (X <= bot) * (time < tf)
source = Xmask * go * gxo * (1 - time / tf) * numerix.exp(-alpha * (X - shift) * Xmask)
eqn = TransientTerm(transientCoeff) == DiffusionTerm(diffusionCoeff) + source
from fipy.boundaryConditions.fixedValue import FixedValue
BCs = (FixedValue(faces=mesh.getFacesLeft(), value=0),
FixedValue(faces=mesh.getFacesRight(), value=0))
xmin = shift - 3.e-3
xmax = shift + 3.e-3
from fipy.viewers import make
#viewer = make(var, limits={'datamax':1.5e3})
viewer = make(var, limits={'xmax' : xmax, 'xmin' : xmin, 'datamax':1.e3})
from fipy.viewers.tsvViewer import TSVViewer
#TSVViewer(vars=var).plot(filename="twmDATA.tsv")
while (time < 1. * tf1).getValue():
eqn.solve(var, boundaryConditions=BCs, dt=dt)
time.setValue(time + dt)
print 'time',time + dt # twm add
# print 'Xmask',Xmask # twm add
viewer.plot()
TSVViewer(vars=var).plot(filename="twmDATA" + str(time + dt) + ".tsv")
# TSVViewer(vars=var).plot(filename="twmDATA1.tsv")
raw_input("finished")
On Aug 16, 2006, at 4:21 PM, [EMAIL PROTECTED] wrote:
Daniel Wheeler |
