[petsc-users] help about my first petsc program

Xuan YU xxy113 at psu.edu
Wed Jun 23 11:45:37 CDT 2010


On Jun 23, 2010, at 12:38 PM, Jed Brown wrote:

> On Wed, 23 Jun 2010 12:24:36 -0400, Xuan YU <xxy113 at psu.edu> wrote:
>> I tried these method. Pseudo and Beuler work well. gl kept running
>> after t=1.665007e+01.
>
> Different code from the kinetics problem you pasted?  GL worked when I
> ran it [1], but I'm not surprised if it fails on your real problem.
>
>> Actually, I will solve a global ODE system in form of y'=f(t,y;x), x
>> is the forcing. The problem has been solved by cvode(sundials). I  
>> want
>> to use petsc to improve efficiency.
>
> That is likely largely about preconditioning, note that you can also  
> use
> CVODE through PETSc, with PETSc preconditioners, but that doesn't use
> SNES or KSP so you have fewer choices.
>
> Jed
>
>
> [1]
>
> $ ./a.out -ts_type gl
> At t =          0  y =1.000000e+00  0.000000e+00  0.000000e+00
> At t =       0.01  y =9.996023e-01  4.536940e-05  3.523190e-04
> At t =      0.012  y =9.995227e-01  3.460238e-05  4.427435e-04
> At t =  0.0128944  y =9.994870e-01  3.630127e-05  4.766579e-04
> At t =  0.0132594  y =9.994725e-01  3.636046e-05  4.911255e-04
> At t =  0.0140389  y =9.994415e-01  3.638138e-05  5.221217e-04
> At t =  0.0167059  y =9.993355e-01  3.639729e-05  6.281372e-04
> At t =  0.0239153  y =9.990496e-01  3.638965e-05  9.140576e-04
> At t =  0.0447892  y =9.982260e-01  3.619797e-05  1.737826e-03
> At t =  0.0731174  y =9.971190e-01  3.581689e-05  2.845193e-03
> At t =   0.109233  y =9.957254e-01  3.583264e-05  4.238734e-03
> At t =   0.131687  y =9.948689e-01  3.554250e-05  5.095594e-03
> At t =    0.15262  y =9.940770e-01  3.477519e-05  5.888207e-03
> At t =   0.189042  y =9.927143e-01  3.556983e-05  7.250171e-03
> At t =   0.210466  y =9.919214e-01  3.496951e-05  8.043646e-03
> At t =   0.216991  y =9.916812e-01  3.499105e-05  8.283760e-03
> At t =   0.228628  y =9.912544e-01  3.495839e-05  8.710620e-03
> At t =   0.249814  y =9.904822e-01  3.480390e-05  9.482953e-03
> At t =   0.284509  y =9.892306e-01  3.457380e-05  1.073483e-02
> At t =   0.329694  y =9.876293e-01  3.428339e-05  1.233642e-02
> At t =   0.453362  y =9.833627e-01  3.346441e-05  1.660382e-02
> At t =   0.632794  y =9.774858e-01  3.258959e-05  2.248158e-02
> At t =   0.763647  y =9.734140e-01  3.178560e-05  2.655426e-02
> At t =        0.8  y =9.723125e-01  3.169671e-05  2.765585e-02
> Number of timesteps = 23 final time 8.00e-01
> $ ./a.out -ts_type sundials
> At t =          0  y =1.000000e+00  0.000000e+00  0.000000e+00
> At t =        0.8  y =9.723021e-01  3.169016e-05  2.766620e-02
> Number of timesteps = 1 final time 8.00e-01
>
> TS Object:
>  type: sundials
>  Sundials integrater does not use SNES!
>  Sundials integrater type BDF: backward differentiation formula
>  Sundials abs tol 1e-06 rel tol 1e-06
>  Sundials linear solver tolerance factor 0.05
>  Sundials GMRES max iterations (same as restart in SUNDIALS) 5
>  Sundials using unmodified (classical) Gram-Schmidt for  
> orthogonalization in GMRES
>  Sundials suggested factor for tolerance scaling 1
>  Sundials cumulative number of internal steps 28
>  Sundials no. of calls to rhs function 44
>  Sundials no. of calls to linear solver setup function 14
>  Sundials no. of error test failures 2
>  Sundials no. of nonlinear solver iterations 40
>  Sundials no. of nonlinear convergence failure 0
>  Sundials no. of linear iterations 51
>  Sundials no. of linear convergence failures 0
>  Sundials no. of preconditioner evaluations 1
>  Sundials no. of preconditioner solves 88
>  Sundials no. of Jacobian-vector product evaluations 51
>  Sundials no. of rhs calls for finite diff. Jacobian-vector evals 51
>

I changed dt=0.4 and the Monitor function, so GL doesn't work.

PetscErrorCode Monitor(TS ts,PetscInt step,PetscReal time,Vec u, void  
*ctx)
{
   PetscScalar *y;
   PetscReal dt;
   TSGetTimeStep(ts,&dt);
   VecGetArray(u,&y);
   PetscPrintf(PETSC_COMM_WORLD,"At t =%e  y =%e  %e  %e,  
\n",time,y[0],y[1],y[2]);
   VecRestoreArray(u,&y);
   if(step>0)dt=time*9;
   TSSetTimeStep(ts,dt);
   return 0;
}


Why Petsc is faster than cvode? How fast it will be?


Xuan YU
xxy113 at psu.edu






More information about the petsc-users mailing list