examples.updating.update2_0to3_0¶
How to update scripts from version 2.0 to 3.0.
FiPy 3.0 introduces several syntax changes from FiPy 2.0. We appreciate that this is very inconvenient for our users, but we hope you’ll agree that the new syntax is easier to read and easier to use. We assure you that this is not something we do casually; it has been over two and a half years since our last incompatible change (when FiPy 2.0 superceded FiPy 1.0).
All examples included with version 3.0 have been updated to use the new syntax, but any scripts you have written for FiPy 2.0 will need to be updated. A complete listing of the changes needed to take the FiPy examples scripts from version 2.0 to version 3.0 can be found with
$ git diff version-2_1 version-3_0 examples/
but we summarize the necessary changes here. If these tips are not sufficient to make your scripts compatible with FiPy 3.0, please don’t hesitate to ask for help on the mailing list.
The following items must be changed in your scripts
We have reconsidered the change in FiPy 2.0 that included all of the functions of the
numerixmodule in thefipynamespace. You now must be more explicit when referring to any of these functions:>>> from fipy import * >>> y = numerix.exp(x)>>> from fipy.tools.numerix import exp >>> y = exp(x)We generally use the first, but you may see us import specific functions if we feel it improves readability. You should feel free to use whichever form you find most comfortable.
Note
the old behavior can be obtained, at least for now, by setting the
FIPY_INCLUDE_NUMERIX_ALLenvironment variable.If your equation contains a
TransientTerm, then you must specify the timestep by passing adt=argument when callingsolve()orsweep().
The remaining changes are not required, but they make scripts easier to read
and we recommend them. FiPy may issue a DeprecationWarning for some cases,
to indicate that we may not maintain the old syntax indefinitely.
“getter” and “setter” methods have been replaced with properties, e.g., use
>>> x, y = mesh.cellCentersinstead of
>>> x, y = mesh.getCellCenters()Boundary conditions are better applied with the
constrain()method than with the oldFixedValueandFixedFluxclasses. See Boundary Conditions.Individual
Meshclasses should be imported directly fromfipy.meshesand notfipy.meshes.numMesh.The Gmsh meshes now have simplified names:
Gmsh2Dinstead ofGmshImporter2D,Gmsh3Dinstead ofGmshImporter3D, andGmsh2DIn3DSpaceinstead ofGmshImporter2DIn3DSpace.
        FiPy