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 #include <core/LatticeUtils.h>
23 
24 EnumStringMap<SymmetryMode> symmMap(
25 	SymmetriesNone, "none",
26 	SymmetriesAutomatic, "automatic",
27 	SymmetriesManual, "manual" );
28 
29 struct CommandSymmetries : public Command
30 {
CommandSymmetriesCommandSymmetries31 	CommandSymmetries() : Command("symmetries", "jdftx/Miscellaneous")
32 	{
33 		format = "<symm>=" + symmMap.optionList();
34 		comments = "+ none: symmetries are off\n"
35 			"+ automatic: automatic calculation of symmetries (default)\n"
36 			"+ manual: symmetries specified using symmetry-matrix command.";
37 		hasDefault = true;
38 	}
39 
processCommandSymmetries40 	void process(ParamList& pl, Everything& e)
41 	{	pl.get(e.symm.mode, SymmetriesAutomatic, symmMap, "symm");
42 	}
43 
printStatusCommandSymmetries44 	void printStatus(Everything& e, int iRep)
45 	{	logPrintf("%s", symmMap.getString(e.symm.mode));
46 	}
47 }
48 commandSymmetries;
49 
50 
51 struct CommandSymmetryMatrix : public Command
52 {
CommandSymmetryMatrixCommandSymmetryMatrix53 	CommandSymmetryMatrix() : Command("symmetry-matrix", "jdftx/Miscellaneous")
54 	{
55 		format = " \\\n\t<s00> <s01> <s02> \\\n\t<s10> <s11> <s12> \\\n\t<s20> <s21> <s22> \\\n\t<a0> <a1> <a2>";
56 		comments = "Specify symmetry operator matrices explicitly. The top 3 x 3 block\n"
57 			"contains the integer rotation matrix in lattice coordinates, while the\n"
58 			"final row contains the subsequent translation in lattice coordinates.\n"
59 			"Requires symmetries command to be called with manual argument.";
60 		allowMultiple = true;
61 
62 		require("symmetries");
63 	}
64 
processCommandSymmetryMatrix65 	void process(ParamList& pl, Everything& e)
66 	{	if(e.symm.mode != SymmetriesManual)
67 			throw string("symmetry-matrix needs symmetries to be called with \"manual\"");
68 
69 		SpaceGroupOp op;
70 		for(int j=0; j<3; j++) for(int k=0; k<3; k++)
71 		{	ostringstream oss; oss << "s" << j << k;
72 			pl.get(op.rot(j,k), 0, oss.str(), true);
73 		}
74 		for(int k=0; k<3; k++)
75 		{	ostringstream oss; oss << "a" << k;
76 			pl.get(op.a[k], 0., oss.str(), true);
77 		}
78 		e.symm.sym.push_back(op);
79 	}
80 
printStatusCommandSymmetryMatrix81 	void printStatus(Everything& e, int iRep)
82 	{	for (int j=0; j < 3; j++)
83 		{	logPrintf(" \\\n\t");
84 			for(int k=0; k<3; k++) logPrintf("%d ",e.symm.sym[iRep].rot(j,k));
85 		}
86 		logPrintf(" \\\n\t");
87 		for(int k=0; k<3; k++) logPrintf("%lg ",e.symm.sym[iRep].a[k]);
88 	}
89 }
90 commandSymmetryMatrix;
91 
92 
93 struct CommandSymmetryThreshold : public Command
94 {
CommandSymmetryThresholdCommandSymmetryThreshold95 	CommandSymmetryThreshold() : Command("symmetry-threshold", "jdftx/Miscellaneous")
96 	{
97 		format = "[<threshold>=1e-4]";
98 		comments = "Relative threshold parameter used for symmetry detection.";
99 		hasDefault = true;
100 	}
101 
processCommandSymmetryThreshold102 	void process(ParamList& pl, Everything& e)
103 	{	pl.get(symmThreshold, 1e-4, "threshold");
104 		symmThresholdSq = symmThreshold*symmThreshold;
105 	}
106 
printStatusCommandSymmetryThreshold107 	void printStatus(Everything& e, int iRep)
108 	{	logPrintf("%lg", symmThreshold);
109 	}
110 }
111 commandSymmetryThreshold;
112 
113 struct CommandKpointReduceInversion : public Command
114 {
CommandKpointReduceInversionCommandKpointReduceInversion115 	CommandKpointReduceInversion() : Command("kpoint-reduce-inversion", "jdftx/Electronic/Parameters")
116 	{
117 		format = "yes|no";
118 		comments =
119 			"Whether to use inversion symmetry to reduce k-point mesh,\n"
120 			"even when system is not inversion symmetric (using inversion\n"
121 			"+ complex-conjugation symmetry in a real potential).\n"
122 			"Default: yes.";
123 	}
124 
processCommandKpointReduceInversion125 	void process(ParamList& pl, Everything& e)
126 	{	pl.get(e.symm.kReduceUseInversion, true, boolMap, "useInversion", true);
127 	}
128 
printStatusCommandKpointReduceInversion129 	void printStatus(Everything& e, int iRep)
130 	{	logPrintf("%s", boolMap.getString(e.symm.kReduceUseInversion));
131 	}
132 }
133 commandKpointReduceInversion;
134