00001
00002
00003
00004
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
00029 energy_unit_in_eV = 1.0;
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;
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";
00049 potentialAuxIndex = -1;
00050
00051
00052
00053
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
00060
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");
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
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
00106
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
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