Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2The ASE Calculator for OpenMX <http://www.openmx-square.org>: Python interface 

3to the software package for nano-scale material simulations based on density 

4functional theories. 

5 Copyright (C) 2018 Jae Hwan Shim and JaeJun Yu 

6 

7 This program is free software: you can redistribute it and/or modify 

8 it under the terms of the GNU Lesser General Public License as published by 

9 the Free Software Foundation, either version 2.1 of the License, or 

10 (at your option) any later version. 

11 

12 This program is distributed in the hope that it will be useful, 

13 but WITHOUT ANY WARRANTY; without even the implied warranty of 

14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

15 GNU Lesser General Public License for more details. 

16 

17 You should have received a copy of the GNU Lesser General Public License 

18 along with ASE. If not, see <http://www.gnu.org/licenses/>. 

19""" 

20from typing import List, Dict, Any 

21 

22from ase.calculators.calculator import Parameters 

23from ase.calculators.openmx.default_settings import default_dictionary 

24 

25 

26# Keys that have length 3 

27tuple_integer_keys = [ 

28 'scf.Ngrid', 

29 'scf.Kgrid', 

30 'Dos.Kgrid', 

31] 

32tuple_float_keys = [ 

33 'scf.Electric.Field', 

34 'scf.fixed.grid' 

35] 

36tuple_bool_keys: List[str] = [ 

37 

38] 

39integer_keys = [ 

40 'level.of.stdout', 

41 'level.of.fileout', 

42 'Species.Number', 

43 'Atoms.Number', 

44 'scf.maxIter', 

45 'scf.Mixing.History', 

46 'scf.Mixing.StartPulay', 

47 'scf.Mixing.EveryPulay', 

48 '1DFFT.NumGridK', 

49 '1DFFT.NumGridR', 

50 'orbitalOpt.scf.maxIter', 

51 'orbitalOpt.Opt.maxIter', 

52 'orbitalOpt.Opt.Method', 

53 'orbitalOpt.HistoryPulay', 

54 'Num.CntOrb.Atoms', 

55 'orderN.KrylovH.order', 

56 'orderN.KrylovS.order', 

57 'MD.maxIter', 

58 'MD.Opt.DIIS.History', 

59 'MD.Opt.StartDIIS', 

60 'Band.Nkpath', 

61 'num.HOMOs', 

62 'num.LUMOs', 

63 'MO.Nkpoint', 

64 'MD.Current.Iter' 

65] 

66float_keys = [ 

67 'scf.Constraint.NC.Spin.v', 

68 'scf.ElectronicTemperature', 

69 'scf.energycutoff', 

70 'scf.Init.Mixing.Weight', 

71 'scf.Min.Mixing.Weight', 

72 'scf.Max.Mixing.Weight', 

73 'scf.Kerker.factor', 

74 'scf.criterion', 

75 'scf.system.charge', 

76 '1DFFT.EnergyCutoff', 

77 'orbitalOpt.SD.step', 

78 'orbitalOpt.criterion', 

79 'orderN.HoppingRanges', 

80 'MD.TimeStep', 

81 'MD.Opt.criterion', 

82 'NH.Mass.HeatBath', 

83 'scf.NC.Mag.Field.Spin', 

84 'scf.NC.Mag.Field.Orbital', 

85] 

86string_keys = [ 

87 'System.CurrentDirectory', 

88 'System.Name', 

89 'DATA.PATH', 

90 'Atoms.SpeciesAndCoordinates.Unit', 

91 'Atoms.UnitVectors.Unit', 

92 'scf.XcType', 

93 'scf.SpinPolarization', 

94 'scf.Hubbard.Occupation', 

95 'scf.EigenvalueSolver', 

96 'scf.Mixing.Type', 

97 'orbitalOpt.Method', 

98 'orbitalOpt.StartPulay', 

99 'MD.Type', 

100 'Wannier.Initial.Projectors.Unit' 

101] 

102bool_keys = [ 

103 'scf.partialCoreCorrection', 

104 'scf.Hubbard.U', 

105 'scf.Constraint.NC.Spin', 

106 'scf.ProExpn.VNA', 

107 'scf.SpinOrbit.Coupling', 

108 'CntOrb.fileout', 

109 'orderN.Exact.Inverse.S', 

110 'orderN.Recalc.Buffer', 

111 'orderN.Expand.Core', 

112 'Band.Dispersion', 

113 'scf.restart', 

114 'MO.fileout', 

115 'Dos.fileout', 

116 'HS.fileout', 

117 'Voronoi.charge', 

118 'scf.NC.Zeeman.Spin', 

119 'scf.stress.tensor', 

120 'Energy.Decomposition' 

121] 

122list_int_keys: List[str] = [] 

123list_bool_keys: List[str] = [] 

124list_float_keys = [ 

125 'Dos.Erange', 

126] 

127matrix_keys = [ 

128 'Definition.of.Atomic.Species', 

129 'Atoms.SpeciesAndCoordinates', 

130 'Atoms.UnitVectors', 

131 'Hubbard.U.values', 

132 'Atoms.Cont.Orbitals', 

133 'MD.Fixed.XYZ', 

134 'MD.TempControl', 

135 'MD.Init.Velocity', 

136 'Band.KPath.UnitCell', 

137 'Band.kpath', 

138 'MO.kpoint', 

139 'Wannier.Initial.Projectors' 

140] 

141unit_dat_keywords = { 

142 'Hubbard.U.Values': 'eV', 

143 'scf.Constraint.NC.Spin.v': 'eV', 

144 'scf.ElectronicTemperature': 'K', 

145 'scf.energycutoff': 'Ry', 

146 'scf.criterion': 'Ha', 

147 'scf.Electric.Field': 'GV / m', 

148 'OneDFFT.EnergyCutoff': 'Ry', 

149 'orbitalOpt.criterion': '(Ha/Borg)**2', 

150 'MD.Opt.criterion': 'Ha/Bohr', 

151 'MD.TempControl': 'K', 

152 'NH.Mass.HeatBath': '_amu', 

153 'MD.Init.Velocity': 'm/s', 

154 'Dos.Erange': 'eV', 

155 'scf.NC.Mag.Field.Spin': 'Tesla', 

156 'scf.NC.Mag.Field.Orbital': 'Tesla' 

157} 

158 

159 

160omx_parameter_defaults: Dict[str, Any] = dict( 

161 scf_ngrid=None, 

162 scf_kgrid=None, 

163 dos_kgrid=None, 

164 scf_electric_field=None, 

165 level_of_stdout=None, 

166 level_of_fileout=None, 

167 species_number=None, 

168 atoms_number=None, 

169 scf_maxiter=None, # default 40 

170 scf_mixing_history=None, 

171 scf_mixing_startpulay=None, 

172 scf_mixing_everypulay=None, 

173 onedfft_numgridk=None, # 1Dfft 

174 onedfft_numgridr=None, # 1Dfft 

175 orbitalopt_scf_maxiter=None, 

176 orbitalopt_opt_maxiter=None, 

177 orbitalopt_opt_method=None, 

178 orbitalopt_historypulay=None, 

179 num_cntorb_atoms=None, 

180 ordern_krylovh_order=None, 

181 ordern_krylovs_order=None, 

182 md_maxiter=None, 

183 md_opt_diis_history=None, 

184 md_opt_startdiis=None, 

185 band_nkpath=None, 

186 num_homos=None, 

187 num_lumos=None, 

188 mo_nkpoint=None, 

189 md_current_iter=None, 

190 scf_constraint_nc_spin_v=None, 

191 scf_electronictemperature=None, 

192 scf_fixed_grid=None, 

193 scf_energycutoff=150, 

194 scf_init_mixing_weight=None, 

195 scf_min_mixing_weight=None, 

196 scf_max_mixing_weight=None, 

197 scf_kerker_factor=None, 

198 scf_criterion=None, # Ha unit defualt 1e-6 

199 scf_system_charge=None, 

200 onedfft_energycutoff=None, # 1Dfft 

201 orbitalopt_sd_step=None, 

202 orbitalopt_criterion=None, 

203 ordern_hoppingranges=None, 

204 md_timestep=None, 

205 md_opt_criterion=None, 

206 nh_mass_heatbath=None, 

207 scf_nc_mag_field_spin=None, 

208 scf_nc_mag_field_orbital=None, 

209 system_currentdirectory=None, 

210 system_name=None, 

211 data_path=None, 

212 atoms_speciesandcoordinates_unit='Ang', 

213 atoms_unitvectors_unit='Ang', 

214 scf_xctype='LDA', 

215 scf_spinpolarization=None, 

216 scf_hubbard_occupation=None, 

217 scf_eigenvaluesolver='Cluster', # Band | Cluster 

218 scf_mixing_type='Rmm-Diis', 

219 orbitalopt_method=None, 

220 orbitalopt_startpulay=None, 

221 md_type=None, 

222 wannier_initial_projectors_unit=None, 

223 scf_partialcorecorrection=None, 

224 scf_hubbard_u=None, 

225 scf_constraint_nc_spin=None, 

226 scf_proexpn_vna=None, 

227 scf_spinorbit_coupling=None, 

228 cntorb_fileout=None, 

229 ordern_exact_inverse_s=None, 

230 ordern_recalc_buffer=None, 

231 ordern_expand_core=None, 

232 band_dispersion=None, 

233 scf_restart=None, 

234 mo_fileout=None, 

235 dos_fileout=None, 

236 hs_fileout=None, 

237 voronoi_charge=None, 

238 scf_nc_zeeman_spin=None, 

239 scf_stress_tensor=None, 

240 energy_decomposition=None, 

241 dos_erange=None, 

242 definition_of_atomic_species=None, 

243 atoms_speciesandcoordinates=None, 

244 atoms_unitvectors=None, 

245 hubbard_u_values=None, 

246 atoms_cont_orbitals=None, 

247 md_fixed_xyz=None, 

248 md_tempcontrol=None, 

249 md_init_velocity=None, 

250 band_kpath_unitcell=None, 

251 band_kpath=None, 

252 mo_kpoint=None, 

253 wannier_initial_projectors=None, 

254 xc=None, # Default is set to 'LDA' as 'scf_xctype' keyword 

255 maxiter=None, 

256 energy_cutoff=None, # Please make sure written in eV unit not Ry 

257 kpts=None, # Default value is set to (4, 4, 4) in 'scf_kgrid' 

258 band_kpts=tuple(), # To separate monkhorst and band kpts 

259 eigensolver=None, 

260 spinpol=None, 

261 convergence=None, 

262 external=None, 

263 mixer=None, 

264 charge=None, 

265 smearing=None, 

266 restart=None, # Beginning of calculator parameters 

267 mpi=None, 

268 pbs=None, 

269 debug=False, 

270 nohup=True, 

271 dft_data_dict=None, # dft_data_year : Pseudo potential generated year 

272 dft_data_year=None) # writting in 'Definition.Of.Atomic.Species'. 13 or 19 

273 

274 

275class OpenMXParameters(Parameters): 

276 """ 

277 Parameters class for the OpenMX calculator. OpenMX parameters are defined 

278 here. If values seems unreasonable, for example, energy_cutoff=0.01, it 

279 gives warning. Changing standard parameters to openmx kewords is not a job 

280 for this class. We translate the variable right before we write. Hence, 

281 translation processes are written in `writers.py`. Here we only deals with 

282 default parameters and the reasonable boundary for that value. 

283 

284 (1, 1, 1) < scf_kgrid < (16, 16, 16) 

285 1 < scf_maxiter < 10000 

286 1e-10 < scf_criterion < 1e-1 

287 100 < scf_energycutoff < 600 

288 100 * Ha < convergence < 600 * Ha 

289 

290 """ 

291 

292 allowed_xc = [ 

293 'LDA', 

294 'GGA', 'PBE', 'GGA-PBE', 

295 'LSDA', 

296 'LSDA-PW', 

297 'LSDA-CA', 

298 'CA', 

299 'PW'] 

300 

301 def __init__(self, **kwargs): 

302 kw = omx_parameter_defaults.copy() 

303 kw.update(kwargs) 

304 Parameters.__init__(self, **kw) 

305 

306 if self.kpts == (1, 1, 1): 

307 print("When only the gamma point is considered, the eigenvalue \ 

308 solver is changed to 'Cluster' with the periodic boundary \ 

309 condition.") 

310 self.eigensolver = 'Cluster' 

311 self.mpi = None 

312 self.pbs = None 

313 

314 from copy import deepcopy 

315 dft_data_dict = deepcopy(default_dictionary) 

316 if self.dft_data_dict is not None: 

317 dft_data_dict.update(self.dft_data_dict) 

318 self.dft_data_dict = dft_data_dict 

319 

320 # keys = {k: v for k, v in kwargs.items() if not(v is None or v == [])}