Coverage for /builds/kinetik161/ase/ase/calculators/openmx/parameters.py: 84.38%

32 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-12-10 11:04 +0000

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 Any, Dict, List 

21 

22from ase.calculators.calculator import Parameters 

23from ase.calculators.openmx.default_settings import default_dictionary 

24 

25# Keys that have length 3 

26tuple_integer_keys = [ 

27 'scf.Ngrid', 

28 'scf.Kgrid', 

29 'Dos.Kgrid', 

30] 

31tuple_float_keys = [ 

32 'scf.Electric.Field', 

33 'scf.fixed.grid' 

34] 

35tuple_bool_keys: List[str] = [ 

36 

37] 

38integer_keys = [ 

39 'level.of.stdout', 

40 'level.of.fileout', 

41 'Species.Number', 

42 'Atoms.Number', 

43 'scf.maxIter', 

44 'scf.Mixing.History', 

45 'scf.Mixing.StartPulay', 

46 'scf.Mixing.EveryPulay', 

47 '1DFFT.NumGridK', 

48 '1DFFT.NumGridR', 

49 'orbitalOpt.scf.maxIter', 

50 'orbitalOpt.Opt.maxIter', 

51 'orbitalOpt.Opt.Method', 

52 'orbitalOpt.HistoryPulay', 

53 'Num.CntOrb.Atoms', 

54 'orderN.KrylovH.order', 

55 'orderN.KrylovS.order', 

56 'MD.maxIter', 

57 'MD.Opt.DIIS.History', 

58 'MD.Opt.StartDIIS', 

59 'Band.Nkpath', 

60 'num.HOMOs', 

61 'num.LUMOs', 

62 'MO.Nkpoint', 

63 'MD.Current.Iter' 

64] 

65float_keys = [ 

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

67 'scf.ElectronicTemperature', 

68 'scf.energycutoff', 

69 'scf.Init.Mixing.Weight', 

70 'scf.Min.Mixing.Weight', 

71 'scf.Max.Mixing.Weight', 

72 'scf.Kerker.factor', 

73 'scf.criterion', 

74 'scf.system.charge', 

75 '1DFFT.EnergyCutoff', 

76 'orbitalOpt.SD.step', 

77 'orbitalOpt.criterion', 

78 'orderN.HoppingRanges', 

79 'MD.TimeStep', 

80 'MD.Opt.criterion', 

81 'NH.Mass.HeatBath', 

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

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

84] 

85string_keys = [ 

86 'System.CurrentDirectory', 

87 'System.Name', 

88 'DATA.PATH', 

89 'Atoms.SpeciesAndCoordinates.Unit', 

90 'Atoms.UnitVectors.Unit', 

91 'scf.XcType', 

92 'scf.SpinPolarization', 

93 'scf.Hubbard.Occupation', 

94 'scf.EigenvalueSolver', 

95 'scf.Mixing.Type', 

96 'orbitalOpt.Method', 

97 'orbitalOpt.StartPulay', 

98 'MD.Type', 

99 'Wannier.Initial.Projectors.Unit' 

100] 

101bool_keys = [ 

102 'scf.partialCoreCorrection', 

103 'scf.Hubbard.U', 

104 'scf.Constraint.NC.Spin', 

105 'scf.ProExpn.VNA', 

106 'scf.SpinOrbit.Coupling', 

107 'CntOrb.fileout', 

108 'orderN.Exact.Inverse.S', 

109 'orderN.Recalc.Buffer', 

110 'orderN.Expand.Core', 

111 'Band.Dispersion', 

112 'scf.restart', 

113 'MO.fileout', 

114 'Dos.fileout', 

115 'HS.fileout', 

116 'Voronoi.charge', 

117 'scf.NC.Zeeman.Spin', 

118 'scf.stress.tensor', 

119 'Energy.Decomposition' 

120] 

121list_int_keys: List[str] = [] 

122list_bool_keys: List[str] = [] 

123list_float_keys = [ 

124 'Dos.Erange', 

125] 

126matrix_keys = [ 

127 'Definition.of.Atomic.Species', 

128 'Atoms.SpeciesAndCoordinates', 

129 'Atoms.UnitVectors', 

130 'Hubbard.U.values', 

131 'Atoms.Cont.Orbitals', 

132 'MD.Fixed.XYZ', 

133 'MD.TempControl', 

134 'MD.Init.Velocity', 

135 'Band.KPath.UnitCell', 

136 'Band.kpath', 

137 'MO.kpoint', 

138 'Wannier.Initial.Projectors' 

139] 

140unit_dat_keywords = { 

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

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

143 'scf.ElectronicTemperature': 'K', 

144 'scf.energycutoff': 'Ry', 

145 'scf.criterion': 'Ha', 

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

147 'OneDFFT.EnergyCutoff': 'Ry', 

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

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

150 'MD.TempControl': 'K', 

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

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

153 'Dos.Erange': 'eV', 

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

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

156} 

157 

158 

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

160 scf_ngrid=None, 

161 scf_kgrid=None, 

162 dos_kgrid=None, 

163 scf_electric_field=None, 

164 level_of_stdout=None, 

165 level_of_fileout=None, 

166 species_number=None, 

167 atoms_number=None, 

168 scf_maxiter=None, # default 40 

169 scf_mixing_history=None, 

170 scf_mixing_startpulay=None, 

171 scf_mixing_everypulay=None, 

172 onedfft_numgridk=None, # 1Dfft 

173 onedfft_numgridr=None, # 1Dfft 

174 orbitalopt_scf_maxiter=None, 

175 orbitalopt_opt_maxiter=None, 

176 orbitalopt_opt_method=None, 

177 orbitalopt_historypulay=None, 

178 num_cntorb_atoms=None, 

179 ordern_krylovh_order=None, 

180 ordern_krylovs_order=None, 

181 md_maxiter=None, 

182 md_opt_diis_history=None, 

183 md_opt_startdiis=None, 

184 band_nkpath=None, 

185 num_homos=None, 

186 num_lumos=None, 

187 mo_nkpoint=None, 

188 md_current_iter=None, 

189 scf_constraint_nc_spin_v=None, 

190 scf_electronictemperature=None, 

191 scf_fixed_grid=None, 

192 scf_energycutoff=150, 

193 scf_init_mixing_weight=None, 

194 scf_min_mixing_weight=None, 

195 scf_max_mixing_weight=None, 

196 scf_kerker_factor=None, 

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

198 scf_system_charge=None, 

199 onedfft_energycutoff=None, # 1Dfft 

200 orbitalopt_sd_step=None, 

201 orbitalopt_criterion=None, 

202 ordern_hoppingranges=None, 

203 md_timestep=None, 

204 md_opt_criterion=None, 

205 nh_mass_heatbath=None, 

206 scf_nc_mag_field_spin=None, 

207 scf_nc_mag_field_orbital=None, 

208 system_currentdirectory=None, 

209 system_name=None, 

210 data_path=None, 

211 atoms_speciesandcoordinates_unit='Ang', 

212 atoms_unitvectors_unit='Ang', 

213 scf_xctype='LDA', 

214 scf_spinpolarization=None, 

215 scf_hubbard_occupation=None, 

216 scf_eigenvaluesolver='Cluster', # Band | Cluster 

217 scf_mixing_type='Rmm-Diis', 

218 orbitalopt_method=None, 

219 orbitalopt_startpulay=None, 

220 md_type=None, 

221 wannier_initial_projectors_unit=None, 

222 scf_partialcorecorrection=None, 

223 scf_hubbard_u=None, 

224 scf_constraint_nc_spin=None, 

225 scf_proexpn_vna=None, 

226 scf_spinorbit_coupling=None, 

227 cntorb_fileout=None, 

228 ordern_exact_inverse_s=None, 

229 ordern_recalc_buffer=None, 

230 ordern_expand_core=None, 

231 band_dispersion=None, 

232 scf_restart=None, 

233 mo_fileout=None, 

234 dos_fileout=None, 

235 hs_fileout=None, 

236 voronoi_charge=None, 

237 scf_nc_zeeman_spin=None, 

238 scf_stress_tensor=None, 

239 energy_decomposition=None, 

240 dos_erange=None, 

241 definition_of_atomic_species=None, 

242 atoms_speciesandcoordinates=None, 

243 atoms_unitvectors=None, 

244 hubbard_u_values=None, 

245 atoms_cont_orbitals=None, 

246 md_fixed_xyz=None, 

247 md_tempcontrol=None, 

248 md_init_velocity=None, 

249 band_kpath_unitcell=None, 

250 band_kpath=None, 

251 mo_kpoint=None, 

252 wannier_initial_projectors=None, 

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

254 maxiter=None, 

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

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

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

258 eigensolver=None, 

259 spinpol=None, 

260 convergence=None, 

261 external=None, 

262 mixer=None, 

263 charge=None, 

264 smearing=None, 

265 restart=None, # Beginning of calculator parameters 

266 mpi=None, 

267 pbs=None, 

268 debug=False, 

269 nohup=True, 

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

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

272 

273 

274class OpenMXParameters(Parameters): 

275 """ 

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

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

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

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

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

281 default parameters and the reasonable boundary for that value. 

282 

283 (1, 1, 1) < scf_kgrid < (16, 16, 16) 

284 1 < scf_maxiter < 10000 

285 1e-10 < scf_criterion < 1e-1 

286 100 < scf_energycutoff < 600 

287 100 * Ha < convergence < 600 * Ha 

288 

289 """ 

290 

291 allowed_xc = [ 

292 'LDA', 

293 'GGA', 'PBE', 'GGA-PBE', 

294 'LSDA', 

295 'LSDA-PW', 

296 'LSDA-CA', 

297 'CA', 

298 'PW'] 

299 

300 def __init__(self, **kwargs): 

301 kw = omx_parameter_defaults.copy() 

302 kw.update(kwargs) 

303 Parameters.__init__(self, **kw) 

304 

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

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

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

308 condition.") 

309 self.eigensolver = 'Cluster' 

310 self.mpi = None 

311 self.pbs = None 

312 

313 from copy import deepcopy 

314 dft_data_dict = deepcopy(default_dictionary) 

315 if self.dft_data_dict is not None: 

316 dft_data_dict.update(self.dft_data_dict) 

317 self.dft_data_dict = dft_data_dict 

318 

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