Samo, The following code includes an example of solving an equation by creating a secondary mesh on the right sided faces. In this example, the boundary equation has a slow diffusion coefficient. Notice that CellVariable's call method is used to take the values from the 1D boundary equation to the 2D problem. This works with version 2.1 of FiPy.
from fipy import * dt = 1e-2 L = 1. N = 10 dx = L / N m = Grid2D(nx=N, ny=N, dx=dx, dy=dx) mbc = Grid1D(nx=N, dx=dx) x, y = m.getCellCenters() X, Y = m.getFaceCenters() ybc, = mbc.getCellCenters() xbc = numerix.array([L] * N) v = CellVariable(mesh=m, value=x * y) maskedFaceValue = FaceVariable(mesh=m, value=X * Y) vbc = CellVariable(mesh=mbc, value=ybc * xbc) eq = TransientTerm() == DiffusionTerm() eqbc = TransientTerm() == DiffusionTerm(coeff=1e-2) bcs = (FixedValue(faces=m.getFacesRight(), value=maskedFaceValue),) vi = Viewer(v, datamax=1, datamin=0) while True: maskedFaceValue[:] = vbc((Y,)) eq.solve(v, dt=dt, boundaryConditions=bcs) eqbc.solve(vbc, dt=dt) vi.plot() -------- Original Message -------- Subject: Re: fipy boundary conditions Date: Tue, 4 Oct 2011 12:09:13 -0400 From: Samo Fišinger <samo.fisin...@gmail.com> To: Wheeler, Daniel <daniel.whee...@nist.gov> References: <26a5a3e9-9aca-455b-991d-f14eaf8e2...@googlemail.com> <4e8b1f56.1070...@nist.gov> Hi Daniel, I'm preparing a scientific publication and I would really like to include FiPy calculations in it. So, I would like to ask you if you can give me a hint of how to implement this idea with the second mesh. I'm not sure I got it. I also have to admit that I'm totally new to FiPy. Thanks in advance, Samo p.s. Next time I'll make sure to post to FiPy mailing list. On Oct 4, 2011, at 4:59 PM, Daniel Wheeler wrote: > Hi Samo, Thanks for your interest in FiPy. > > Samo Fišinger wrote: >> >> Dear Daniel, >> I would like to implement the following boundary condition in fipy (coupled >> diffusion equations with source): >> - alpha*phi_b = grad(phi_a) >> alpha is just a parameter (scalar) phi_a and phi_b are concentrations which >> obey the diffusion reactions. > > This should be quite straight forward. Just create a secondary mesh on the > boundary and solve for a separate set of variables. Make sure to copy the > values between each mesh's variables at each time step or sweep. > >> I saw the example with sourceBoundary on your page, however, I would like to >> know how to implement this kind of >> equation as a boundary condition and more complicated (arbitrary) boundary >> conditions in general. > > At the moment boundary operators are not supported so use the separate mesh > approach described above. > >> On the other hand, I would also like to ask if you have any detailed >> tutorial of fipy? I have the impression that fipy is more powerful than the >> examples given on your page. > > That's true, but we don't have any more examples right now. > > Cheers > > PS Can you post to the FiPy list if possible. Thanks. > >> Thanks in advance, >> Samo > > -- > Daniel Wheeler > -- Daniel Wheeler -- Daniel Wheeler _______________________________________________ fipy mailing list fipy@nist.gov http://www.ctcms.nist.gov/fipy [NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy]