1 /*-------------------------------------------------------------------
2 Copyright 2011 Ravishankar Sundararaman
3 
4 This file is part of JDFTx.
5 
6 JDFTx is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10 
11 JDFTx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with JDFTx.  If not, see <http://www.gnu.org/licenses/>.
18 -------------------------------------------------------------------*/
19 
20 #include <commands/command.h>
21 #include <electronic/Everything.h>
22 
23 struct CommandKpoint : public Command
24 {
CommandKpointCommandKpoint25 	CommandKpoint() : Command("kpoint", "jdftx/Electronic/Parameters")
26 	{
27 		format = "<k0> <k1> <k2> <weight>";
28 		comments =
29 		  "Specify kpoint at lattice coordinates (<k0>, <k1>, <k2>) with weight <weight>.\n"
30 		  "A single k-point at 0,0,0 (Gamma point) with weight 1 is used if unspecified.";
31 		allowMultiple = true;
32 		hasDefault = true;
33 	}
34 
processCommandKpoint35 	void process(ParamList& pl, Everything& e)
36 	{	QuantumNumber qnum;
37 		for(int k=0; k<3; k++)
38 		{	ostringstream oss; oss << "k" << k;
39 			pl.get(qnum.k[k], 0.0, oss.str());
40 		}
41 		pl.get(qnum.weight, 1.0, "weight");
42 		e.eInfo.qnums.push_back(qnum);
43 		e.eInfo.nStates = e.eInfo.qnums.size();
44 	}
45 
printStatusCommandKpoint46 	void printStatus(Everything& e, int iRep)
47 	{	const QuantumNumber& qnum = e.eInfo.qnums[iRep];
48 		for(int k=0; k<3; k++) logPrintf("%16.12lf ", qnum.k[k]);
49 		logPrintf("%17.14lf", qnum.weight);
50 	}
51 }
52 commandKpoint;
53 
54 struct CommandKpointFolding : public Command
55 {
CommandKpointFoldingCommandKpointFolding56 	CommandKpointFolding() : Command("kpoint-folding", "jdftx/Electronic/Parameters")
57 	{
58 		format = "[<n0>=1] [<n1>=1] [<n2>=1]";
59 		comments = "Fold k-points in direction i by factor <ni> (for i=0,1,2)";
60 		hasDefault = true;
61 
62 		require("kpoint");
63 	}
64 
processCommandKpointFolding65 	void process(ParamList& pl, Everything& e)
66 	{	for(int k=0; k<3; k++)
67 		{	ostringstream oss; oss << "n" << k;
68 			string paramName = oss.str();
69 			pl.get(e.eInfo.kfold[k], 1, paramName);
70 			if(e.eInfo.kfold[k]<1) throw string("<" + paramName + "> must be positive");
71 		}
72 	}
73 
printStatusCommandKpointFolding74 	void printStatus(Everything& e, int iRep)
75 	{	for(int k=0; k<3; k++) logPrintf("%d ", e.eInfo.kfold[k]);
76 	}
77 }
78 commandKpointFolding;
79