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

QCAD_SchrodingerProblem.cpp

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 "QCAD_SchrodingerProblem.hpp"
00008 #include "QCAD_MaterialDatabase.hpp"
00009 
00010 #include "Intrepid_FieldContainer.hpp"
00011 #include "Intrepid_DefaultCubatureFactory.hpp"
00012 #include "Shards_CellTopology.hpp"
00013 #include "PHAL_FactoryTraits.hpp"
00014 
00015 #include "Albany_Utils.hpp"
00016 
00017 
00018 QCAD::SchrodingerProblem::SchrodingerProblem( const Teuchos::RCP<Teuchos::ParameterList>& params_,
00019         const Teuchos::RCP<ParamLib>& paramLib_,
00020         const int numDim_,
00021         const Teuchos::RCP<const Epetra_Comm>& comm_) :
00022   Albany::AbstractProblem(params_, paramLib_, 1),
00023   comm(comm_), havePotential(false), 
00024   numDim(numDim_)
00025 {
00026   havePotential = params->isSublist("Potential");
00027 
00028   //Note: can't use get("ParamName" , <default>) form b/c non-const
00029   energy_unit_in_eV = 1.0; //default eV
00030   if(params->isType<double>("Energy Unit In Electron Volts"))
00031     energy_unit_in_eV = params->get<double>("Energy Unit In Electron Volts");
00032   *out << "Energy unit = " << energy_unit_in_eV << " eV" << std::endl;
00033 
00034   length_unit_in_m = 1e-6; //default to um
00035   if(params->isType<double>("Length Unit In Meters"))
00036     length_unit_in_m = params->get<double>("Length Unit In Meters");
00037   *out << "Length unit = " << length_unit_in_m << " meters" << std::endl;
00038 
00039   mtrlDbFilename = "materials.xml";
00040   if(params->isType<std::string>("MaterialDB Filename"))
00041     mtrlDbFilename = params->get<std::string>("MaterialDB Filename");
00042 
00043   bOnlySolveInQuantumBlocks = false;
00044   if(params->isType<bool>("Only solve in quantum blocks"))
00045     bOnlySolveInQuantumBlocks = params->get<bool>("Only solve in quantum blocks");
00046 
00047 
00048   potentialFieldName = "V"; // name for potential at QPs field
00049   potentialAuxIndex = -1; // if >= 0, index within workset's auxData multivector to import potential from
00050 
00051   //Extract Aux index if necessary:
00052   // Note: we can't do this from within SchrodingerPotential evaluator
00053   // since it isn't created in the case of importing from an aux vector.
00054   if(params->isSublist("Potential")) {
00055     Teuchos::ParameterList& pList = params->sublist("Potential");
00056     if(pList.isType<std::string>("Type")) {
00057       if(pList.get<std::string>("Type") == "From Aux Data Vector") {
00058 
00059   //do Potential list validation since SchrodingerPotential evaluator doesn't
00060   // ** maybe we should allow other values from SchrodingerPotential as well? **
00061   Teuchos::ParameterList validPL("Valid Schrodinger Potential Params");
00062   validPL.set<std::string>("Type", "defaultType", "Switch between different potential types");
00063   validPL.set<int>("Aux Index", 0, "Index of aux vector to import potential from.");
00064   pList.validateParameters(validPL, 0);
00065 
00066   potentialAuxIndex = pList.get<int>("Aux Index"); //error if doesn't exist
00067       }
00068     }
00069   }
00070 
00071   TEUCHOS_TEST_FOR_EXCEPTION(params->isSublist("Source Functions"), Teuchos::Exceptions::InvalidParameter,
00072          "\nError! Schrodinger problem does not parse Source Functions sublist\n" 
00073                      << "\tjust Potential sublist " << std::endl);
00074 }
00075 
00076 QCAD::SchrodingerProblem::
00077 ~SchrodingerProblem()
00078 {
00079 }
00080 
00081 void
00082 QCAD::SchrodingerProblem::
00083 buildProblem(
00084   Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> >  meshSpecs,
00085   Albany::StateManager& stateMgr)
00086 {
00087   /* Construct All Phalanx Evaluators */
00088   TEUCHOS_TEST_FOR_EXCEPTION(meshSpecs.size()!=1,std::logic_error,"Problem supports one Material Block");
00089   fm.resize(1);
00090   fm[0]  = Teuchos::rcp(new PHX::FieldManager<PHAL::AlbanyTraits>);
00091   buildEvaluators(*fm[0], *meshSpecs[0], stateMgr, Albany::BUILD_RESID_FM, 
00092       Teuchos::null);
00093   constructDirichletEvaluators(*meshSpecs[0]);
00094 }
00095 
00096 Teuchos::Array< Teuchos::RCP<const PHX::FieldTag> >
00097 QCAD::SchrodingerProblem::
00098 buildEvaluators(
00099   PHX::FieldManager<PHAL::AlbanyTraits>& fm0,
00100   const Albany::MeshSpecsStruct& meshSpecs,
00101   Albany::StateManager& stateMgr,
00102   Albany::FieldManagerChoice fmchoice,
00103   const Teuchos::RCP<Teuchos::ParameterList>& responseList)
00104 {
00105   // Call constructeEvaluators<EvalT>(*rfm[0], *meshSpecs[0], stateMgr);
00106   // for each EvalT in PHAL::AlbanyTraits::BEvalTypes
00107   Albany::ConstructEvaluatorsOp<SchrodingerProblem> op(
00108     *this, fm0, meshSpecs, stateMgr, fmchoice, responseList);
00109   boost::mpl::for_each<PHAL::AlbanyTraits::BEvalTypes>(op);
00110   return *op.tags;
00111 }
00112 
00113 void
00114 QCAD::SchrodingerProblem::constructDirichletEvaluators(
00115         const Albany::MeshSpecsStruct& meshSpecs)
00116 {
00117    // Construct Dirichlet evaluators for all nodesets and names
00118    std::vector<std::string> dirichletNames(neq);
00119    dirichletNames[0] = "psi";
00120    Albany::BCUtils<Albany::DirichletTraits> dirUtils;
00121    dfm = dirUtils.constructBCEvaluators(meshSpecs.nsNames, dirichletNames,
00122                                           this->params, this->paramLib);
00123 }
00124 
00125 Teuchos::RCP<const Teuchos::ParameterList>
00126 QCAD::SchrodingerProblem::getValidProblemParameters() const
00127 {
00128   Teuchos::RCP<Teuchos::ParameterList> validPL =
00129     this->getGenericProblemParams("ValidSchrodingerProblemParams");
00130 
00131   if (numDim==1)
00132     validPL->set<bool>("Periodic BC", false, "Flag to indicate periodic BC for 1D problems");
00133 
00134   validPL->set<double>("Energy Unit In Electron Volts",1.0,"Energy unit in electron volts");
00135   validPL->set<double>("Length Unit In Meters",1e-6,"Length unit in meters");
00136   validPL->set<std::string>("MaterialDB Filename","materials.xml","Filename of material database xml file");
00137   validPL->set<bool>("Only solve in quantum blocks", false,"Only perform Schrodinger solve in element blocks marked as quatum regions.");
00138 
00139   validPL->sublist("Potential", false, "");
00140 
00141   return validPL;
00142 }
00143 

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