      subroutine estatem
*
*  compute thermodynamic quantities for the compsition just specified 
*  by ccomp.  use the additive volume technique (see istatco for ref).
*  see Fontaine, Graboske & Van Horn 1977, ApJS, 35, 293
*
      implicit double precision(a-h,o-z)

      common/je/je
      common/comp/amhyhe,amheca,x(4)
      common/c/az(3),z(3),taux,ts,ps,sm,rs,err,te,gs,rho,ol1x,rl1x,el1x
     1  ,atgx,rtgx,tl,pl,xmass,acu,am,bk,an0,pi
      common/grad/ drdtp(400),cp(400),ttg(400),drdtpx,cpx,pecx,ttgx,
     1  deptx,dpdr,dtdr,dmdr,dr,xr,xt,cv,drdptx
*
*  initialize summation variables
*
        rhotmp  = 0.0
        etatmp  = 0.0
        cptmp   = 0.0
        cpdatmp = 0.0
        deltmp  = 0.0
        dpttmp  = 0.0
        dtptmp  = 0.0
*
*  call estate for each composition i for which x(i) ne 0.
*
        do 100 je = 1,3
           if ( x(je) .gt. 0. ) then
              xx = x(je)
              xje = xx
              call estate
              rhotmp = rhotmp + xje/ rho
              etatmp = etatmp + xje * el1x
              cptmp  = cptmp + xje * cpx 
              cpdatmp = cpdatmp + xje * cpx * atgx 
              dpttmp = dpttmp + xje / ( rho * drdptx )
              dtptmp = dtptmp + xje / ( rho * drdtpx )
           endif
100     continue
*
*  now some final polishing and we're finished
*
        rho    = 1/rhotmp
        rl1x   = dlog10(rho)
        el1x   = etatmp
        cpx    = cptmp
        atgx   = cpdatmp / cpx
        drdptx = 1. / (rho * dpttmp)
        drdtpx = 1. / (rho * dtptmp)
        xr     = -1./ drdptx
        xt     = -drdtpx / drdptx
        cv     = cpx * ( 1. - xt * atgx )
        return
        end

************************************************************************

