• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

TransportCoefficients_Def.hpp

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00003 //    This Software is released under the BSD license detailed     //
00004 //    in the file "license.txt" in the top-level Albany directory  //
00005 //*****************************************************************//
00006 
00007 #include "Teuchos_TestForException.hpp"
00008 #include "Phalanx_DataLayout.hpp"
00009 
00010 #include <Intrepid_MiniTensor.h>
00011 
00012 #include <typeinfo>
00013 
00014 namespace LCM {
00015 
00016   //----------------------------------------------------------------------------
00017   template<typename EvalT, typename Traits>
00018   TransportCoefficients<EvalT, Traits>::
00019   TransportCoefficients(Teuchos::ParameterList& p,
00020                         const Teuchos::RCP<Albany::Layouts>& dl) :
00021     c_lattice_(p.get<std::string>("Lattice Concentration Name"),dl->qp_scalar),
00022     temperature_(p.get<std::string>("Temperature Name"),dl->qp_scalar),
00023     k_eq_(p.get<std::string>("Concentration Equilibrium Parameter Name"),dl->qp_scalar),
00024     n_trap_(p.get<std::string>("Trapped Solvent Name"),dl->qp_scalar),
00025     c_trapped_(p.get<std::string>("Trapped Concentration Name"),dl->qp_scalar),
00026     eff_diff_(p.get<std::string>("Effective Diffusivity Name"),dl->qp_scalar),
00027     diffusion_coefficient_(p.get<std::string>("Diffusion Coefficient Name"),dl->qp_scalar),
00028     convection_coefficient_(p.get<std::string>("Tau Contribution Name"),dl->qp_scalar),
00029     total_concentration_(p.get<std::string>("Total Concentration Name"),dl->qp_scalar),
00030     F_(p.get<std::string>("Deformation Gradient Name"),dl->qp_tensor),
00031     F_mech_(p.get<std::string>("Mechanical Deformation Gradient Name"),dl->qp_tensor),
00032     J_(p.get<std::string>("Determinant of F Name"),dl->qp_scalar),
00033     strain_rate_fac_(p.get<std::string>("Strain Rate Factor Name"),dl->qp_scalar),
00034     weighted_average_(p.get<bool>("Weighted Volume Average J", false)),
00035     alpha_(p.get<RealType>("Average J Stabilization Parameter", 0.0))
00036   {
00037     // get the material parameter list
00038     Teuchos::ParameterList* mat_params = 
00039       p.get<Teuchos::ParameterList*>("Material Parameters");
00040 
00041     partial_molar_volume_ = mat_params->get<RealType>("Partial Molar Volume");
00042     pre_exponential_factor_ = mat_params->get<RealType>("Pre-exponential Factor");
00043     Q_ = mat_params->get<RealType>("Diffusion Activation Enthalpy");
00044     ideal_gas_constant_ = mat_params->get<RealType>("Ideal Gas Constant");
00045   trap_binding_energy_ = mat_params->get<RealType>("Trap Binding Energy");
00046     n_lattice_ = mat_params->get<RealType>("Number of Lattice Sites");
00047     ref_total_concentration_ = mat_params->get<RealType>("Reference Total Concentration");
00048     a_ = mat_params->get<RealType>("A Constant");
00049     b_ = mat_params->get<RealType>("B Constant");
00050     c_ = mat_params->get<RealType>("C Constant");
00051     // to express Avogadro's number in different units.
00052     avogadros_num_  = mat_params->get<RealType>("Avogadro's Number");
00053     lattice_strain_flag_= mat_params->get<bool>("Lattice Strain Flag");
00054   //  avogadros_num_ = 6.0221413e23;
00055 
00056     // if ( p.isType<bool>("Weighted Volume Average J") )
00057     //   weighted_average_ = p.get<bool>("Weighted Volume Average J");
00058     // if ( p.isType<RealType>("Average J Stabilization Parameter") )
00059     //   alpha_ = p.get<RealType>("Average J Stabilization Parameter");
00060 
00061     have_eqps_ = false;
00062     if ( p.isType<std::string>("Equivalent Plastic Strain Name") ) {
00063       have_eqps_ = true;
00064       PHX::MDField<ScalarT, Cell, QuadPoint> 
00065         tmp(p.get<std::string>("Equivalent Plastic Strain Name"), dl->qp_scalar);
00066       eqps_ = tmp;
00067     }
00068 
00069 
00070     this->addDependentField(F_);
00071     this->addDependentField(J_);
00072     this->addDependentField(temperature_);
00073     this->addDependentField(c_lattice_);
00074     if (have_eqps_) {
00075       this->addDependentField(eqps_);
00076     }
00077     this->addEvaluatedField(k_eq_);
00078     this->addEvaluatedField(n_trap_);
00079     this->addEvaluatedField(eff_diff_);
00080     this->addEvaluatedField(c_trapped_);
00081     this->addEvaluatedField(total_concentration_);
00082     this->addEvaluatedField(strain_rate_fac_);
00083     this->addEvaluatedField(diffusion_coefficient_);
00084     this->addEvaluatedField(convection_coefficient_);
00085     this->addEvaluatedField(F_mech_);
00086 
00087     this->setName("Transport Coefficients"+PHX::TypeString<EvalT>::value);
00088     std::vector<PHX::DataLayout::size_type> dims;
00089     dl->qp_tensor->dimensions(dims);
00090     worksetSize  = dims[0];
00091     num_pts_  = dims[1];
00092     num_dims_ = dims[2];
00093 
00094   }
00095 
00096   //----------------------------------------------------------------------------
00097   template<typename EvalT, typename Traits>
00098   void TransportCoefficients<EvalT, Traits>::
00099   postRegistrationSetup(typename Traits::SetupData d,
00100                         PHX::FieldManager<Traits>& fm)
00101   {
00102   this->utils.setFieldData(temperature_,fm);
00103     this->utils.setFieldData(c_lattice_,fm);
00104     this->utils.setFieldData(F_,fm);
00105     this->utils.setFieldData(F_mech_,fm);
00106     this->utils.setFieldData(J_,fm);
00107     if ( have_eqps_ ) {
00108       this->utils.setFieldData(eqps_,fm);
00109     }
00110     this->utils.setFieldData(k_eq_,fm);
00111     this->utils.setFieldData(c_trapped_,fm);
00112     this->utils.setFieldData(total_concentration_,fm);
00113     this->utils.setFieldData(n_trap_,fm);
00114     this->utils.setFieldData(eff_diff_,fm);
00115     this->utils.setFieldData(strain_rate_fac_,fm);
00116     this->utils.setFieldData(diffusion_coefficient_,fm);
00117     this->utils.setFieldData(convection_coefficient_,fm);
00118 
00119   }
00120 
00121   //----------------------------------------------------------------------------
00122   template<typename EvalT, typename Traits>
00123   void TransportCoefficients<EvalT, Traits>::
00124   evaluateFields(typename Traits::EvalData workset)
00125   {
00126     ScalarT theta_term(0.0);
00127 
00128     // Diffusion Coefficient
00129     for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00130       for (std::size_t pt=0; pt < num_pts_; ++pt) {
00131 
00132         diffusion_coefficient_(cell,pt) = pre_exponential_factor_*
00133                                                                        std::exp(-1.0*Q_/
00134                                                             (ideal_gas_constant_*
00135                                                             temperature_(cell,pt)));
00136       }
00137     }
00138 
00139     // Convection Coefficient
00140     for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00141       for (std::size_t pt=0; pt < num_pts_; ++pt) {
00142 
00143         convection_coefficient_(cell,pt) = partial_molar_volume_*
00144                                                         diffusion_coefficient_(cell,pt)/
00145                                                             (ideal_gas_constant_*
00146                                                             temperature_(cell,pt));
00147       }
00148     }
00149 
00150     // equilibrium constant k_T = e^(W_b/RT)
00151     for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00152       for (std::size_t pt=0; pt < num_pts_; ++pt) {
00153 
00154         k_eq_(cell,pt) = std::exp(trap_binding_energy_/
00155                                                        ( ideal_gas_constant_ *
00156                                                         temperature_(cell,pt)));
00157    //     std::cout  << "k_eq_" << k_eq_(cell,pt) << std::endl;
00158       }
00159     }
00160 
00161     /*
00162     // theta term C_T
00163     for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00164       for (std::size_t pt(0); pt < num_pts_; ++pt) {
00165         theta_term = k_eq_(cell,pt) * c_lattice_(cell,pt) / 
00166           ( k_eq_(cell,pt) * c_lattice_(cell,pt) + n_lattice_ );
00167       }
00168     }
00169     */
00170     
00171     // trapped solvent
00172     if (have_eqps_) {
00173       for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00174         for (std::size_t pt(0); pt < num_pts_; ++pt) {
00175           n_trap_(cell,pt) = (1.0/avogadros_num_) * 
00176                                            std::pow( 10.0, (a_ - b_ *
00177                                                std::exp( -c_ * eqps_(cell,pt) ))  );
00178     //     std::cout  << "ntrap" << n_trap_(cell,pt) << std::endl;
00179         }
00180       }
00181     }
00182     else
00183     {
00184       for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00185         for (std::size_t pt(0); pt < num_pts_; ++pt) {
00186           n_trap_(cell,pt) = (1.0/avogadros_num_) * std::pow( 10.0, (a_ - b_ ));
00187         }
00188       }
00189     }
00190     
00191     // strain rate factor
00192     if (have_eqps_) {
00193       for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00194         for (std::size_t pt(0); pt < num_pts_; ++pt) {
00195             theta_term = k_eq_(cell,pt) * c_lattice_(cell,pt) /
00196               ( k_eq_(cell,pt) * c_lattice_(cell,pt) + n_lattice_ );
00197 
00198           strain_rate_fac_(cell,pt) = theta_term * n_trap_(cell,pt) * 
00199             std::log(10.0) * b_ * c_ * std::exp( -c_ * eqps_(cell,pt) );
00200         }
00201       }
00202     }
00203     else
00204     {
00205       for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00206         for (std::size_t pt(0); pt < num_pts_; ++pt) {
00207             theta_term = k_eq_(cell,pt) * c_lattice_(cell,pt) /
00208               ( k_eq_(cell,pt) * c_lattice_(cell,pt) + n_lattice_ );
00209 
00210               strain_rate_fac_(cell,pt) = theta_term * n_trap_(cell,pt) *
00211               std::log(10.0) * b_ * c_;
00212         }
00213       }
00214     }
00215 
00216     // trapped conecentration
00217     for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00218       for (std::size_t pt(0); pt < num_pts_; ++pt) {
00219           theta_term = k_eq_(cell,pt) * c_lattice_(cell,pt) /
00220             ( k_eq_(cell,pt) * c_lattice_(cell,pt) + n_lattice_ );
00221 
00222         c_trapped_(cell,pt) = theta_term * n_trap_(cell,pt);
00223       }
00224     }
00225     
00226     // total concentration
00227     for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00228       for (std::size_t pt(0); pt < num_pts_; ++pt) {
00229         total_concentration_(cell, pt) = c_trapped_(cell,pt) +
00230                                                          c_lattice_(cell,pt);
00231       }
00232     }
00233 
00234     // effective diffusivity
00235     for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00236       for (std::size_t pt(0); pt < num_pts_; ++pt) {
00237         eff_diff_(cell,pt) = 1.0 + n_trap_(cell,pt) * n_lattice_ /
00238           (  k_eq_(cell,pt) * c_lattice_(cell,pt) * c_lattice_(cell,pt) ) /
00239           ( ( 1.0 + n_lattice_ / k_eq_(cell,pt) / c_lattice_(cell,pt) ) *
00240             ( 1.0 + n_lattice_ / k_eq_(cell,pt) / c_lattice_(cell,pt) ) );
00241       }
00242     }
00243 
00244     // deformation gradient volumetric split for lattice concentration
00245     Intrepid::Tensor<ScalarT> Fmech(num_dims_);
00246 
00247     for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00248       for (std::size_t pt(0); pt < num_pts_; ++pt) {
00249         Fmech.fill( &F_(cell,pt,0,0) );
00250           for (std::size_t i(0); i < num_dims_; ++i) {
00251             for (std::size_t j(0); j < num_dims_; ++j) {
00252               F_mech_(cell,pt,i,j) = Fmech(i,j);
00253             }
00254           }
00255       }
00256     }
00257     // Since Intrepid will later perform calculations on the entire workset size
00258     // and not just the used portion, we must fill the excess with reasonable
00259     // values. Leaving this out leads to inversion of 0 tensors.
00260     for (std::size_t cell=workset.numCells; cell < worksetSize; ++cell)
00261       for (std::size_t qp=0; qp < num_pts_; ++qp)
00262         for (std::size_t i=0; i < num_dims_; ++i)
00263           F_mech_(cell,qp,i,i) = 1.0;
00264 
00265    ScalarT lambda_ =  partial_molar_volume_*n_lattice_/avogadros_num_;
00266    ScalarT JH(1.0);
00267 
00268    if (lattice_strain_flag_){
00269      for (std::size_t cell=0; cell < workset.numCells; ++cell)
00270           {
00271             for (std::size_t qp=0; qp < num_pts_; ++qp)
00272             {
00273               JH = 1.0 + lambda_*(total_concentration_(cell, qp)- ref_total_concentration_);
00274               for (std::size_t i=0; i < num_dims_; ++i)
00275               {
00276                 for (std::size_t j=0; j < num_dims_; ++j)
00277                 {
00278                   F_mech_(cell,qp,i,j) *= std::pow(JH ,-1./3. );
00279                 }
00280               }
00281             }
00282           }
00283    }
00284 
00285 
00286   }
00287   //----------------------------------------------------------------------------
00288 }
00289 

Generated on Wed Mar 26 2014 18:36:46 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1