me471s03_lec09

Embed Size (px)

Citation preview

  • 8/21/2019 me471s03_lec09

    1/12

    Introduction to Time Dependent Problems

    Problems in One Space Dimension

    We first consider a 1D initial-boundary value problem:

    ∂u

    ∂t  =

     ∂ 2u

    ∂x2 + g(x, t),   0 < x

  • 8/21/2019 me471s03_lec09

    2/12

    where f i  = I  gH idx +  H i

    ∂u∂x

    ba

    We can write the equations above in matrix form as

    M  =

     I 

    H 1H 2

    ( H 1   H 2 )  dx, K   =

     I 

    dH 1dxdH 2dx

    (  dH 1

    dxdH 2dx

      )  dx

    and

    F  =

     I 

    H 1H 2

    g(x, t) dx +

    −∂u/∂x(a, t)

    ∂u/∂x(b, t)

    and obtain the element equations

    M  U̇  +  KU  = F,

    where M  is called the element mass matrix (in keeping with the structural origins of the fem). Note that theelement load vector contains the partial derivatives of the test function evaluated end points of the interval.These cannot be computed using

     ujH j   because they would fail to be continuous across the element

    boundary – and then the whole method would fail since it is based on the assumption that 10

      =

    e

     xe+1xe

    .Fortunately these unknown partial derivatives all cancel out when the element matrices are assembled intothe global matrices – except, that is, for the terms   H 1(0)∂u/∂x(0, t) and  H 2(1)∂u/∂x(1, t).  But since thetest functions  w  are required to vanish at  x  = 0,  w  =  H 1   is not admissible in element 1 so this term is tobe omitted, and in the last element  nel  ∂u/∂x(1, t) =  b(t) is given. The fact that all the internal unknowns,∂u/∂x(xe, t), e  = 2, . . . , nel −  1,   introduced with the element weak form cancel out in the final assemblymakes it fairly reasonable to ignore these unknowns and treat the element load vector as if it consisted of only

    F e =

     I e

    H e1H e2

    g(x, t) dx + δ e,ne

      0b(t)

    ,

    that is, only in the final element is there a contribution from the flux terms. I think this is probably anacceptable fiction as long as the true state of affairs is kept in mind.

    For 1D linear shape functions (see pp. 38-39 of the text) we have:

    K  ≡ [kij] =  1

    h   1   −1−1 1

      M  ≡ [mij ] =  h6 2 1

    1 2

    It is worthwhile looking at the computation of the mass matrix. In integrating over element of the formI  = [a, b] of length h  =  b − a, it is useful to transform the variable of integration setting  r  = (x − a)/h, andintegrate over the unit interval [0, 1]. On this interval the basis functions become:   H 1(r) = 1− r, H 2(r) =  r,so that the integral to be computed becomes

    M  = h

       10

    (1− r)2 r(1− r)r(1− r)   r2

     dr

    It is now easy to perform the required integration and verify the results.

    The global equations which are assembled, as usual, from the element equations take the form

    M  U̇  +  KU  = F.

    This is essentially a system of ODEs for the values uj(t) of the solution at the nodes. I say essentially becauseall given boundary value information has to be input in order to create a legitimate system. (In this case,it is required that  u1(t) =  a(t). This can be done simply by replacing the first equation with u̇1   = ȧ  andtacking on the initial condition  u1(0) = a(0).)

    Generally, the numerical solution of the system of ODEs just derived in accomplished using finite differencemethods not finite element methods. For these methods, we pick a sequence of times   tj , j  = 1, . . . ,  wheret1  = 0,  and attempt to predict  U (t) at these times. Let U 

    j =  U (tj), then by the mean value theorem for

    2

  • 8/21/2019 me471s03_lec09

    3/12

    derivatives asserts that  U̇ (tj  + θ(tj+1  −  tj)) = (U j+1 − U j)/(tj+1  −  tj), for some   θ,   0   < θ <   1. Letting

    ∆j  = tj+1 − tj  we have

    M (U j+1 − U j) + ∆jKU (tj +  θ∆j) = ∆jF (tj + θ∆j)

    So far this equation is exact, but we don’t actually know the value of  θ. So we choose a fixed value, andeach such choice creates a new numerical method. (Once   θ   is picked, the   U j will represent a numericalapproximation to the original  U , but I will continue to ignore this sort of thing.) The standard ones are:

    1 The explicit forward difference method is obtained by choosing θ  = 0, and can be written as

    M U j+1 = (M  − ∆jK )U j + ∆jF 

    j U 1 = [c(x1), c(x2), . . . , c(1)]T 

    Note that this determines U j for all j  = 1, 2, . . .. It is explicit because it determines  U  at each new timelevel explicitly in terms of  U  at the previous level. It is a forward difference method since the derivativeat level  j  is represented using the difference between  U  at this level and  U  at the next (forward) level.

    2 The backward difference or implicit method is obtained using θ  = 1. This gives

    (M  + ∆jK )U j+1 = M U j + ∆jF 

    j+1 U 0 = [c(x1), c(x2), . . . , c(xn+1)]T 

    Thus,  U  at the new level us obtained only by solving a system of equations, i.e., the difference formulaonly defines  U  at the new level implicitly. The backward difference designation obviously refers to thefact the derivative is approximated at the new level using  U   at the previous (backward) level. Since,our problem is linear we can actually solve for  U j+1 to obtain

    U j+1 = (M  + ∆jK )−1(MU j + ∆jF 

    j+1)

    3 The Crank-Nicholson method is obtained using  θ  = 1/2, and using the additional approximations

    U (1

    2(tj +  tj+1)) =

     1

    2(U j+1 + U j), F (

    1

    2(tj + tj+1)) =

     1

    2(F j+1 + F j).

    From these we obtain

    (2M  + ∆jK )U j+1 = (2M  − ∆jK )U 

    j + ∆j(F j+1 + F j)

    .

    These methods have different properties. To keep the discussion simple, assume that   tj+1 − tj   = ∆, j   =0, 1, . . .   It can be shown that the explicit method is only works (technically, is stable) for small ∆. Theimplicit method is stable for all ∆, and its accuracy increases linearly as delta decreases. The Crank-Nicholson method is also stable for all ∆, its accuracy increases quadratically as ∆ decreases, but it involvesmore work per step than the implicit method.

    I have included a small m-file which uses the backward difference method to solve an initial value problem.

    function transient2(n, nstep, dt)

    % 1D transient heat conduction problem:

    % u_t=u_xx, 0

  • 8/21/2019 me471s03_lec09

    4/12

    % dt = time increment

    %

    sdof=n+1;

    xvec=linspace(0,1,n+1); % define the node points

    h=1/n;

    nodes=[[1:n]’ [2:n+1]’]; % configuration matrix

     mm=zeros(sdof,sdof); kk=zeros(sdof,sdof); ff=zeros(sdof,1);ke=elstif(h);

     me=elmass(h);

    for iel=1:n % assembly loop all elements have same mass and stiffness

    for ii=1:2 % assemble mass and stiffness

    gn1=nodes(iel,ii);

    for jj=1:2

    gn2=nodes(iel,jj);

     mm(gn1,gn2)=mm(gn1,gn2)+me(ii,jj);

    kk(gn1,gn2)=kk(gn1,gn2)+ke(ii,jj);

    end

    end

    end

    uold=init_val(xvec’); % set inital conditionseffrc=zeros(sdof,1);

    t=0;

    esol=exac(xvec,0);

    close all

    hold on

    plot(xvec, uold, xvec,esol,’o’); % plot initial condition

    for k=1:nstep % use implicit method

    ff(sdof)=1.0; % forcing at time t

    effrc=mm*uold+dt*ff; % effective forcing

    aa=mm+dt*kk;

    aa(1,:)=0; aa(1,1)=1; effrc(1)=0; % impose bc at x=0 and time t

    fsol=aa\effrc;

    esol=exac(xvec,t+dt);

    plot(xvec’, fsol, xvec, esol, ’o’); % plot solution at new time, t=t+dt

    uold=fsol; t=t+dt;

    end

    legend(’fem soln’, ’exact soln’,4)

    hold off

    %============================================

    % end of main program

    %============================================

    function me=elmass(h)

    % element mass matrix

     me=(h/6)*[2 1; 1 2];

    %============================================function ke=elstif(h)

    % element stiffness matrix

    ke=(1/h)*[1 -1; -1 1];

    %============================================

    function h=init_val(x)

    h=sin(pi*x./2)+x;

    %============================================

    function u=exac(x,t)

    u=x+exp(-pi^2*t/4)*sin(pi*x/2)

    4

  • 8/21/2019 me471s03_lec09

    5/12

    Problems in Two Space Dimensions

    We now shift our attention to problems with 2 space dimensions. As with the 1D case we consider only theheat equation in the form

    ∂u

    ∂t  =

     ∂ 2u

    ∂x2 +

     ∂ 2u

    ∂y2 + g(x, y, t),   (x, y) ∈  D, t > 0.

    On the boundary  ∂ D  of  D, u  takes the values

    u =  a(x, y, t) on  ∂ Du,  ∂u

    ∂n = b(x, y, t) on ∂ Dq,

    with ∂ D =  ∂Du ∪ ∂Dq,  and  a, b given functions. At time  t  = 0, u satisfies the initial condition

    u(x,y, 0) =  c(x, y),   (x, y) ∈  D,

    where, again,   c   is given. (Again, the usual consistency requirements need to be imposed, e.g.,   c(x, y)  →a(x0, y0, 0),   as (x, y)  →  (x0, y0)  ∈  ∂Du.) The weak form is derived just as in the 1D case. We define theresidual

    r = ∂u

    ∂t

     − ∂ 2u

    ∂x2 −

     ∂ 2u

    ∂y2 − g(x, y, t),

    multiply  r  by a test function  w(x, y) which must vanish on ∂ Du  (note that  w  is independent of time  t), andthen integrate over D.  Using the divergence theorem to integrate by parts just as in the stationary case, wefind    

    D

    wrdA =

     D

    (w∂u

    ∂t  +

     ∂ w

    ∂x

    ∂u

    ∂x +

     ∂ w

    ∂y

    ∂u

    ∂y −wg) dA −

     ∂Dq

    w∂u

    ∂n ds.

    This leads to the weak form. That is, we require that  u  take the given values on  ∂ Du, satisfy D

    (w∂u

    ∂t  +

     ∂ w

    ∂x

    ∂u

    ∂x +

     ∂ w

    ∂y

    ∂u

    ∂y) dA =

     D

    wg dA +

     ∂Dq

    wbds

    for all test functions  w  vanishing on  ∂Du, and take the initial condition  u  =  c  at time 0. It is easy to seethat for smooth functions the weak form is equivalent to the original problem.

    Now we introduce a division of  D  into finite elements – linear triangles, bilinear rectangles, etc. – I’ll onlyconsider linear triangles here but other elements can be handled in a similar manner. We specify that thetrial function be linear on each triangular element and continuous throughout the domain. We can thenwrite it in the form   u   =

     n+1j=1  φj(x, y)uj(t) where the global shape functions,   φj   satisfy the conditions

    φi(xj , yj) =   δ ij . We require that the trial solution  u  satisfy the Dirichlet boundary condition on  ∂Du   sothat  uj(t) =  a(xj , yj , t) for nodes on this boundary. We demand that the weak form be satisfied for anytest function  w  from the set  {φk, k = 1, . . . , n + 1} (  φj   corresponding to boundary nodes j  on ∂ Du  shouldnot be included since  w  must vanish there, but as usual we ignore this restriction and impose the properconditions at the end). Substituting for  u  and  w  gives a system of linear equations:

    n+1

    j=1mij u̇j +

    n+1

    j=1kijuj  = f i, i = 1, . . . , n + 1

    Rather than go into the details of these global matrices here, I will focus immediately on a single elementsince the global matrices can be assembled from the lower dimensional element matrices. We assume theelement number  e  is fixed, and therefore to simplify notation do not explicitly indicate it in our formulas.

    Letting the element shape functions be denoted by  H j , j  = 1, 3 as usual, we can write for an element

    M  =

     I 

    H 1H 2

    H 3

    ( H 1   H 2   H 3 )  dA,

    5

  • 8/21/2019 me471s03_lec09

    6/12

    K  =

     I 

    ∂H 1∂x∂H 2∂x∂H 3∂x

    (  ∂H 1

    ∂x∂H 2∂x

    ∂H 3∂x

      ) +

    ∂H 1∂y∂H 2∂y∂H 3∂y

    ∂H 1∂y ∂H 2∂y ∂H 3∂y

    dA,

    and

    F  =  I 

    H 1H 2H 3 g dA +  

    ∂I ∩∂Dq

    H 1H 2H 3 b ds

    Using these matrices we obtain the element equations

    M  U̇  +  KU  = F.

    For linear triangles the element stiffness matrix is the same as in the static case. The element mass matrixM  is most easily computed by using a transformation of variables to covert the integral over the element toone over a simpler triangle  T   =  {(r, s) : 0  < r <  1, 0  < s <  1 − r}. If (xj , yj), j   = 1, 2, 3 are the verticesof the element triangle, a suitable transformation is  x  =

     j H jxj ,   y   =

     j H jyj , where  H j   are the basis

    functions for the triangle T :H 1(r, s) = 1 − r − sH 2(r, s) = r

    H 3(r, s) = sThe indicated functions map  T  linearly onto the element triangle, and the Jacobian of the transformation(equal to the elemental area ratio) is   ∂ (x, y)/∂ (r, s) = 2A,   where   A   is the area of the element triangle.Changing the integration variables then gives

    M  = 2A

       10

    dr

       1−r0

    ds

    1− r − sr

    s

    ( 1− r − s r s ) =   A

    12

    2 1 11 2 1

    1 1 2

    .

    The corresponding global equations are of the form

    M  U̇  +  KU  = F.

    This is essentially a system of ODEs for the values  uj(t) of the solution at the nodes. As in the 1D case,all given boundary value information has to be input in order to create a legitimate system. (In this case,it is required that   uj(t) =   a(xj , yj , t) whenever node   j   is on   ∂Du. This can be imposed by substitutingu̇j  = ȧ(xj , yj , t) for the  j th equation, and adding the boundary condition  uj(0) = a(xj , yj , 0) =  c(xj , yj).)

    The remaining considerations involving integrating these equations forward in time are essentially the sameas in the 1D case. Let’s look at a slightly altered version of the file  ex5111.m  from the text which illustratesthe 2D case. The explicit method of time integration is chosen in this file. The numerical solution could becompared to the exact as computed using the separation of variables technique, but the authors have notdone this. It is easy to show that the exact solution at the center node is given by

    u = 1001 − 2∞

    n=1

    (−1)n−1

    λnexp(−

    λ2n2

     t) ,where λn = (2n−1)π/2,   = 2.5. Thus I have included a computation of this value in the file below. Clearlythere are some inaccuracies at the early stages of the computation.

    %----------------------------------------------------------------------------

    %----------------------------------------------------------------------------

    function ex5111_alt(nx,ny)

    % to solve the transient two-dimensional Laplace’s equation

    % u,t = u,xx + u,yy , 0 < x < 5, 0 < y < 2

    6

  • 8/21/2019 me471s03_lec09

    7/12

    % boundary conditions:

    % u(0,y,t) = 100, u(5,y,t) = 100,

    % u,y(x,0,t) = 0, u,y(x,2,t) = 0

    % initial condition:

    % u(x,y,0) = 0 over the domain

    % using linear triangular elements and forward difference method

    %% Variable descriptions

    % k = element matrix for time-independent term (u,xx + u,yy)

    % m = element matrix for time-dependent term (u,t)

    % f = element vector

    % kk = system matrix of k

    % mm = system matrix of m

    % ff = system vector

    % gcoord = coordinate values of each node

    % nodes = nodal connectivity of each element

    % index = a vector containing system dofs associated with each element

    % bcdof = a vector containing dofs associated with boundary conditions

    % bcval = a vector containing boundary condition values associated with

    % the dofs in ’bcdof’%----------------------------------------------------------------------------

    nx1=nx+1; ny1=ny+1;

    nel=2*nx*ny; % number of elements

    nnel=3; % number of nodes per element

    ndof=1; % number of dofs per node

    nnode=nx1*ny1; % total number of nodes in system

    sdof=nnode*ndof; % total system dofs

    deltt=0.1; % time step size for transient analysis

    stime=0.0; % initial time

    ftime=10; % termination time

    ntime=fix((ftime-stime)/deltt); % number of time increment

    %---------------------------------------------

    % input data for nodal coordinate values

    % gcoord(i,j) where i->node no. and j->x or y

    %---------------------------------------------

    [gcoord, nodes]=gridgen([0,0],[5,2],nx,ny,2);

    gridplot(nx,ny,gcoord,nodes,2)

    input(’Strike any key to continue solution’);

    bcdof=[1:nx1:nnode-nx, nx1:nx1:nnode ]

    lbc=length(bcdof);

    bcval=100*ones(1,lbc);

    %-----------------------------------------

    % initialization of matrices and vectors

    %-----------------------------------------

    ff=zeros(sdof,1); % initialization of system vector

    7

  • 8/21/2019 me471s03_lec09

    8/12

    fn=zeros(sdof,1); % initialization of effective system vector

    fsol=zeros(sdof,1); % solution vector

    sol=zeros(2,ntime+1); % vector containing time history solution

    kk=zeros(sdof,sdof); % initialization of system matrix

     mm=zeros(sdof,sdof); % initialization of system matrix

    index=zeros(nnel*ndof,1); % initialization of index vector

    %-----------------------------------------------------------------

    % computation of element matrices and vectors and their assembly

    %-----------------------------------------------------------------

    for iel=1:nel % loop for the total number of elements

    nd(1)=nodes(iel,1); % 1st connected node for (iel)-th element

    nd(2)=nodes(iel,2); % 2nd connected node for (iel)-th element

    nd(3)=nodes(iel,3); % 3rd connected node for (iel)-th element

    x1=gcoord(nd(1),1); y1=gcoord(nd(1),2);% coord values of 1st node

    x2=gcoord(nd(2),1); y2=gcoord(nd(2),2);% coord values of 2nd node

    x3=gcoord(nd(3),1); y3=gcoord(nd(3),2);% coord values of 3rd node

    index=feeldof(nd,nnel,ndof);% extract system dofs associated with element

    k=felp2dt3(x1,y1,x2,y2,x3,y3); % compute element matrix

     m=felpt2t3(x1,y1,x2,y2,x3,y3); % compute element matrix

    kk=feasmbl1(kk,k,index); % assemble element matrices

     mm=feasmbl1(mm,m,index); % assemble element matrices

    end

    %-----------------------------

    % loop for time integration

    %-----------------------------

    for in=1:sdof

    fsol(in)=0.0; % initial condition

    end

    sol(1,1)=fsol(8); % store time history solution for node no. 8

    sol(2,1)=fsol(9); % store time history solution for node no. 9

    for it=1:ntime % start loop for time integration

    fn=deltt*ff+(mm-deltt*kk)*fsol; % compute effective column vector

    [mm,fn]=feaplyc2(mm,fn,bcdof,bcval); % apply boundary condition

    fsol=mm\fn; % solve the matrix equation

    sol(1,it+1)=fsol(8); % store time history solution for node no. 8

    sol(2,it+1)=fsol(9); % store time history solution for node no. 9

    end

    8

  • 8/21/2019 me471s03_lec09

    9/12

    %------------------------------------

    % plot the solution at nodes 8 and 9

    %------------------------------------

    close all

    time=0:deltt:ntime*deltt;

    for k=1:ntime+1esol(k)=cntr((k-1)*deltt, 20, 2.5);

    end

    plot(time,sol(1,:),’*’,time,sol(2,:),’-’, time, esol,’o’);

    xlabel(’Time’)

    ylabel(’Solution at specified nodes’)

    legend(’node 8’, ’node 9’, ’node 8 exact’,0)

    %---------------------------------------------------------------

    function [index]=feeldof(nd,nnel,ndof)

    %----------------------------------------------------------

    % Purpose:% Compute system dofs associated with each element

    %

    % Synopsis:

    % [index]=feeldof(nd,nnel,ndof)

    %

    % Variable Description:

    % index - system dof vector associated with element "iel"

    % iel - element number whose system dofs are to be determined

    % nnel - number of nodes per element

    % ndof - number of dofs per node

    %-----------------------------------------------------------

    edof = nnel*ndof;

    k=0;

    for i=1:nnel

    start = (nd(i)-1)*ndof;

    for j=1:ndof

    k=k+1;

    index(k)=start+j;

    end

    end

    function [k]=felp2dt3(x1,y1,x2,y2,x3,y3)

    %-------------------------------------------------------------------

    % Purpose:

    % element matrix for two-dimensional Laplace’s equation

    % using three-node linear triangular element

    %

    % Synopsis:

    % [k]=felp2dt3(x1,y1,x2,y2,x3,y3)

    %

    9

  • 8/21/2019 me471s03_lec09

    10/12

    % Variable Description:

    % k - element stiffness matrix (size of 3x3)

    % x1, y1 - x and y coordinate values of the first node of element

    % x2, y2 - x and y coordinate values of the second node of element

    % x3, y3 - x and y coordinate values of the third node of element

    %-------------------------------------------------------------------

    % element matrix

    A=0.5*(x2*y3+x1*y2+x3*y1-x2*y1-x1*y3-x3*y2); % area of the triangule

    k(1,1)=((x3-x2)^2+(y2-y3)^2)/(4*A);

    k(1,2)=((x3-x2)*(x1-x3)+(y2-y3)*(y3-y1))/(4*A);

    k(1,3)=((x3-x2)*(x2-x1)+(y2-y3)*(y1-y2))/(4*A);

    k(2,1)=k(1,2);

    k(2,2)=((x1-x3)^2+(y3-y1)^2)/(4*A);

    k(2,3)=((x1-x3)*(x2-x1)+(y3-y1)*(y1-y2))/(4*A);

    k(3,1)=k(1,3);

    k(3,2)=k(2,3);

    k(3,3)=((x2-x1)^2+(y1-y2)^2)/(4*A);

    function [m]=felpt2t3(x1,y1,x2,y2,x3,y3)

    %-------------------------------------------------------------------

    % Purpose:

    % element matrix for transient term of two-dimensional

    % Laplace’s equation using linear triangular element

    %

    % Synopsis:

    % [m]=felpt2t3(x1,y1,x2,y2,x3,y3)

    %

    % Variable Description:

    % m - element stiffness matrix (size of 3x3)

    % x1, y1 - x and y coordinate values of the first node of element

    % x2, y2 - x and y coordinate values of the second node of element

    % x3, y3 - x and y coordinate values of the third node of element

    %-------------------------------------------------------------------

    % element matrix

    A=0.5*(x2*y3+x1*y2+x3*y1-x2*y1-x1*y3-x3*y2); % area of the triangle

     m = (A/12)* [ 2 1 1;

    1 2 1;

    1 1 2 ];

    function [kk]=feasmbl1(kk,k,index)

    %----------------------------------------------------------

    % Purpose:

    % Assembly of element matrices into the system matrix

    %

    % Synopsis:

    10

  • 8/21/2019 me471s03_lec09

    11/12

    % [kk]=feasmbl1(kk,k,index)

    %

    % Variable Description:

    % kk - system matrix

    % k - element matri

    % index - d.o.f. vector associated with an element

    %-----------------------------------------------------------

    edof = length(index);

    for i=1:edof

    ii=index(i);

    for j=1:edof

    jj=index(j);

    kk(ii,jj)=kk(ii,jj)+k(i,j);

    end

    end

    function [kk,ff]=feaplyc2(kk,ff,bcdof,bcval)

    %----------------------------------------------------------

    % Purpose:

    % Apply constraints to matrix equation [kk]{x}={ff}

    %

    % Synopsis:

    % [kk,ff]=feaplybc(kk,ff,bcdof,bcval)

    %

    % Variable Description:

    % kk - system matrix before applying constraints

    % ff - system vector before applying constraints

    % bcdof - a vector containging constrained d.o.f

    % bcval - a vector containing contained value

    %

    % For example, there are constraints at d.o.f=2 and 10

    % and their constrained values are 0.0 and 2.5,

    % respectively. Then, bcdof(1)=2 and bcdof(2)=10; and

    % bcval(1)=1.0 and bcval(2)=2.5.

    %-----------------------------------------------------------

    n=length(bcdof);

    sdof=size(kk);

    for i=1:n

    c=bcdof(i);

    for j=1:sdof

    kk(c,j)=0;

    end

    kk(c,c)=1;

    ff(c)=bcval(i);

    end

    %-----------------------------------------------------------

    function u=cntr(t,n,lx)

    11

  • 8/21/2019 me471s03_lec09

    12/12

    % exact solution at the center node

    % t=time, n=number of terms in sum, lx=half-length of region

    v=1:2:2*n+1; %n+1 terms

    w=cos((0:n)*pi);

    lam=pi*v/(2*lx);

    series=w.*(v.^-1).*exp(-(lam.^2)*t);

    u=100-(400/pi)*sum(series);

    12