Dear Henri, >From your last message I gather that you would like to apply zero-flux conditions on all boundaries, in a cylindrical (r,z) geometry.
In that case, I warmly recommend that you follow Jon's suggestion and use the implicit no-flux boundary condition. Do not explicitly specify a zero-gradient. We had some advection-diffusion test cases here where explicitly specifying zero-flux conditions in Fipy yielded less precise results (loss of mass conservation) than the implicit no-flux. https://github.com/mhvwerts/MasonWeaver-finite-diff/blob/master/finite-difference-solver-vs-Fipy-finite-volume-solver.pdf Also, the CylindricalGrid2D is likely exactly what you need for your problem geometry. We used it with success on a system for which an analytic solution exists. https://github.com/simulkade/FVTool/blob/master/Examples/External/Diffusion1DSpherical_Analytic-vs-FVTool-vs-Fipy/diffusion1Dspherical_analytic_vs_FVTool_vs_Fipy.pdf Best wishes Martin P.S.1. Our example where we used CylindricalGrid2D was created before SphericalGrid1D was implemented in Fipy P.S.2. For some it is a bit awkward to not specify boundary conditions explicitly. It might be an idea to have a method 'standard_zero_flux_boundaries()' or so, that simply does nothing, but that one could put in one's code so that everything is specified... On 10/11/2020 15:45, 'Guyer, Jonathan E. Dr. (Fed)' via fipy wrote: > Henri - > > My apologies for the delay in answering. > > We have an existing mesh generator > [`CylindricalGrid2D`](https://www.ctcms.nist.gov/fipy/fipy/generated/fipy.meshes.html#fipy.meshes.factoryMeshes.CylindricalGrid2D) > that automatically takes care of calculating cylindrical symmetry. You > only need to specify the r and z dimensions of the mesh and FiPy takes > care of the wedge-shaped geometry; you do not need to transform your > PDE into cylindrical form. > > Mathematically, what boundary conditions are you trying to achieve? > > I definitely wouldn’t use `NthOrderBoundaryCondition`. Those are only > for higher-order PDEs like Cahn-Hilliard/Ginsburg-Landau. Even then, > that’s an older way of doing things that we don’t recommend anymore. > > `Pol.faceGrad.constrain()` is the syntax we recommend, but you should > be aware that as a finite volume code, FiPy has no-flux as the natural > boundary condition. While no-flux is not always equivalent to zero > normal gradient, for your diffusion equation, they are equivalent. > There is no need to apply a constraint if no-flux is what you desire. > > - Jon > >> On Nov 3, 2020, at 12:49 PM, Henri Colaux <[email protected] >> <mailto:[email protected]>> wrote: >> >> >> Dear devs, >> >> I am writing a code that simulates the diffusion of magnetisation >> from proton to proton inside a solid. This process behaves like a >> standard diffusion program (but with an equilibrium term) so your >> code have been very helpful and I got some great results so far, but >> I stambled into some problem whose solution is above my knowledge. >> >> I am trying to simulate a « drill-core » sort of structure with two >> different components - denoted « domains », one being a small slice >> inside a much more abundant one, as pictured in the following >> schematics : >> >> >> I figured that this system is equivalent to producing a 2D array >> using Grid2D as picture of the right of this figure, and ensuring >> that there is no magnetisation transfer (i.e. no flux) taking place >> at the border of the system. To account for the rotation centre and >> the cylindrical symmetry, I have taken the effect of the radius >> directly in the differential equation.Yet, for some reasons, it seems >> like the boundery conditions is not set correctly in my code, which >> gave unwanted behaviours. >> >> I have included a minimum working example of the code I am trying to >> simulate. First and formost, could you let me know if I do everything >> right for what I am trying to simulate ? >> >> Cheers ! >> >> Henri Colaux >> >> -- >> To unsubscribe from this group, send email to >> [email protected] <mailto:[email protected]> >> >> View this message at https://list.nist.gov/fipy >> --- >> To unsubscribe from this group and stop receiving emails from it, >> send an email to [email protected] >> <mailto:[email protected]>. >> <spindiff_v3_6_1_mwe.py> > > -- > To unsubscribe from this group, send email to > [email protected] > > View this message at https://list.nist.gov/fipy > --- > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected] > <mailto:[email protected]>. -- To unsubscribe from this group, send email to [email protected] View this message at https://list.nist.gov/fipy --- To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
