Dear fipy users and developers,    
    
I have a spherical symmetric problem, so I can use Grid1D mesh, but need to 
multiply coefficients in diffusion-convection problem by r^2 and also add 
external one like 1/r^2, i.e.    
    
df/dt = 1/r^2 d/dr (r^2 D df/dr) - 1/r^2 d/dr (r^2 u f)    
    
I managed to provide r^2 in "internal" coefficients, but failed to provide 
1/r^2 in "external" ones (i.e. something like (1/r**2)*DiffusionTerm). I then 
tested to put some CellVariable before the Term as was advised to do earlier 
and the script failed again.    
    
Do you have any ideas how to implement this? Below is the test script that 
currently works.    
    
Rmax=1.    
nsteps=100    
dr=Rmax / float(nsteps)    
mesh_r = Grid1D(dx = dr, nx = nsteps)    
r = mesh_r.getCellCenters()    
    
phi = CellVariable(mesh=mesh_r, name = "variable", value=1.0)    
         
valueLeft = 0    
valueRight = 0    
BCs = (FixedValue(faces=mesh_r.getFacesLeft(), value=valueLeft), 
FixedValue(faces=mesh_r.getFacesRight(), value=valueRight))    
       
convCoeff = FaceVariable(mesh=mesh_r, 
value=1.0*mesh_r.getFaceCenters()*mesh_r.getFaceCenters(), rank=1)    
diffCoeff = FaceVariable(mesh=mesh_r, 
value=1.0*mesh_r.getFaceCenters()*mesh_r.getFaceCenters())    
    
Source = CellVariable(mesh=mesh_r)    
Source.setValue(5e-8)    
       
eq = TransientTerm() == DiffusionTerm(coeff = diffCoeff) + 
PowerLawConvectionTerm(coeff = convCoeff) + Source    
     
timeStepDuration = 1    
time = 1    
viewer = Viewer(vars=(phi), limits={'datamin': 1e-15, 'datamax': 1e1})    
while time <= t:    
        timeStep = timeStepDuration    
        eq.solve(var=phi, boundaryConditions=BCs, dt=timeStep)    
        time=time+timeStep    
        viewer.plot()    
  

Reply via email to