From 5c1528588688d6759d2ae87e8c6ef371b487aa95 Mon Sep 17 00:00:00 2001 From: Anouar Benali Date: Thu, 28 Sep 2023 15:32:11 -0500 Subject: [PATCH 1/2] Finalize RMG -> QMCPACK SD runs with twist averaging --- nexus/lib/qmcpack.py | 4 +- nexus/lib/rmg.py | 59 ++- nexus/lib/rmg_input.py | 871 ++++++++++++++++++++++++++--------------- 3 files changed, 623 insertions(+), 311 deletions(-) diff --git a/nexus/lib/qmcpack.py b/nexus/lib/qmcpack.py index 1e8ca79b78..89e8806237 100644 --- a/nexus/lib/qmcpack.py +++ b/nexus/lib/qmcpack.py @@ -44,6 +44,7 @@ from developer import unavailable from nexus_base import nexus_core from copy import deepcopy +from rmg import Rmg try: import h5py except: @@ -174,7 +175,7 @@ def incorporate_result(self,result_name,result,sim): input = self.input system = self.system if result_name=='orbitals': - if isinstance(sim,Pw2qmcpack): + if isinstance(sim,(Pw2qmcpack,Rmg)): h5file = result.h5file @@ -273,7 +274,6 @@ def incorporate_result(self,result_name,result,sim): #end if #end if qs.wavefunction = newwfn - else: self.error('incorporating orbitals from '+sim.__class__.__name__+' has not been implemented') #end if diff --git a/nexus/lib/rmg.py b/nexus/lib/rmg.py index 1edd2479c8..50c91659d5 100644 --- a/nexus/lib/rmg.py +++ b/nexus/lib/rmg.py @@ -3,9 +3,12 @@ ################################################################## +import os from simulation import Simulation +from generic import obj from rmg_input import RmgInput,generate_rmg_input from rmg_analyzer import RmgAnalyzer +from execute import execute @@ -15,24 +18,72 @@ class Rmg(Simulation): generic_identifier = 'rmg' application = 'rmg-cpu' application_properties = set(['serial','mpi']) - application_results = set(['']) + application_results = set(['orbitals','wavefunctions']) + + + def __init__(self,**sim_args): + sync_from_scf = sim_args.pop('sync_from_scf',True) + Simulation.__init__(self,**sim_args) + self.sync_from_scf = False + #calc = self.input.ontrol.get('calculation_mode',None) + if self.input.calculation_mode=='NSCF': + self.sync_from_scf = sync_from_scf + #end if + #end def __init__ + + def check_result(self,result_name,sim): calculating_result = False + input =self.input + if result_name=='orbitals': + conv_requested = self.input.write_qmcpack_restart + calculating_result = conv_requested + if result_name=='wavefunctions' : + calculating_result = True return calculating_result #end def check_result def get_result(self,result_name,sim): - result = None - self.error('Ability to get result '+result_name+' has not been implemented.') + result = obj() + input = self.input + outdir = 'Waves' + result.locdir = self.locdir + result.outdir = os.path.join(self.locdir,outdir) + if result_name=='orbitals': + h5file = 'wave.out.h5' + result.h5file = os.path.join(self.locdir,outdir,h5file) + if result_name=='wavefunctions': + result.location = os.path.join(self.locdir,outdir,'wave.out') + #self.error('Ability to get result '+result_name+' has not been implemented.') return result #end def get_result def incorporate_result(self,result_name,result,sim): - self.error('ability to incorporate result '+result_name+' has not been implemented') + #self.error('ability to incorporate result '+result_name+' has not been implemented') + if result_name=='wavefunctions': + res_path = os.path.abspath(result.locdir) + loc_path = os.path.abspath(self.locdir) + if res_path==loc_path: + None # don't need to do anything if in same directory + elif self.sync_from_scf: # rsync output into nscf dir + outdir = os.path.join(self.locdir,'Waves') + #outdir = os.path.join(self.locdir,c.outdir) + command = 'rsync -av {0}/* {1}/'.format(result.outdir,outdir) + if not os.path.exists(outdir): + os.makedirs(outdir) + #end if + sync_record = os.path.join(outdir,'nexus_sync_record') + if not os.path.exists(sync_record): + execute(command) + f = open(sync_record,'w') + f.write('\n') + f.close() + #end if + #end if #end def incorporate_result diff --git a/nexus/lib/rmg_input.py b/nexus/lib/rmg_input.py index 9e9b788631..475506ef37 100644 --- a/nexus/lib/rmg_input.py +++ b/nexus/lib/rmg_input.py @@ -27,10 +27,40 @@ class RmgInputSettings(DevBase): # Key type : string -> formatted # Hubbard_U # Key type : string -> formatted +# kpoints +# Key type : string -> formatted raw_input_spec = ''' + Control options + Key name: AFM + Required: no + Key type: boolean + Expert: No + Experimental: No + Default: "false" + Description: If true, anti-feromagnetic will be forced by symmetry operation if + possible. + + Key name: STM_bias + Required: no + Key type: string + Expert: No + Experimental: No + Default: "-1.0 1.0" + Allowed: + Description: Bias (in unit of Volt) for STM calculation + + Key name: STM_height + Required: no + Key type: string + Expert: No + Experimental: No + Default: "2.0 4.0" + Allowed: + Description: Height range for STM calculation + Key name: a_length Required: no Key type: double @@ -41,6 +71,16 @@ class RmgInputSettings(DevBase): Default: 0.000000e+00 Description: First lattice constant. + Key name: afd_cfac + Required: no + Key type: double + Expert: No + Experimental: No + Min value: 0.000000e+00 + Max value: 10.000000 + Default: 0.000000e+00 + Description: Manual setting for the adaptive finite differencing parameter. + Key name: b_length Required: no Key type: double @@ -67,10 +107,10 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "Quench Electrons" - Allowed: "Exx Only" "NEB Relax" "Band Structure Only" "Psi Plot" "Plot" - "Constant Pressure And Energy" "TDDFT" "Dimer Relax" "Constant - Temperature And Energy" "Constant Volume And Energy" "Relax - Structure" "Quench Electrons" "NSCF" + Allowed: "NSCF" "Constant Temperature And Energy" "Constant Volume And + Energy" "Dimer Relax" "TDDFT" "Relax Structure" "Constant Pressure + And Energy" "Quench Electrons" "Plot" "Psi Plot" "Band Structure + Only" "STM" "NEB Relax" "Exx Only" Description: Type of calculation to perform. Key name: cell_relax @@ -117,6 +157,14 @@ class RmgInputSettings(DevBase): Description: Flag indicating whether or not parallel output wavefunction file uses compressed format. + Key name: compute_direct + Required: no + Key type: boolean + Expert: No + Experimental: No + Default: "false" + Description: If true then direct energy values are computed for QMCPACK. + Key name: description Required: no Key type: string @@ -147,6 +195,16 @@ class RmgInputSettings(DevBase): Description: Units to be used when writing energy values to the output file. Hartrees or Rydbergs are available. + Key name: epsg_guard + Required: no + Key type: double + Expert: No + Experimental: No + Min value: 0.000000e+00 + Max value: 1.000000e-05 + Default: 1.000000e-07 + Description: GGA guard value for low density regions. + Key name: exx_integrals_filepath Required: no Key type: string @@ -161,7 +219,7 @@ class RmgInputSettings(DevBase): Key type: string Expert: No Experimental: No - Default: "Distributed fft" + Default: "Local fft" Allowed: "Local fft" "Distributed fft" Description: FFT mode for exact exchange computations. @@ -174,6 +232,15 @@ class RmgInputSettings(DevBase): Allowed: "none" "gygi-baldereschi" Description: Exact exchange method for handling exx divergence at G=0. + Key name: gpu_managed_memory + Required: no + Key type: boolean + Expert: Yes + Experimental: No + Default: "false" + Description: Some AMD and Nvidia GPUs support managed gou memory which is + useful when GPU memory limits are exceeded. + Key name: input_tddft_file Required: no Key type: string @@ -232,7 +299,7 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "false" - Description: if set true, calculate noncollinear + Description: If set true, noncollinear calculation. Key name: nvme_orbitals Required: no @@ -334,6 +401,16 @@ class RmgInputSettings(DevBase): Allowed: Description: File/path for runtime disk storage of qfunctions. + Key name: qmc_nband + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 0 + Max value: 2147483647 + Default: 0 + Description: The number of band used in rmg-qmcpack interface. + Key name: read_serial_restart Required: no Key type: boolean @@ -354,13 +431,23 @@ class RmgInputSettings(DevBase): Description: The RMS value of the change in the total potential from step to step where we assume self consistency has been achieved. + Key name: semilocal_projectors + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 6 + Max value: 40 + Default: 10 + Description: Controls the number of semilocal projectors. + Key name: spinorbit Required: no Key type: boolean Expert: No Experimental: No Default: "false" - Description: if set true, calculate with spinorbit coupling + Description: If set true, spinorbit coupling calculation. Key name: start_mode Required: no @@ -368,8 +455,8 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "LCAO Start" - Allowed: "Modified LCAO Start" "Restart TDDFT" "Start TDDFT" "Gaussian - Start" "FIREBALL Start" "LCAO Start" "Restart From File" "Random + Allowed: "Modified LCAO Start" "Restart TDDFT" "Start TDDFT" "FIREBALL + Start" "Gaussian Start" "LCAO Start" "Restart From File" "Random Start" Description: Type of run. @@ -391,15 +478,16 @@ class RmgInputSettings(DevBase): Default: 0.500000 Description: The stress criteria - Key name: tddft_steps + Key name: system_charge Required: no - Key type: integer + Key type: double Expert: No Experimental: No - Min value: 0 - Max value: 2147483647 - Default: 2000 - Description: Maximum number of tddft steps to perform. + Min value: -unlimited + Max value: unlimited + Default: 0.000000e+00 + Description: Number of excess holes in the system (useful for doped systems). + Example, 2 means system is missing two electrons Key name: time_reversal Required: no @@ -415,9 +503,18 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "None" - Allowed: "DFT-D3" "DFT-D2" "Grimme-D2" "None" + Allowed: "DFT-D3" "Grimme-D2" "DFT-D2" "None" Description: Type of vdw correction + Key name: vdwdf_grid_type + Required: no + Key type: string + Expert: No + Experimental: No + Default: "Coarse" + Allowed: "Fine" "Coarse" + Description: Type of grid to use when computing vdw-df correlation. + Key name: vdwdf_kernel_filepath Required: no Key type: string @@ -427,6 +524,14 @@ class RmgInputSettings(DevBase): Allowed: Description: File/path for vdW_kernel_table data. + Key name: verbose + Required: no + Key type: boolean + Expert: No + Experimental: No + Default: "false" + Description: Flag for writing out extra information + Key name: wannier90 Required: no Key type: boolean @@ -452,30 +557,12 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Min value: 5 - Max value: 500 + Max value: 50 Default: 5 Description: How often to write checkpoint files during the initial quench in units of SCF steps. During structural relaxations of molecular dynamics checkpoints are written each ionic step. - Key name: write_eigvals_period - Required: no - Key type: integer - Expert: No - Experimental: No - Min value: 1 - Max value: 100 - Default: 5 - Description: How often to output eigenvalues in units of scf steps. - - Key name: write_pseudopotential_plots - Required: no - Key type: boolean - Expert: No - Experimental: No - Default: "false" - Description: Flag to indicate whether or not to write pseudopotential plots. - Key name: write_qmcpack_restart Required: no Key type: boolean @@ -521,10 +608,10 @@ class RmgInputSettings(DevBase): Key type: string Expert: No Experimental: No - Default: "Orthorhombic Primitive" - Allowed: "Tetragonal Primitive" "Cubic Body Centered" "Orthorhombic - Primitive" "Cubic Face Centered" "Hexagonal Primitive" "Cubic - Primitive" "None" + Default: "None" + Allowed: "Orthorhombic Primitive" "Monoclinic Primitive" "Tetragonal + Primitive" "Hexagonal Primitive" "Cubic Body Centered" "Triclinic + Primitive" "Cubic Face Centered" "Cubic Primitive" "None" Description: Bravais Lattice Type. Key name: cell_movable @@ -544,6 +631,15 @@ class RmgInputSettings(DevBase): Allowed: "Angstrom" "Bohr" Description: Units for the atomic coordinates. + Key name: frac_symmetry + Required: no + Key type: boolean + Expert: No + Experimental: No + Default: "true" + Description: For supercell calculation, one can disable the fractional + translation symmetry + Key name: grid_spacing Required: no Key type: double @@ -554,6 +650,18 @@ class RmgInputSettings(DevBase): Default: 0.350000 Description: Approximate grid spacing (bohr). + Key name: kpoint_distribution + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: -2147483647 + Max value: 2147483647 + Default: -1 + Description: This option affects kpoint parallelization. If there are M MPI + procs then N = M/kpoint_distribution procs are assigned to each + kpoint. M must be evenly divisible by kpoint_distribution. + Key name: kpoint_is_shift Required: no Key type: integer array @@ -576,7 +684,7 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "Bohr" - Allowed: "Angstrom" "Alat" "Bohr" + Allowed: "Alat" "Angstrom" "Bohr" Description: Units for the lattice vectors Key name: lattice_vector @@ -585,16 +693,18 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "Not done yet" - Description: Lattice vectors, a0, a1, a2 + Description: The simulation cell may be specified using either lattice vectors, + a0, a1, a2 or by lattice constants and a bravais lattice type. If + lattice vectors are used they should be entered as a 3x3 matrix. Key name: potential_grid_refinement Required: no Key type: integer Expert: No Experimental: No - Min value: 0 + Min value: 1 Max value: 4 - Default: 0 + Default: 2 Description: Ratio of the potential grid density to the wavefunction grid density. For example if the wavefunction grid is (72,72,72) and potential_grid_refinement = "2" then the potential grid would be @@ -610,6 +720,16 @@ class RmgInputSettings(DevBase): Default: "1 1 1 " Description: Three-D (x,y,z) layout of the MPI processes. + Key name: use_symmetry + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 0 + Max value: 2 + Default: 2 + Description: 0: never use symmetry, 1: always use symmetry, + Key name: wavefunction_grid Required: no Key type: integer array @@ -621,6 +741,16 @@ class RmgInputSettings(DevBase): Pseudopotential related options + Key name: all_electron_parm + Required: no + Key type: integer + Expert: Yes + Experimental: Yes + Min value: 1 + Max value: 12 + Default: 4 + Description: Gygi all electron parameter. + Key name: atomic_orbital_type Required: no Key type: string @@ -640,15 +770,6 @@ class RmgInputSettings(DevBase): Default: 0.800000 Description: - Key name: filter_dpot - Required: no - Key type: boolean - Expert: Yes - Experimental: No - Default: "false" - Description: Flag indicating whether or not to filter density dependent - potentials. - Key name: filter_factor Required: no Key type: double @@ -656,9 +777,19 @@ class RmgInputSettings(DevBase): Experimental: No Min value: 0.060000 Max value: 1.000000 - Default: 0.250000 + Default: 1.000000 Description: Filtering factor. + Key name: internal_pseudo_type + Required: no + Key type: string + Expert: No + Experimental: No + Default: "sg15" + Allowed: "all_electron" "nc_accuracy" "sg15" "ultrasoft" + Description: Internal pseudopotential type. Choices are sg15, ultrasoft, + nc_accuracy or all_electron + Key name: localize_localpp Required: no Key type: boolean @@ -747,6 +878,16 @@ class RmgInputSettings(DevBase): format uses the atomic symbol followed by the pseudopotential file name. pseudopotential = "Ni Ni.UPF O O.UPF" + Key name: use_bessel_projectors + Required: no + Key type: boolean + Expert: No + Experimental: Yes + Default: "false" + Description: When a semi-local pseudopotential is being used projectors will be + generated using Bloechl's procedure with Bessel functions as the + basis set if this is true. + Kohn Sham solver options Key name: davidson_max_steps @@ -783,6 +924,17 @@ class RmgInputSettings(DevBase): For very large problems the N^3 scaling makes even a factor of 2 prohibitively costly and the multigrid solver is a better choice. + Key name: davidson_premg + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 0 + Max value: 8 + Default: 4 + Description: If the davidson solver is selected this parameter controls the + number of multigrid steps to use before enabling davidson. + Key name: kohn_sham_coarse_time_step Required: no Key type: double @@ -800,13 +952,13 @@ class RmgInputSettings(DevBase): Expert: Yes Experimental: No Min value: 6 - Max value: 10 + Max value: 12 Default: 8 Description: RMG uses finite differencing to represent the kinetic energy operator and the accuracy of the representation is controllable by the kohn_sham_fd_order parameter. The default is 8 and is fine for - most purposes but higher accuracy is obtainable with 10th order at - the cost of some additional computational expense. + most purposes but higher accuracy is obtainable with 10th or 12th + order at the cost of some additional computational expense. Key name: kohn_sham_mg_levels Required: no @@ -905,14 +1057,13 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "AUTO_XC" - Allowed: "hartree-fock" "vdw-df-c09" "sla+pw+pbe+vdw1" "VDW-DF" "vdw-df" - "gaupbe" "B3LYP" "hse" "mgga tb09" "AUTO_XC" "m06l" "VDW-DF-CX" - "tpss" "ev93" "optbk88" "sogga" "wc" "HSE" "HCTH" "hcth" "Q2D" - "q2d" "PBESOL" "tb09" "b86bpbe" "PW86PBE" "PBE0" "MGGA TB09" - "pw86pbe" "REVPBE" "pbe" "revpbe" "GGA PBE" "BLYP" "pbe0" "pbesol" - "blyp" "PBE" "GGA XP CP" "pw91" "GGA XB CP" "TB09" "optb86b" - "olyp" "BP" "GGA BLYP" "bp" "b3lyp" "LDA" "vdw-df-cx" "PW91" "PZ" - "pz" + Allowed: "hartree-fock" "VDW-DF" "vdw-df" "gaupbe" "HSE" "PBE0" "mgga tb09" + "TB09" "VDW-DF-CX" "optbk88" "AUTO_XC" "BLYP" "hse" "tb09" "GGA + BLYP" "GGA XB CP" "ev93" "GGA XP CP" "Q2D" "pbe0" "PW91" "pbe" + "bp" "vdw-df-c09" "optb86b" "pbesol" "pw91" "b86bpbe" "BP" "blyp" + "PBE" "pz" "PZ" "LDA" "hcth" "revpbe" "m06l" "REVPBE" "vdw-df-cx" + "pw86pbe" "B3LYP" "PW86PBE" "PBESOL" "sla+pw+pbe+vdw1" "sogga" + "q2d" "MGGA TB09" "GGA PBE" "wc" "tpss" "HCTH" "b3lyp" "olyp" Description: Most pseudopotentials specify the exchange correlation type they were generated with and the default value of AUTO_XC means that the type specified in the pseudopotial is what RMG will use. That @@ -969,7 +1120,7 @@ class RmgInputSettings(DevBase): Min value: 0 Max value: 5 Default: 2 - Description: order of Methefessel Paxton occupation. + Description: Order of Methefessel Paxton occupation. Key name: dos_broading Required: no @@ -1017,8 +1168,8 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "Fermi Dirac" - Allowed: "Error Function" "Gaussian" "Fermi Dirac" "MethfesselPaxton" "Cold - Smearing" "Fixed" + Allowed: "Tetrahedron" "MethfesselPaxton" "Cold Smearing" "Error Function" + "Gaussian" "Fermi Dirac" "Fixed" Description: RMG supports several different ways of specifying orbital occupations. For a spin polarized system one may specify the occupations for up and down separately. In the case of a non-zero @@ -1057,6 +1208,15 @@ class RmgInputSettings(DevBase): states_count_and_occupation. Total number of states must match spin down occupation string. + Key name: tetra_method + Required: no + Key type: string + Expert: No + Experimental: No + Default: "Bloechl" + Allowed: "Optimized" "Linear" "Bloechl" + Description: tetrahedron method to use + Key name: unoccupied_states_per_kpoint Required: no Key type: integer @@ -1081,16 +1241,6 @@ class RmgInputSettings(DevBase): Description: Number of previous steps to use when Broyden mixing is used to update the charge density. - Key name: charge_broyden_scale - Required: no - Key type: double - Expert: No - Experimental: No - Min value: 0.000000e+00 - Max value: 1.000000 - Default: 0.500000 - Description: - Key name: charge_density_mixing Required: no Key type: double @@ -1119,7 +1269,7 @@ class RmgInputSettings(DevBase): Key type: boolean Expert: No Experimental: No - Default: "false" + Default: "true" Description: if set true, charge density mixing the residual in G space Key name: charge_pulay_order @@ -1141,16 +1291,76 @@ class RmgInputSettings(DevBase): Min value: 1 Max value: 2147483647 Default: 100 - Description: + Description: charge Pulay mixing reset steps. - Key name: charge_pulay_scale + Key name: drho_precond + Required: no + Key type: boolean + Expert: No + Experimental: No + Default: "true" + Description: if set true, charge density residual is preconded with + q^2/(q^2+q0^2) + + Key name: drho_precond_q0 + Required: no + Key type: double + Expert: No + Experimental: No + Min value: 0.000000e+00 + Max value: 10.000000 + Default: 0.250000 + Description: preconding the charge density residual by q^2/(q^2+q0^2) + + Key name: ldau_mixing Required: no Key type: double Expert: No Experimental: No Min value: 0.000000e+00 Max value: 1.000000 - Default: 0.500000 + Default: 1.000000 + Description: Proportion of the current ldau occupation to replace with the new + ones after each scf step when linear mixing is used. + + Key name: ldau_mixing_type + Required: no + Key type: string + Expert: No + Experimental: No + Default: "Linear" + Allowed: "Broyden" "Pulay" "Linear" + Description: RMG supports Pulay and Linear mixing for DFT+U occupation mixing + + Key name: ldau_pulay_order + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 1 + Max value: 10 + Default: 5 + Description: Number of previous steps to use when Pulay mixing is used to + update the ldau occupation . + + Key name: ldau_pulay_refresh + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 1 + Max value: 2147483647 + Default: 100 + Description: ldau pulay mixing reset steps + + Key name: ldau_pulay_scale + Required: no + Key type: double + Expert: No + Experimental: No + Min value: 0.000000e+00 + Max value: 1.000000 + Default: 1.000000 Description: Key name: potential_acceleration_constant_step @@ -1452,7 +1662,7 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Min value: 4 - Max value: 512 + Max value: 2048 Default: 32 Description: Block size to use with scalapack. Optimal value is dependent on matrix size and system hardware. @@ -1463,11 +1673,32 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "auto" - Allowed: "elpa" "cusolver" "auto" "scalapack" "magma" "lapack" + Allowed: "auto" "rocsolver" "elpa" "cusolver" "magma" "scalapack" "lapack" Description: Driver type used for subspace diagonalization of the eigenvectors. + Key name: subdiag_groups + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 1 + Max value: 16 + Default: 1 + Description: Number of scalapack or elpa groups. + Performance related options + Key name: fd_allocation_limit + Required: no + Key type: integer + Expert: Yes + Experimental: No + Min value: 1024 + Max value: 262144 + Default: 65536 + Description: Allocation sizes in finite difference routines less than this + value are stack rather than heap based. + Key name: mpi_queue_mode Required: no Key type: boolean @@ -1506,6 +1737,17 @@ class RmgInputSettings(DevBase): Description: If set RMG assumes that sufficient huge pages are available. Bad things may happen if this is not true. + Key name: rmg_threads_per_node + Required: no + Key type: integer + Expert: Yes + Experimental: No + Min value: 0 + Max value: 64 + Default: 0 + Description: Number of Multigrid/Davidson threads each MPI process will use. A + value of 0 means set automatically. + Key name: spin_manager_thread Required: no Key type: boolean @@ -1532,7 +1774,8 @@ class RmgInputSettings(DevBase): Min value: 1 Max value: 2147483647 Default: 64 - Description: state_block used in nlforce. + Description: State block size used in nlforce. Larger values require more + memory but can Key name: use_alt_zgemm Required: no @@ -1549,7 +1792,12 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "true" - Description: Use asynchronous allreduce if available. + Description: RMG uses MPI_Allreduce function calls in several places and for + large problems these can account for a significant fraction of the + total run time. In most cases using the asynchronous MPI versions + of the functions is faster but this is not true for all platforms + and in that casesetting this flag to false can improve + performance. Key name: use_hwloc Required: no @@ -1566,7 +1814,16 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "true" - Description: Use internal numa setup if available. + Description: Numa stands for Non Uniform Memory Access and means that the main + memory of a computer is organized into seperate distinct banks. + Each bank is then attached to a CPU core or group of cores and + while all cores can normally access all banks the access speed is + faster for directly attached banks. Ensuring that individual CPU + cores mostly access memory in banks they are directly attached to + can have a large impact on performance. Process mapping that does + this can normally be done when jobs are submitted and run via + arguments to mpirun/mpiexec but if this is not done RMG will + attempt to provide an optimal mapping if use_numa is set to true. LDAU options @@ -1578,7 +1835,7 @@ class RmgInputSettings(DevBase): Default: "" Allowed: Description: Hubbard U parameter for each atomic species using the format - Hubbard_U="Ni 6.5" + Hubbard_U="Ni 6.5 3d 0.0 0.0 0.0" Key name: ldaU_mode Required: no @@ -1599,6 +1856,53 @@ class RmgInputSettings(DevBase): Default: 9.000000 Description: Max radius of atomic orbitals to be used in LDA+U projectors. +TDDFT related options + + Key name: restart_tddft + Required: no + Key type: boolean + Expert: No + Experimental: No + Default: "false" + Description: restart TDDFT + + Key name: tddft_mode + Required: no + Key type: string + Expert: No + Experimental: No + Default: "electric field" + Allowed: "point charge" "electric field" + Description: TDDFT mode + + Key name: tddft_qgau + Required: no + Key type: double + Expert: No + Experimental: No + Min value: 0.000000e+00 + Max value: unlimited + Default: 1.000000 + Description: Gaussian parameter for point charge to Gaussian charge + + Key name: tddft_qpos + Required: no + Key type: double array + Expert: No + Experimental: No + Default: "Not done yet" + Description: cartesian coordinate of the point charge for tddft + + Key name: tddft_steps + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 0 + Max value: 2147483647 + Default: 2000 + Description: Maximum number of tddft steps to perform. + Poisson solver options Key name: hartree_max_sweeps @@ -1664,6 +1968,16 @@ class RmgInputSettings(DevBase): Description: Time step to use in the poisson multigrid solver on the finest level. + Key name: poisson_mg_levels + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: -1 + Max value: 6 + Default: -1 + Description: Number of multigrid levels to use in the hartree multigrid solver. + Key name: poisson_mucycles Required: no Key type: integer @@ -1675,38 +1989,111 @@ class RmgInputSettings(DevBase): Description: Number of mu (also known as W) cycles to use in the hartree multigrid solver. - Key name: poisson_post_smoothing + Key name: poisson_post_smoothing + Required: no + Key type: integer + Expert: Yes + Experimental: No + Min value: 1 + Max value: 6 + Default: 1 + Description: Number of global hartree grid post-smoothing steps to perform + after a multigrid iteration. + + Key name: poisson_pre_smoothing + Required: no + Key type: integer + Expert: Yes + Experimental: No + Min value: 1 + Max value: 6 + Default: 2 + Description: Number of global hartree grid pre-smoothing steps to perform + before a multigrid iteration. + + Key name: poisson_solver + Required: no + Key type: string + Expert: No + Experimental: No + Default: "pfft" + Allowed: "pfft" "multigrid" + Description: poisson solver. + + Key name: charge_analysis_period + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 0 + Max value: 500 + Default: 0 + Description: How often to perform and write out charge analysis. + + Key name: output_rho_xsf + Required: no + Key type: boolean + Expert: No + Experimental: No + Default: "false" + Description: Generate xsf format for electronic density. + + Key name: write_eigvals_period + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 1 + Max value: 100 + Default: 5 + Description: How often to output eigenvalues in units of scf steps. + + Key name: write_orbital_overlaps + Required: no + Key type: boolean + Expert: No + Experimental: No + Default: "false" + Description: If true the orbital overlap matrix from successive MD steps is + written. + + Key name: write_pdos Required: no - Key type: integer - Expert: Yes + Key type: boolean + Expert: No Experimental: No - Min value: 1 - Max value: 6 - Default: 1 - Description: Number of global hartree grid post-smoothing steps to perform - after a multigrid iteration. + Default: "false" + Description: Flag to write partial density of states. - Key name: poisson_pre_smoothing + Key name: write_pseudopotential_plots Required: no - Key type: integer - Expert: Yes + Key type: boolean + Expert: No Experimental: No - Min value: 1 - Max value: 6 - Default: 2 - Description: Number of global hartree grid pre-smoothing steps to perform - before a multigrid iteration. + Default: "false" + Description: Flag to indicate whether or not to write pseudopotential plots. - Key name: poisson_solver +Testing options + + Key name: test_bond_length Required: no - Key type: string + Key type: double Expert: No Experimental: No - Default: "pfft" - Allowed: "pfft" "multigrid" - Description: poisson solver. + Min value: 0.000000e+00 + Max value: 20.000000 + Default: nan + Description: Expected dimer bond length for testing. -Testing options + Key name: test_bond_length_tolerance + Required: no + Key type: double + Expert: No + Experimental: No + Min value: 1.000000e-04 + Max value: 0.100000 + Default: 1.000000e-03 + Description: Test bond length tolerance. Key name: test_energy Required: no @@ -1728,6 +2115,26 @@ class RmgInputSettings(DevBase): Default: 1.000000e-07 Description: Test final energy tolerance. + Key name: test_steps + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 0 + Max value: 1000 + Default: 0 + Description: Expected number of scf steps for testing. + + Key name: test_steps_tolerance + Required: no + Key type: integer + Expert: No + Experimental: No + Min value: 0 + Max value: 10 + Default: 1 + Description: Test scf steps tolerance. + Miscellaneous options Key name: E_POINTS @@ -1806,16 +2213,6 @@ class RmgInputSettings(DevBase): Description: Type of charge analysis to use. Only Voronoi deformation density is currently available. - Key name: charge_analysis_period - Required: no - Key type: integer - Expert: No - Experimental: No - Min value: 0 - Max value: 500 - Default: 0 - Description: How often to perform and write out charge analysis. - Key name: cube_pot Required: no Key type: boolean @@ -1829,7 +2226,7 @@ class RmgInputSettings(DevBase): Key type: boolean Expert: No Experimental: No - Default: "true" + Default: "false" Description: if set true, charge density is printed out in cube format Key name: cube_states_list @@ -1927,40 +2324,20 @@ class RmgInputSettings(DevBase): Expert: No Experimental: No Default: "false" - Description: if set true, calculate the exact exchange integrals + Description: If set true, calculate the exact exchange integrals. Key name: fast_density Required: no Key type: boolean - Expert: No + Expert: Yes Experimental: No - Default: "true" + Default: "false" Description: Use a faster but less accurate method to generate the charge density from the electronic wavefunctions. As the cutoff (grid-density) increases this method improves in accuracy. This option should be set to false if you receive warnings about negative charge densities after interpolation. - Key name: fd_allocation_limit - Required: no - Key type: integer - Expert: No - Experimental: No - Min value: 1024 - Max value: 262144 - Default: 65536 - Description: Allocation sizes in finite difference routines less than this - value are stack rather than heap based. - - Key name: frac_symmetry - Required: no - Key type: boolean - Expert: No - Experimental: No - Default: "true" - Description: For supercell calculation, one can disable the fractional - translation symmetry - Key name: freeze_occupied Required: no Key type: boolean @@ -2001,31 +2378,29 @@ class RmgInputSettings(DevBase): Description: Special purpose flag which will force use of an FFT for the kinetic energy operator. - Key name: kpoint_distribution - Required: no - Key type: integer - Expert: No - Experimental: No - Min value: -2147483647 - Max value: 2147483647 - Default: -1 - Description: - - Key name: laplacian_autocoeff - Required: no - Key type: boolean + Key name: kpoints + Required: yes + Key type: formatted Expert: No Experimental: No - Default: "false" - Description: if set to true, we use LaplacianCoeff.cpp to generate coeff + Default: "" + Allowed: + Description: Normally kpoints are specified using the kpoint_mesh and + kpoint_is_shift options but one can also enter a list of kpoints + and their weights with this option. If kpoint_mesh is not + specified or this is a bandstructure calculation this is required + otherwise it is optional. - Key name: laplacian_offdiag + Key name: kpoints_bandstructure Required: no - Key type: boolean + Key type: formatted Expert: No Experimental: No - Default: "false" - Description: if set to true, we use LaplacianCoeff.cpp to generate coeff + Default: "" + Allowed: + Description: List of kpoints to use in a bandstructure calculation. For more + detailed information look at the github wiki page on kpoint + calculations. Key name: lcao_use_empty_orbitals Required: no @@ -2056,32 +2431,6 @@ class RmgInputSettings(DevBase): Default: 0 Description: number of wannier functions to be used in wannier90 - Key name: output_rho_xsf - Required: no - Key type: boolean - Expert: No - Experimental: No - Default: "false" - Description: Generate xsf format for electronic density. - - Key name: poisson_mg_levels - Required: no - Key type: integer - Expert: No - Experimental: No - Min value: -1 - Max value: 6 - Default: -1 - Description: Number of multigrid levels to use in the hartree multigrid solver. - - Key name: restart_tddft - Required: no - Key type: boolean - Expert: No - Experimental: No - Default: "false" - Description: restart TDDFT - Key name: rmg2bgw Required: no Key type: boolean @@ -2090,17 +2439,6 @@ class RmgInputSettings(DevBase): Default: "false" Description: Write wavefunction in G-space to BerkeleyGW WFN file. - Key name: rmg_threads_per_node - Required: no - Key type: integer - Expert: No - Experimental: No - Min value: 0 - Max value: 64 - Default: 0 - Description: Number of Multigrid/Davidson threads each MPI process will use. A - value of 0 means set automatically. - Key name: scf_steps_offset Required: no Key type: integer @@ -2114,50 +2452,12 @@ class RmgInputSettings(DevBase): Key name: sqrt_interpolation Required: no Key type: boolean - Expert: No + Expert: Yes Experimental: No Default: "false" Description: Flag indicating whether or not to use square root technique for density interpolation. - Key name: system_charge - Required: no - Key type: double - Expert: No - Experimental: No - Min value: -unlimited - Max value: unlimited - Default: 0.000000e+00 - Description: Number of excess holes in the system (useful for doped systems). - Example, 2 means system is missing two electrons - - Key name: tddft_mode - Required: no - Key type: string - Expert: No - Experimental: No - Default: "electric field" - Allowed: "point charge" "electric field" - Description: TDDFT mode - - Key name: tddft_qgau - Required: no - Key type: double - Expert: No - Experimental: No - Min value: 0.000000e+00 - Max value: unlimited - Default: 1.000000 - Description: Gaussian parameter for point charge to Gaussian charge - - Key name: tddft_qpos - Required: no - Key type: double array - Expert: No - Experimental: No - Default: "Not done yet" - Description: cartesian coordinate of the point charge for tddft - Key name: total_scf_steps_offset Required: no Key type: integer @@ -2176,30 +2476,16 @@ class RmgInputSettings(DevBase): Default: "true" Description: if set to true, we use Cpdgemr2d to change matrix distribution - Key name: use_symmetry - Required: no - Key type: boolean - Expert: No - Experimental: No - Default: "true" - Description: For non-gamma point, always true, for gamma point, optional - - Key name: vdwdf_grid_type - Required: no - Key type: string - Expert: No - Experimental: No - Default: "Coarse" - Allowed: "Fine" "Coarse" - Description: Type of grid to use when computing vdw-df correlation. - - Key name: verbose + Key name: use_gpu_fd Required: no Key type: boolean Expert: No - Experimental: No + Experimental: Yes Default: "false" - Description: Flag for writing out extra information + Description: Use gpus for kohn-sham orbital finite differencing. Depending on + the balance of hardware characteristics this can provide a + significant speedup but individual testing is required. + Experimental. Key name: vxc_diag_nmax Required: no @@ -2242,56 +2528,20 @@ class RmgInputSettings(DevBase): Description: when wannier90 is used to build wannier functions, the energy window parameter - Key name: write_orbital_overlaps - Required: no - Key type: boolean - Expert: No - Experimental: No - Default: "false" - Description: If true the orbital overlap matrix from successive MD steps is - written. - - Key name: write_pdos - Required: no - Key type: boolean - Expert: No - Experimental: No - Default: "false" - Description: Flag to write partial density of states. - Key name: z_average_output_mode Required: no Key type: string Expert: No Experimental: No Default: "None" - Allowed: "potential and charge density" "wave functions" "None" + Allowed: "wave functions" "potential and charge density" "None" Description: z_average_output_mode. -''' +''' undocumented_options = ''' Undocumented options - Key name: use_bessel_projectors - Required: no - Key type: boolean - Expert: No - Experimental: No - Default: "false" - - Key name: kpoints - Required: no - Key type: formatted - Expert: No - Experimental: No - - Key name: kpoints_bandstructure - Required: no - Key type: formatted - Expert: No - Experimental: No - Key name: atoms Required: no Key type: formatted @@ -2333,9 +2583,7 @@ class RmgInputSettings(DevBase): Key type: double Expert: No Experimental: No - ''' - raw_input_spec += undocumented_options raw_input_spec += deprecated_options @@ -3138,7 +3386,6 @@ def __init__(self,filepath=None): #end if #end def __init__ - def assign(self,**values): unrecognized = [] for k,v in values.items(): @@ -3364,6 +3611,7 @@ def generate_any_rmg_input(**kwargs): virtual_frac = kw.delete_optional('virtual_frac' , None ) spin_polarized = kw.delete_optional('spin_polarized' , None ) default_units = kw.delete_optional('default_units' , 'bohr' ) + default_units = dict( a = 'angstrom', @@ -3387,7 +3635,8 @@ def generate_any_rmg_input(**kwargs): #end if ri.assign(**kw) - if ri.calculation_mode is 'NSCF' and 'input_wave_function_file' not in ri: + # Special case for nscf calculation to force the read from already computed charge density. + if ri.calculation_mode=='NSCF' and 'input_wave_function_file' not in ri: ri.input_wave_function_file='Waves/wave.out' # incorporate pseudopotentials details provided via "pseudos" @@ -3487,16 +3736,28 @@ def generate_any_rmg_input(**kwargs): #end if # set kpoints - if len(s.kpoints)>0 and 'kpoint_mesh' not in ri: + if ri.calculation_mode=='NSCF': kpu = s.kpoints_unit() ri.kpoints = obj( kpoints = kpu.copy(), weights = s.kweights.copy(), ) - if 'kpoint_is_shift' in ri: - del ri.kpoint_is_shift - #end if - #end if + # + ri.use_symmetry=0 + ri.kpoint_distribution=1 + else: + if len(s.kpoints)>0 and 'kpoint_mesh' not in ri: + kpu = s.kpoints_unit() + ri.kpoints = obj( + kpoints = kpu.copy(), + weights = s.kweights.copy(), + ) + if 'kpoint_is_shift' in ri: + del ri.kpoint_is_shift + #end if + #end if + + # set wavefunction grid if wf_grid_spacing is not None: From 2473e3e4901920b77edd0326a79b4065847686f9 Mon Sep 17 00:00:00 2001 From: Anouar Benali Date: Thu, 28 Sep 2023 15:54:40 -0500 Subject: [PATCH 2/2] Adding complete example for RMG with Nexus --- .../Diamond_full.py | 225 ++++++++++++++++++ 1 file changed, 225 insertions(+) create mode 100755 nexus/examples/rmg/02_diamond_scf_nscf_optJ123_dmc/Diamond_full.py diff --git a/nexus/examples/rmg/02_diamond_scf_nscf_optJ123_dmc/Diamond_full.py b/nexus/examples/rmg/02_diamond_scf_nscf_optJ123_dmc/Diamond_full.py new file mode 100755 index 0000000000..a3d29ff04a --- /dev/null +++ b/nexus/examples/rmg/02_diamond_scf_nscf_optJ123_dmc/Diamond_full.py @@ -0,0 +1,225 @@ +#! /usr/bin/env python3 + +import os +cores = os.cpu_count() // 2 + +# Paths to executables. *** EDIT ME *** +rmg_bin="rmg-cpu" +qmc_bin="qmcpack_complex" + +# Import Nexus stuff +from nexus import settings,job,run_project,obj +from nexus import generate_physical_system +from nexus import ppset +from nexus import generate_qmcpack +from nexus import generate_rmg + +# machine settings +settings( + pseudo_dir = '../../qmcpack/pseudopotentials', # Pseudopotential directory + generate_only = 0, # only write input files, T/F + results = '', # Don't store results separately + sleep = 5, # Workflow polling frequency (sec) + machine = 'ws'+str(cores), # Executing on simple workstation + account = 'PSFMat_2', + ) + +scf_job = job(cores=cores, app=rmg_bin) # How to run RMG +opt_job = job(cores=cores, app=qmc_bin) + + +ppset( + label = 'BFD', + qmcpack = ['C.BFD.xml'], + rmg = ['C.BFD.xml'], + + ) + +for struct in ['Diamond']: + primcell = generate_physical_system( + units = 'A', + structure = 'diamond', + cell = 'prim', + symm_kgrid=True, + C=4, + ) + #Number of Supercells + tiled = primcell.structure.tile_opt(2) + + + scf=generate_rmg( + path = 'RMG/scf', + system = primcell, + virtual_frac = 1.0, + wf_grid_spacing = 0.15, + # nexus inputs + identifier = 'scf', + job = job(cores=1,app='rmg-cpu'), + pseudos = 'BFD', + input_type = 'generic', + # control options + calculation_mode = 'Quench Electrons', + compressed_infile = False, + compressed_outfile = False, + description = 'diamond', + energy_convergence_criterion = 1.0e-09, + max_scf_steps = 100, + #start_mode = 'Restart From File', + write_data_period = 10, + # cell parameter options + atomic_coordinate_type = 'Cell Relative', + kpoint_is_shift = (0,0,0), + kpoint_mesh = (3,2,1), + potential_grid_refinement = 2, + # pseudopotential related options + localize_localpp = False, + localize_projectors = False, + # kohn sham solver options + kohn_sham_mucycles = 3, + kohn_sham_solver = 'davidson', + # orbital occupation options + occupations_type = 'Fixed', + # charge density mixing options + charge_density_mixing = 0.5, + charge_mixing_type = 'Broyden', + potential_acceleration_constant_step = 1.0, + # diagonalization options + subdiag_driver = 'lapack', + exchange_correlation_type = 'pbe', + # miscellaneous options + kpoint_distribution = 1, + #qmcpack output + write_qmcpack_restart = True, + ) + opt1=1 + #Creating a 3x3x3 twist grid with a 2 Supercell + for grid in range(3,4): + supercell = generate_physical_system( + structure = tiled.copy(), + kgrid = (grid,grid,grid), + kshift = (1,1,1), + symm_kgrid = True, + C = 4, + ) + + nscf = generate_rmg( + path = 'RMG/nscf-'+str(grid)+'x'+str(grid)+'x'+str(grid), + system = supercell, + virtual_frac = 1.0, + wf_grid_spacing = 0.15, + # nexus inputs + identifier = 'nscf', + job = job(cores=1,app='rmg-cpu'), + pseudos = 'BFD', + input_type = 'generic', + # control options + calculation_mode = 'NSCF', + compressed_infile = False, + compressed_outfile = False, + description = 'diamond', + # cell parameter options + atomic_coordinate_type = 'Cell Relative', + kohn_sham_mucycles = 3, + kohn_sham_solver = 'davidson', + # diagonalization options + subdiag_driver = 'lapack', + exchange_correlation_type = 'pbe', + # miscellaneous options + kpoint_distribution = 1, + kpoint_is_shift = (1,1,1), + #Kpoint_mesh needs to have a negative number!!!!! + kpoint_mesh = (-3,2,1), + #qmcpack output + write_qmcpack_restart = True, + dependencies = (scf,'wavefunctions'), + ) + + + if(opt1==1): + optJ12 = generate_qmcpack( + #block = True, + identifier = 'opt', + path = 'RMG/optJ12', # Run directory + job = opt_job, + input_type = 'basic', + system = supercell, # System to calculate + pseudos = 'BFD', + twistnum = 0, + meshfactor = 1.0, # you choose this and hybrid params + J1 = True, # Add a 1-body B-spline Jastrow + J2 = True, # Add a 2-body B-spline Jastrow + #J1_rcut = 6.842691799768850, + qmc = 'opt', # Do a wavefunction optimization + minmethod = 'oneshift', # Optimization algorithm (assumes energy minimization) + init_cycles = 2, # First 4 iterations allow large parameter changes + cycles = 5, # 8 subsequent iterations with smaller parameter changes + warmupsteps = 8, # First 8 steps are not recorded + blocks = 100, # Number of blocks to write in the .scalar.dat file + timestep = 0.1, # MC step size (nothing to do with time for VMC) + init_minwalkers = 0.01, # Smaller values -> bigger parameter change + minwalkers = 0.5, # + samples = 80000, # VMC samples per iteration + use_nonlocalpp_deriv = False, + dependencies = (nscf,'orbitals'), + ) + + + optJ123 = generate_qmcpack( + #block = True, + identifier = 'opt', + path = 'RMG/optJ123', # Run directory + job = opt_job, + input_type = 'basic', + system = supercell, # System to calculate + twistnum = 0, + J3 = True, # Add a 2-body B-spline Jastrow + J3_rcut = 3.00, # Cutoff for J3 + pseudos = 'BFD', + qmc = 'opt', # Do a wavefunction optimization + minmethod = 'oneshift', # Optimization algorithm (assumes energy minimization) + init_cycles = 2, # First 4 iterations allow large parameter changes + init_minwalkers = 0.01, # Smaller value -> bigger parameter change + cycles = 5, # Subsequent iterations with smaller parameter changes + minwalkers = 0.5, # Larger value -> smaller parameter change + warmupsteps = 4, # First steps are not recorded + blocks = 100, # Number of blocks to write in the .scalar.dat file + timestep = 0.1, # MC step size (nothing to do with time for VMC) + samples = 160000, # VMC samples per iteration + use_nonlocalpp_deriv = False, # Don't include nonlocal pseudo derivatives in optimization (this is nice to have for deep semicore states but expensive!) + dependencies = [(nscf,'orbitals'), + (optJ12, 'jastrow')], + ) + opt1=2 + + # run DMC with 1,2 and 3 Body Jastrow function + qmc = generate_qmcpack( + #block = True, + identifier = 'dmc', + path = 'RMG/dmc-'+str(grid)+'x'+str(grid)+'x'+str(grid), # Run directory + job = job(cores=cores), # Submit with the number of cores available + system = supercell, # System to calculate + pseudos = 'BFD', + jastrows = [], + qmc = 'dmc', # dmc run + vmc_samples = 16000, # Number of Samples (selected from a VMC step) + vmc_warmupsteps = 100, # Number of Equilibration steps + warmupsteps = 100, # Number of Equilibration steps + vmc_blocks = 20, # Number of VMC blocks (To generate the DMC samples) + vmc_steps = 20, # Number of VMC steps (To generate DMC samples) + vmc_timestep = 0.1, # VMC Timestep (To Generate DMC samples) + timestep = 0.01, # DMC timestep + steps = 40, # start with small number for large timesteps [autocorrelation] + blocks = 1000, # Number of DMC blocks + nonlocalmoves = 'v3', + dependencies = [(nscf,'orbitals'), + (optJ123, 'jastrow')], + ) + + +run_project() + + + + + +