On Aug 11, 2011, at 10:59 AM, JAMBON Fanny 213198 wrote:
> Here is the full script (I do not use the fipy viewer but pylab, make sure > you have it installed!). A better way to do this is to use the MatplotlibViewer and then manipulate its axes as you desire: view = MatplotlibViewer(vars=cH) view.axes.plot(X_scale, Sol, marker='o') view.plot() This allows FiPy to properly position its solution values, which is a problem in your script. > ## Mesh > X_scale= n.linspace(0,2.0e+4,1000)# grid 0-> 20 um ; units[nm] > Nbx=len(X_scale) > deltax= 1.0/float(Nbx) You calculate the analytical solution over a domain of [0, 2.0e+4 nm], but your FiPy grid is only [0, 1.0 nm]. Try: deltax= 2.0e+4/float(Nbx) instead. > # Graph plotting > Y_scale=tuple(cH) > plt.plot(X_scale,Y_scale, marker='x') The values of cH are not evaluated at [0., 20.02002002, 40.04004004, ...] as given by linspace, but rather at [1.00000000e+01, 3.00000000e+01, 5.00000000e+01, ...]. Better to do plt.plot(mesh.getCellCenters()[0], cH.getValue(), marker='x') or better still to use the MatplotlibViewer as I show above.
