Page 61 - Process Modelling and Simulation With Finite Element Methods
P. 61

48         Process Modelling and Simulation with Finite Element Methods

             This example should illustrate the importance of  selecting the right  solver
          for your equations.  If there is any dependence off on the dependent variables,
          then the stationary nonlinear  solver should be used.  The linear solver is faster,
          but  it  also presumes  that  the  coefficients  of  the  PDE  do  not  depend  on  the
          dependent variable u (else the problem would be nonlinear).  When in doubt, use
          the nonlinear solver.  After  all, (1.19) with R(u)=k u, is a  linear problem, but
          FEMLAB only finds the correct steady state solution with the nonlinear solver!
          The slow convergence rate is also the consequence of  the form of  the model  -
          general  mode with  the  exact  Jacobian  solver  option  for  the  nonlinear  solver
          converges in two iterations to the correct profile.
             We  argued  that  (1.20)  is  the  finite  difference  matrix  equation  for  this
          problem, yet later applied the argument that (1.22) should describe the FEMLAB
          finite  element  problem.  Because  we  used  Lagrange  linear  elements,  in  this
          special case the finite element and finite difference matrix operators coincide, up
          to the boundary conditions.  To see this, we will take a foray into the MATLAB
          representation of FEMLAB problems.
             Pull down the File Menu and select Export FEM structure as ‘fern’. This
          puts  the  current  solution  as  a  MATLAB  data  structure  in  the  MATLAB
          workspace.  We can  then  manipulate it using  the built-in  MATLAB  functions
          and commands, as well as the special function set of FEMLAB.
             In your MATLAB workspace, try the commands
             >>x=fem.xmesh.p{l};
             >>u=fem.sol.u;
              >>plot (x,u)
          This should pop up a MATLAB Figure plotting the solution u versus the array of
          mesh points.  No doubt your plot looks scrambled.  This is because FEMLAB
          stores the mesh points and the  associated  solution variables  so as to  make the
          specification of the matrix equations sparse and compact.  We can make sense of
          the solution by ordering the mesh points and the solution:
             In your MATLAB workspace, try the commands
             >> [xx, idx] =sort (x) ;
             >>plot (xx, u (idx) )
          This plot  should resemble Figure  1.6, with the exception that it represents your
          last FEMLAB solution.  In fact, we can only make  sense of the solution format
          of the fern structure so readily because this is a single dependent variable, one-
          dimensional  problem.  Otherwise,  multiple  variables  and  dimensions  leave  a
          mesh  and  solution  structure  that  only  FEMLAB  tools/functions  can  readily
          decode.
   56   57   58   59   60   61   62   63   64   65   66