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

QCAD_Permittivity_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 <fstream>
00008 #include "Teuchos_TestForException.hpp"
00009 #include "Phalanx_DataLayout.hpp"
00010 #include "Sacado_ParameterRegistration.hpp"
00011 
00012 template<typename EvalT, typename Traits>
00013 QCAD::Permittivity<EvalT, Traits>::
00014 Permittivity(Teuchos::ParameterList& p,
00015              const Teuchos::RCP<Albany::Layouts>& dl) :
00016   permittivity(p.get<std::string>("QP Variable Name"), dl->qp_scalar),
00017   temp_dependent(false), position_dependent(false)
00018 {
00019   Teuchos::ParameterList* perm_list = 
00020       p.get<Teuchos::ParameterList*>("Parameter List");
00021 
00022   Teuchos::RCP<const Teuchos::ParameterList> reflist = 
00023       this->getValidPermittivityParameters();
00024   perm_list->validateParameters(*reflist,0);
00025 
00026   std::vector<PHX::DataLayout::size_type> dims;
00027   dl->qp_vector->dimensions(dims);
00028   numQPs  = dims[1];
00029   numDims = dims[2];
00030 
00031   // Material database
00032   materialDB = p.get< Teuchos::RCP<QCAD::MaterialDatabase> >("MaterialDB");
00033 
00034   // Permittivity type
00035   typ = perm_list->get("Permittivity Type", "Constant");
00036   
00037   // Permittivity (relative) value is constant
00038   if (typ == "Constant") 
00039   {
00040     position_dependent = false;
00041     temp_dependent = false;
00042 
00043     constant_value = perm_list->get("Value", 1.0);
00044 
00045     // Add Permittivity as a Sacado-ized parameter
00046     Teuchos::RCP<ParamLib> paramLib = 
00047         p.get< Teuchos::RCP<ParamLib> >("Parameter Library", Teuchos::null);
00048     new Sacado::ParameterRegistration<EvalT, SPL_Traits>(
00049         "Permittivity", this, paramLib);
00050   }
00051   
00052   // Permittivity (relative) has temperature dependence
00053   else if (typ == "Temperature Dependent") 
00054   {
00055     position_dependent = false;
00056     temp_dependent = true;
00057 
00058     constant_value = perm_list->get("Value", 1.0);
00059     factor = perm_list->get("Factor", 1.0);
00060 
00061     // Add Permittivity as a Sacado-ized parameter
00062     Teuchos::RCP<ParamLib> paramLib = 
00063         p.get< Teuchos::RCP<ParamLib> >("Parameter Library", Teuchos::null);
00064     new Sacado::ParameterRegistration<EvalT, SPL_Traits>(
00065         "Permittivity", this, paramLib);
00066     new Sacado::ParameterRegistration<EvalT, SPL_Traits>(
00067         "Permittivity Factor", this, paramLib);
00068   }
00069 
00070   else if (typ == "Block Dependent") 
00071   {
00072     // So far *not* position dependent, since we don't need the coordinate vector (just the block name)
00073     // However, this would be set to true if there is a spatial distribution of permittivity within a single block
00074     position_dependent = false; 
00075     temp_dependent = false; 
00076   }
00077   
00078   // for testing 1D MOSCapacitor
00079   else if (typ == "Position Dependent")
00080   {
00081     position_dependent = true; 
00082     temp_dependent = false; 
00083     oxideWidth = perm_list->get("Oxide Width", 0.);
00084     siliconWidth = perm_list->get("Silicon Width", 0.);
00085   }
00086 
00087   // Parse for other functional form for permittivity variation here
00088   // This effectively validates the 2nd argument in perm_list->get (...);
00089   else 
00090   {
00091     TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00092            "Invalid Permittivity Type: " << typ);
00093   } 
00094 
00095 
00096   // Add coordinate dependence to permittivity evaluator
00097   if(position_dependent) {
00098     PHX::MDField<MeshScalarT,Cell,QuadPoint,Dim>
00099         tmp(p.get<std::string>("Coordinate Vector Name"), dl->qp_vector);
00100     coordVec = tmp;
00101     this->addDependentField(coordVec);
00102   }
00103 
00104   // Add temperature dependence to permittivity evaluator
00105   if(temp_dependent) {
00106     PHX::MDField<ScalarT,Cell,QuadPoint>
00107         tmp(p.get<std::string>("Temperature Variable Name"), dl->qp_scalar);
00108     Temp = tmp;
00109     this->addDependentField(Temp);
00110   }
00111 
00112   this->addEvaluatedField(permittivity);
00113   this->setName("Permittivity"+PHX::TypeString<EvalT>::value);
00114 }
00115 
00116 // **********************************************************************
00117 template<typename EvalT, typename Traits>
00118 void QCAD::Permittivity<EvalT, Traits>::
00119 postRegistrationSetup(typename Traits::SetupData d,
00120                       PHX::FieldManager<Traits>& fm)
00121 {
00122   this->utils.setFieldData(permittivity,fm);
00123   if (position_dependent) this->utils.setFieldData(coordVec,fm);
00124   if (temp_dependent) this->utils.setFieldData(Temp,fm);
00125 }
00126 
00127 // **********************************************************************
00128 template<typename EvalT, typename Traits>
00129 void QCAD::Permittivity<EvalT, Traits>::
00130 evaluateFields(typename Traits::EvalData workset)
00131 {
00132   // assign constant_value to permittivity defined in .hpp file
00133   if (typ == "Constant") 
00134   { 
00135     for (std::size_t cell=0; cell < workset.numCells; ++cell) 
00136     { 
00137       for (std::size_t qp=0; qp < numQPs; ++qp) 
00138       {
00139         permittivity(cell,qp) = constant_value;
00140       }
00141     }
00142   }
00143   
00144   // calculate temp-dep value and fill in the permittivity field
00145   else if (typ == "Temperature Dependent") 
00146   {
00147     for (std::size_t cell=0; cell < workset.numCells; ++cell) 
00148     {
00149       for (std::size_t qp=0; qp < numQPs; ++qp) 
00150       {
00151         ScalarT denom = 1.0 + factor * Temp(cell,qp);
00152         permittivity(cell,qp) = constant_value / denom;;
00153       }
00154     }
00155   }
00156 
00157   else if (typ == "Block Dependent") 
00158   { 
00159     const ScalarT& value = materialDB->getElementBlockParam<double>(workset.EBName,"Permittivity");
00160 
00161     // loop through all elements in one workset
00162     for (std::size_t cell=0; cell < workset.numCells; ++cell) { 
00163       // loop through the QPs for each element
00164       for (std::size_t qp=0; qp < numQPs; ++qp)
00165         permittivity(cell,qp) = value;
00166     }
00167   }
00168   
00169   // for testing 1D MOSCapacitor
00170   else if (typ == "Position Dependent")
00171   {
00172     MeshScalarT* coord;
00173     for (std::size_t cell=0; cell < workset.numCells; ++cell) 
00174     { 
00175       for (std::size_t qp=0; qp < numQPs; ++qp)
00176       {
00177         coord = &coordVec(cell,qp,0);
00178         
00179         // Silicon region
00180         if ( (coord[0] > oxideWidth) && (coord[0] <= (oxideWidth + siliconWidth)) )
00181         {
00182           const std::string matName = "Silicon";
00183           const ScalarT& value = materialDB->getMaterialParam<double>(matName,"Permittivity");
00184           permittivity(cell,qp) = value;
00185         }
00186         
00187         // Oxide region
00188         else if ((coord[0] >= 0) && (coord[0] <= oxideWidth))
00189         {
00190           const std::string matName = "SiliconDioxide";
00191           const ScalarT& value = materialDB->getMaterialParam<double>(matName,"Permittivity");
00192           permittivity(cell,qp) = value;
00193         }
00194         
00195         else
00196           TEUCHOS_TEST_FOR_EXCEPTION (true, Teuchos::Exceptions::InvalidParameter,
00197             std::endl << "Error!  x-coord:" << coord[0] << "is outside the oxideWidth" << 
00198             " + siliconWidth range: " << oxideWidth + siliconWidth << "!"<< std::endl);
00199         
00200       }  // end of loop over QPs
00201     }  // end of loop over cells
00202   }
00203   
00204   // otherwise, throw out error message and exit the program
00205   else 
00206   {
00207     std::cout << "Error: permittivity has to be either constant, " <<  
00208         "block dependent, or temperature dependent !" << std::endl;
00209     exit(1);
00210   } 
00211   
00212 }
00213 
00214 // **********************************************************************
00215 template<typename EvalT,typename Traits>
00216 typename QCAD::Permittivity<EvalT,Traits>::ScalarT& 
00217 QCAD::Permittivity<EvalT,Traits>::getValue(const std::string &n)
00218 {
00219   // constant permittivity, n must match the value string in the "Parameters"
00220   // section of the input.xml file as parameters for response analysis 
00221   if (n == "Permittivity")  
00222     return constant_value;
00223   
00224   // temperature factor used in the temp-dep permittivity calculation
00225   else if (n == "Permittivity Factor")
00226     return factor;
00227   
00228   // otherwise, throw out error message and continue the program
00229   else 
00230   {
00231     TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00232         std::endl <<
00233         "Error! Logic error in getting paramter " << n <<
00234         " in Permittivity::getValue()" << std::endl);
00235     return constant_value;
00236   }
00237 }
00238 
00239 // **********************************************************************
00240 template<typename EvalT,typename Traits>
00241 Teuchos::RCP<const Teuchos::ParameterList>
00242 QCAD::Permittivity<EvalT,Traits>::getValidPermittivityParameters() const
00243 {
00244   Teuchos::RCP<Teuchos::ParameterList> validPL =
00245       rcp(new Teuchos::ParameterList("Valid Permittivty Params"));;
00246 
00247   validPL->set<std::string>("Permittivity Type", "Constant", 
00248       "Constant permittivity in the entire device");
00249   validPL->set<double>("Value", 1.0, "Constant permittivity value");
00250   validPL->set<double>("Factor", 1.0, "Permittivity temperature factor");
00251 
00252   validPL->set<double>("Oxide Width", 0., "Oxide width for 1D MOSCapacitor device");
00253   validPL->set<double>("Silicon Width", 0., "Silicon width for 1D MOSCapacitor device");
00254 
00255   return validPL;
00256 }
00257 
00258 // **********************************************************************
00259 // **********************************************************************
00260 

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