subroutine compute_plastic_params (params,mat)

use constants
use definitions
!use mpi

implicit none

include 'mpif.h'

type (parameters) params
type (material) :: mat(0:params%nmat)

double precision c,k,alpha,phi
integer i,iproc,nproc,ierr

call mpi_comm_size (mpi_comm_world,nproc,ierr)
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

do i=0,params%nmat
  select case (trim(mat(i)%plasticity_type))
    case ('No')

    case ('vM')

    case ('DPI')
      phi   = mat(i)%plasticity_parameters(1)*pi/180.d0
      c     = mat(i)%plasticity_parameters(2)
      alpha = (2.d0*sin(phi))  /(sqrt(3.d0)*(3.d0-sin(phi)))
      k     = (6.d0*c*cos(phi))/(sqrt(3.d0)*(3.d0-sin(phi)))
      mat(i)%plasticity_parameters(8) = alpha
      mat(i)%plasticity_parameters(9) = k

    case ('DPII')
      phi   = mat(i)%plasticity_parameters(1)*pi/180.d0
      c     = mat(i)%plasticity_parameters(2)
      alpha = (2.d0*sin(phi))  /(sqrt(3.d0)*(3.d0+sin(phi)))
      k     = (6.d0*c*cos(phi))/(sqrt(3.d0)*(3.d0+sin(phi)))
      mat(i)%plasticity_parameters(8) = alpha
      mat(i)%plasticity_parameters(9) = k

    case ('DPIII')
      phi   = mat(i)%plasticity_parameters(1)*pi/180.d0
      c     = mat(i)%plasticity_parameters(2)
      alpha = (2.d0*sin(phi))  /(sqrt(3.d0)*3.d0)
      k     = (6.d0*c*cos(phi))/(sqrt(3.d0)*3.d0)
      mat(i)%plasticity_parameters(8) = alpha
      mat(i)%plasticity_parameters(9) = k

    case ('DPIV')
      phi   = mat(i)%plasticity_parameters(1)*pi/180.d0
      c     = mat(i)%plasticity_parameters(2)
      alpha = tan(phi)/(sqrt(9.d0+12.d0*(tan(phi))**2.d0))
      k     = (3.d0*c)/(sqrt(9.d0+12.d0*(tan(phi))**2.d0))
      mat(i)%plasticity_parameters(8) = alpha
      mat(i)%plasticity_parameters(9) = k

    case ('DPV')

    case ('DPVI')
      phi   = mat(i)%plasticity_parameters(1)*pi/180.d0
      mat(i)%plasticity_parameters(8) = tan(phi)

    case ('DPVII')
      phi   = mat(i)%plasticity_parameters(1)*pi/180.d0
      mat(i)%plasticity_parameters(8) = sin(phi)
      mat(i)%plasticity_parameters(9) = cos(phi)

    case ('MC')
      phi   = mat(i)%plasticity_parameters(1)*pi/180.d0
      mat(i)%plasticity_parameters(8) = sin(phi)
      mat(i)%plasticity_parameters(9) = cos(phi)

    case ('Tresca')

    case default
      call stop_run('error in compute_plastic_params$')

  end select
  if (iproc.eq.0) then
    write(8,*) 'material ',i,'plasticity_type ',mat(i)%plasticity_type
    write(8,*) 'plasticity_parameters',mat(i)%plasticity_parameters(:)
  end if
end do

return
end