valueLeft = 0. fluxRight = 1. timeStepDuration = 1. L = 10. dx = L / nx dy = 1. mesh = Tri2D(dx, dy, nx, ny) var = CellVariable( name = "solution variable", mesh = mesh, value = valueLeft) from fipy.variables.faceVariable import FaceVariable diffCoeff = FaceVariable(mesh = mesh, value = 1.0) x = mesh.getFaceCenters()[...,0] diffCoeff.setValue(0.1, where=(L/4. <= x) & (x < 3. * L / 4.)) boundaryConditions=(FixedValue(mesh.getFacesLeft(),valueLeft), FixedFlux(mesh.getFacesRight(),fluxRight)) if __name__ == '__main__': ImplicitDiffusionTerm(coeff = diffCoeff).solve(var, boundaryConditions = boundaryConditions) viewer = fipy.viewers.make(vars = var) viewer.plot() raw_input('finished')
ny = 1 valueLeft = 0. fluxRight = 1. timeStepDuration = 1. L = 10. dx = L / nx dy = 1. mesh = Tri2D(dx, dy, nx, ny) var = CellVariable(name="solution variable", mesh=mesh, value=valueLeft) from fipy.variables.faceVariable import FaceVariable diffCoeff = FaceVariable(mesh=mesh, value=1.0) x = mesh.getFaceCenters()[..., 0] diffCoeff.setValue(0.1, where=(L / 4. <= x) & (x < 3. * L / 4.)) boundaryConditions = (FixedValue(mesh.getFacesLeft(), valueLeft), FixedFlux(mesh.getFacesRight(), fluxRight)) if __name__ == '__main__': ImplicitDiffusionTerm(coeff=diffCoeff).solve( var, boundaryConditions=boundaryConditions) viewer = fipy.viewers.make(vars=var) viewer.plot() raw_input('finished')