00001
00002
00003
00004
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
00032 materialDB = p.get< Teuchos::RCP<QCAD::MaterialDatabase> >("MaterialDB");
00033
00034
00035 typ = perm_list->get("Permittivity Type", "Constant");
00036
00037
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
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
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
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
00073
00074 position_dependent = false;
00075 temp_dependent = false;
00076 }
00077
00078
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
00088
00089 else
00090 {
00091 TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00092 "Invalid Permittivity Type: " << typ);
00093 }
00094
00095
00096
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
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
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
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
00162 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00163
00164 for (std::size_t qp=0; qp < numQPs; ++qp)
00165 permittivity(cell,qp) = value;
00166 }
00167 }
00168
00169
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
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
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 }
00201 }
00202 }
00203
00204
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
00220
00221 if (n == "Permittivity")
00222 return constant_value;
00223
00224
00225 else if (n == "Permittivity Factor")
00226 return factor;
00227
00228
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