Coverage for /builds/ase/ase/ase/calculators/openmx/parameters.py: 84.38%
32 statements
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
« prev ^ index » next coverage.py v7.5.3, created at 2025-08-02 00:12 +0000
1# fmt: off
3"""
4The ASE Calculator for OpenMX <http://www.openmx-square.org>: Python interface
5to the software package for nano-scale material simulations based on density
6functional theories.
7 Copyright (C) 2018 Jae Hwan Shim and JaeJun Yu
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 2.1 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with ASE. If not, see <http://www.gnu.org/licenses/>.
21"""
22from typing import Any, Dict, List
24from ase.calculators.calculator import Parameters
25from ase.calculators.openmx.default_settings import default_dictionary
27# Keys that have length 3
28tuple_integer_keys = [
29 'scf.Ngrid',
30 'scf.Kgrid',
31 'Dos.Kgrid',
32]
33tuple_float_keys = [
34 'scf.Electric.Field',
35 'scf.fixed.grid'
36]
37tuple_bool_keys: List[str] = [
39]
40integer_keys = [
41 'level.of.stdout',
42 'level.of.fileout',
43 'Species.Number',
44 'Atoms.Number',
45 'scf.maxIter',
46 'scf.Mixing.History',
47 'scf.Mixing.StartPulay',
48 'scf.Mixing.EveryPulay',
49 '1DFFT.NumGridK',
50 '1DFFT.NumGridR',
51 'orbitalOpt.scf.maxIter',
52 'orbitalOpt.Opt.maxIter',
53 'orbitalOpt.Opt.Method',
54 'orbitalOpt.HistoryPulay',
55 'Num.CntOrb.Atoms',
56 'orderN.KrylovH.order',
57 'orderN.KrylovS.order',
58 'MD.maxIter',
59 'MD.Opt.DIIS.History',
60 'MD.Opt.StartDIIS',
61 'Band.Nkpath',
62 'num.HOMOs',
63 'num.LUMOs',
64 'MO.Nkpoint',
65 'MD.Current.Iter'
66]
67float_keys = [
68 'scf.Constraint.NC.Spin.v',
69 'scf.ElectronicTemperature',
70 'scf.energycutoff',
71 'scf.Init.Mixing.Weight',
72 'scf.Min.Mixing.Weight',
73 'scf.Max.Mixing.Weight',
74 'scf.Kerker.factor',
75 'scf.criterion',
76 'scf.system.charge',
77 '1DFFT.EnergyCutoff',
78 'orbitalOpt.SD.step',
79 'orbitalOpt.criterion',
80 'orderN.HoppingRanges',
81 'MD.TimeStep',
82 'MD.Opt.criterion',
83 'NH.Mass.HeatBath',
84 'scf.NC.Mag.Field.Spin',
85 'scf.NC.Mag.Field.Orbital',
86]
87string_keys = [
88 'System.CurrentDirectory',
89 'System.Name',
90 'DATA.PATH',
91 'Atoms.SpeciesAndCoordinates.Unit',
92 'Atoms.UnitVectors.Unit',
93 'scf.XcType',
94 'scf.SpinPolarization',
95 'scf.Hubbard.Occupation',
96 'scf.EigenvalueSolver',
97 'scf.Mixing.Type',
98 'orbitalOpt.Method',
99 'orbitalOpt.StartPulay',
100 'MD.Type',
101 'Wannier.Initial.Projectors.Unit'
102]
103bool_keys = [
104 'scf.partialCoreCorrection',
105 'scf.Hubbard.U',
106 'scf.Constraint.NC.Spin',
107 'scf.ProExpn.VNA',
108 'scf.SpinOrbit.Coupling',
109 'CntOrb.fileout',
110 'orderN.Exact.Inverse.S',
111 'orderN.Recalc.Buffer',
112 'orderN.Expand.Core',
113 'Band.Dispersion',
114 'scf.restart',
115 'MO.fileout',
116 'Dos.fileout',
117 'HS.fileout',
118 'Voronoi.charge',
119 'scf.NC.Zeeman.Spin',
120 'scf.stress.tensor',
121 'Energy.Decomposition'
122]
123list_int_keys: List[str] = []
124list_bool_keys: List[str] = []
125list_float_keys = [
126 'Dos.Erange',
127]
128matrix_keys = [
129 'Definition.of.Atomic.Species',
130 'Atoms.SpeciesAndCoordinates',
131 'Atoms.UnitVectors',
132 'Hubbard.U.values',
133 'Atoms.Cont.Orbitals',
134 'MD.Fixed.XYZ',
135 'MD.TempControl',
136 'MD.Init.Velocity',
137 'Band.KPath.UnitCell',
138 'Band.kpath',
139 'MO.kpoint',
140 'Wannier.Initial.Projectors'
141]
142unit_dat_keywords = {
143 'Hubbard.U.Values': 'eV',
144 'scf.Constraint.NC.Spin.v': 'eV',
145 'scf.ElectronicTemperature': 'K',
146 'scf.energycutoff': 'Ry',
147 'scf.criterion': 'Ha',
148 'scf.Electric.Field': 'GV / m',
149 'OneDFFT.EnergyCutoff': 'Ry',
150 'orbitalOpt.criterion': '(Ha/Borg)**2',
151 'MD.Opt.criterion': 'Ha/Bohr',
152 'MD.TempControl': 'K',
153 'NH.Mass.HeatBath': '_amu',
154 'MD.Init.Velocity': 'm/s',
155 'Dos.Erange': 'eV',
156 'scf.NC.Mag.Field.Spin': 'Tesla',
157 'scf.NC.Mag.Field.Orbital': 'Tesla'
158}
161omx_parameter_defaults: Dict[str, Any] = dict(
162 scf_ngrid=None,
163 scf_kgrid=None,
164 dos_kgrid=None,
165 scf_electric_field=None,
166 level_of_stdout=None,
167 level_of_fileout=None,
168 species_number=None,
169 atoms_number=None,
170 scf_maxiter=None, # default 40
171 scf_mixing_history=None,
172 scf_mixing_startpulay=None,
173 scf_mixing_everypulay=None,
174 onedfft_numgridk=None, # 1Dfft
175 onedfft_numgridr=None, # 1Dfft
176 orbitalopt_scf_maxiter=None,
177 orbitalopt_opt_maxiter=None,
178 orbitalopt_opt_method=None,
179 orbitalopt_historypulay=None,
180 num_cntorb_atoms=None,
181 ordern_krylovh_order=None,
182 ordern_krylovs_order=None,
183 md_maxiter=None,
184 md_opt_diis_history=None,
185 md_opt_startdiis=None,
186 band_nkpath=None,
187 num_homos=None,
188 num_lumos=None,
189 mo_nkpoint=None,
190 md_current_iter=None,
191 scf_constraint_nc_spin_v=None,
192 scf_electronictemperature=None,
193 scf_fixed_grid=None,
194 scf_energycutoff=150,
195 scf_init_mixing_weight=None,
196 scf_min_mixing_weight=None,
197 scf_max_mixing_weight=None,
198 scf_kerker_factor=None,
199 scf_criterion=None, # Ha unit defualt 1e-6
200 scf_system_charge=None,
201 onedfft_energycutoff=None, # 1Dfft
202 orbitalopt_sd_step=None,
203 orbitalopt_criterion=None,
204 ordern_hoppingranges=None,
205 md_timestep=None,
206 md_opt_criterion=None,
207 nh_mass_heatbath=None,
208 scf_nc_mag_field_spin=None,
209 scf_nc_mag_field_orbital=None,
210 system_currentdirectory=None,
211 system_name=None,
212 data_path=None,
213 atoms_speciesandcoordinates_unit='Ang',
214 atoms_unitvectors_unit='Ang',
215 scf_xctype='LDA',
216 scf_spinpolarization=None,
217 scf_hubbard_occupation=None,
218 scf_eigenvaluesolver='Cluster', # Band | Cluster
219 scf_mixing_type='Rmm-Diis',
220 orbitalopt_method=None,
221 orbitalopt_startpulay=None,
222 md_type=None,
223 wannier_initial_projectors_unit=None,
224 scf_partialcorecorrection=None,
225 scf_hubbard_u=None,
226 scf_constraint_nc_spin=None,
227 scf_proexpn_vna=None,
228 scf_spinorbit_coupling=None,
229 cntorb_fileout=None,
230 ordern_exact_inverse_s=None,
231 ordern_recalc_buffer=None,
232 ordern_expand_core=None,
233 band_dispersion=None,
234 scf_restart=None,
235 mo_fileout=None,
236 dos_fileout=None,
237 hs_fileout=None,
238 voronoi_charge=None,
239 scf_nc_zeeman_spin=None,
240 scf_stress_tensor=None,
241 energy_decomposition=None,
242 dos_erange=None,
243 definition_of_atomic_species=None,
244 atoms_speciesandcoordinates=None,
245 atoms_unitvectors=None,
246 hubbard_u_values=None,
247 atoms_cont_orbitals=None,
248 md_fixed_xyz=None,
249 md_tempcontrol=None,
250 md_init_velocity=None,
251 band_kpath_unitcell=None,
252 band_kpath=None,
253 mo_kpoint=None,
254 wannier_initial_projectors=None,
255 xc=None, # Default is set to 'LDA' as 'scf_xctype' keyword
256 maxiter=None,
257 energy_cutoff=None, # Please make sure written in eV unit not Ry
258 kpts=None, # Default value is set to (4, 4, 4) in 'scf_kgrid'
259 band_kpts=(), # To separate monkhorst and band kpts
260 eigensolver=None,
261 spinpol=None,
262 convergence=None,
263 external=None,
264 mixer=None,
265 charge=None,
266 smearing=None,
267 restart=None, # Beginning of calculator parameters
268 mpi=None,
269 pbs=None,
270 debug=False,
271 nohup=True,
272 dft_data_dict=None, # dft_data_year : Pseudo potential generated year
273 dft_data_year=None) # writting in 'Definition.Of.Atomic.Species'. 13 or 19
276class OpenMXParameters(Parameters):
277 """
278 Parameters class for the OpenMX calculator. OpenMX parameters are defined
279 here. If values seems unreasonable, for example, energy_cutoff=0.01, it
280 gives warning. Changing standard parameters to openmx kewords is not a job
281 for this class. We translate the variable right before we write. Hence,
282 translation processes are written in `writers.py`. Here we only deals with
283 default parameters and the reasonable boundary for that value.
285 (1, 1, 1) < scf_kgrid < (16, 16, 16)
286 1 < scf_maxiter < 10000
287 1e-10 < scf_criterion < 1e-1
288 100 < scf_energycutoff < 600
289 100 * Ha < convergence < 600 * Ha
291 """
293 allowed_xc = [
294 'LDA',
295 'GGA', 'PBE', 'GGA-PBE',
296 'LSDA',
297 'LSDA-PW',
298 'LSDA-CA',
299 'CA',
300 'PW']
302 def __init__(self, **kwargs):
303 kw = omx_parameter_defaults.copy()
304 kw.update(kwargs)
305 Parameters.__init__(self, **kw)
307 if self.kpts == (1, 1, 1):
308 print("When only the gamma point is considered, the eigenvalue \
309 solver is changed to 'Cluster' with the periodic boundary \
310 condition.")
311 self.eigensolver = 'Cluster'
312 self.mpi = None
313 self.pbs = None
315 from copy import deepcopy
316 dft_data_dict = deepcopy(default_dictionary)
317 if self.dft_data_dict is not None:
318 dft_data_dict.update(self.dft_data_dict)
319 self.dft_data_dict = dft_data_dict
321 # keys = {k: v for k, v in kwargs.items() if not(v is None or v == [])}