Main class¶
Below is a description of the code found in the main part of the package, system.py.
Created on Wed Dec 3 14:25:06 2014
@author: Matti Ropo @author: Henrik Levämäki
-
class
system.System(folder=None, EMTOdir=None, xc=None)[source]¶ Bases:
objectThe main class which provides the basis for the pyEMTO scripts.
Somewhere in the beginning of a pyEMTO script a new instance of the system class should be created. All subsequent communication with the newly created system should be through the class methods, which are described below.
Parameters: - folder (str) – Main folder where the input and output files will be stored. Use of absolute paths is recommended (Default value = current working directory)
- EMTOdir (str) – Path to the folder of the EMTO installation. This entry can and should be modified by the user inside the System.__init__ function (Default value = /home/user/EMTO5.8)
- xc (str) – Choice for the xc-functional can be set here. (Default value = PBE)
Returns: None
Return type: None
-
bulk(jobname=None, lat=None, atoms=None, concs=None, splts=None, sws=None, latname=None, latpath=None, emtopath=None, ibz=None, bmod=None, xc=None, ca=None, **kwargs)[source]¶ Initializes the basic parameters for bulk systems.
Basic information concerning the system, such as the types of atoms and the crystal structure should be given to this function and it should be called right after the class instance has been created.
Parameters: - jobname – Name of the system (Default value = None)
- lat – The type of lattice structure (Default value = None)
- atoms – List of atoms in the system (Default value = None)
- concs – List of concentrations of the elements in the ‘atoms’ list. This information is only used in CPA calculations (Default value = None)
- splts – List of initial magnetic moments of the elements in the ‘atoms’ list (Default value = None)
- sws (float) – The Wigner-Seitz radius of the system (Default value = None)
- latname – The ‘jobname’ of the BMDL, KSTR and SHAPE output files. These structure output files have to be located in the ‘latpath’ directory and they have to be named jobname.extention (Default value = None)
- latpath – The absolute path to the folder where the ‘bmdl’, ‘kstr’ and ‘shape’ folders are located, which in turn contain the output files of the structure calculation (Default value = None)
- emtopath – The absolute path to the folder where the EMTO installation is located (Default value = None)
- ibz – The code number indicating the Bravais lattice that the crystal structure of the system has. For a list of possible values, please consult the EMTO manual (Default value = None)
- bmod – The bulk modulus can be inputed here and if it is given, it will be used by the elastic modulus routines (Default value = None)
- xc – The choice of the xc-functional. If None, PBE will be used as default (Default value = None)
- ca – The c/a ratio of hcp structures can be inputed here and if it is given, it will be used by the elastic modulus routines (Default value = None)
- **kwargs –
Arbitrary other KGRN and KFCD input parameters can be given here as keyword arguments. They will be passed down to the self.emto.set_values() function
Returns: None
Return type: None
-
bulk_new(jobname=None, lat=None, atoms=None, concs=None, splts=None, sws=None, latname=None, latpath=None, emtopath=None, ibz=None, bmod=None, xc=None, ca=None, iqs=None, its=None, itas=None, **kwargs)[source]¶ Initializes the basic parameters for bulk systems.
!!!A NEW VERSION OF THE OLD “bulk” ROUTINE!!!Basic information concerning the system, such as the types of atoms and the crystal structure should be given to this function and it should be called right after the class instance has been created.
Parameters: - jobname – Name of the system (Default value = None)
- lat – The type of lattice structure (Default value = None)
- atoms – List of atoms in the system (Default value = None)
- concs – List of concentrations of the elements in the ‘atoms’ list. This information is only used in CPA calculations (Default value = None)
- splts – List of initial magnetic moments of the elements in the ‘atoms’ list (Default value = None)
- sws (float) – The Wigner-Seitz radius of the system (Default value = None)
- latname – The ‘jobname’ of the BMDL, KSTR and SHAPE output files. These structure output files have to be located in the ‘latpath’ directory and they have to be named jobname.extention (Default value = None)
- latpath – The absolute path to the folder where the ‘bmdl’, ‘kstr’ and ‘shape’ folders are located, which in turn contain the output files of the structure calculation (Default value = None)
- emtopath – The absolute path to the folder where the EMTO installation is located (Default value = None)
- ibz – The code number indicating the Bravais lattice that the crystal structure of the system has. For a list of possible values, please consult the EMTO manual (Default value = None)
- bmod – The bulk modulus can be inputed here and if it is given, it will be used by the elastic modulus routines (Default value = None)
- xc – The choice of the xc-functional. If None, PBE will be used as default (Default value = None)
- ca – The c/a ratio of hcp structures can be inputed here and if it is given, it will be used by the elastic modulus routines (Default value = None)
- **kwargs –
Arbitrary other KGRN and KFCD input parameters can be given here as keyword arguments. They will be passed down to the self.emto.set_values() function
Returns: None
Return type: None
-
check_conv(jobname, folder='./')[source]¶ Checks the convergence of given KGRN and KFCD calculations by reading their output files.
Parameters: - jobname (str) – Name of the output files
- folder (str) – Name of the folder where the output files are located (Default value = “./”)
Returns: Convergence of KGRN (True/False), convergence of KFCD (True/False)
Return type: boolean, boolean
-
check_str(jobname, folder='./')[source]¶ Checks if a KSTR calculation file exists and has converged.
Only KSTR file is checked because BMDL and SHAPE are fast to rerun in any case.
Parameters: - jobname (str) – Filename of the structure output file
- folder (str) – Folder where the output file is located (Default value = “./”)
Returns: True if KSTR has finished and False if not
Return type: boolean
-
create_jobname(jobname=None)[source]¶ Creates jobnames based on system information.
Creates a jobname based on the optional input prefix jobname. The format of the full jobname in this case will be: jobname_3.000000, where 3.000000 is the sws.
If jobname prefix is not given, full jobname is generated automatically based on system data self.sws, self.atoms and self.concs. The format of the jobname is: au0.50pd0.50_3.000000, where 0.50 are the atomic concentrations and 3.000000 is the sws.
Parameters: jobname (str) – Optional prefix for the full jobname (Default value = None) Returns: Newly created full jobname Return type: str
-
elastic_constants_analyze(sws=None, bmod=None, ca=None, R=None, cs=None, relax=True, debug=False)[source]¶ Analyzes the output files generated using the elastic_constants_batch_generate function.
The results are printed on screen.
Parameters: - sws (float) – WS-radius (Default value = None)
- bmod (float) – Bulk modulus (Default value = None)
- ca (float) – hpc c/a ratio (Default value = None)
- R (float) – Dimensionless quantity of hcp systems (Default value = None)
- cs (float) – Second order c/a-derivative of the energy (Default value = None)
Returns: None
Return type: None
-
elastic_constants_batch_calculate(sws=None, bmod=None, ca=None, R=None, cs=None)[source]¶ Calculates the elastic constants of a system using the parallelism of the batch system.
This is a combination of the batch_generate and batch_analyze functions.
Parameters: - sws (float) – WS-radius (Default value = None)
- bmod (float) – Bulk modulus (Default value = None)
- ca (float) – hpc c/a ratio (Default value = None)
- R (float) – The dimensionless quantity of hcp systems (Default value = None)
- cs (float) – Second order c/a-derivative of the energy (Default value = None)
Returns: None
Return type: None
-
elastic_constants_batch_generate(sws=None, ca=None, relax=True)[source]¶ Generates all the necessary input files based on the class data.
Parameters: - sws (float) – WS-radius (Default value = None)
- ca (float) – hpc c/a ratio (Default value = None)
Returns: List of jobnames
Return type: list(str)
-
elastic_constants_serial_calculate(sws=None, bmod=None, ca=None, R=None, cs=None)[source]¶ Calculates elastic constants on one CPU without using the batch system.
At the end the results are printed on screen.
Parameters: - sws (float) – WS-radius (Default value = None)
- bmod (float) – Bulk modulus (Default value = None)
- ca (float) – hpc c/a ratio (Default value = None)
Returns: None
Return type: None
-
find_lc(delta=0.01, prn=True, xc='PBE')[source]¶ Computes initial estimates for the ground state quantities for cubic systems.
Parameters: - delta (float) – Step size for the volume vs. energy array (Default value = 0.01)
- prn (boolean) – True if results should be printed, False if not (Default value = True)
- xc (str) – Choice of the xc-functional (Default value = ‘PBE’)
Returns: WS-radius, bulk modulus, c/a and energy
Return type: float, float, float, float
-
find_lc_hcp(delta=0.01, prn=True, xc='PBE')[source]¶ Computes initial estimates for the ground state quantities for hcp systems.
Parameters: - delta (float) – Step size for the volume vs. energy array (Default value = 0.01)
- prn (boolean) – True if results should be printed, False if not (Default value = True)
- xc (str) – Choice of the xc-functional (Default value = ‘PBE’)
Returns: WS-radius, bulk modulus, c/a and energy
Return type: float, float, float, float
-
get_energy(jobname=None, func='PBE', folder=None)[source]¶ Extracts total energy from the KFCD output file.
Different total energies given by different xc-functionals can be selected using the func input parameter. Default value is ‘PBE’.
Parameters: - jobname (str) – Name of the KFCD output file
- func (str) – Name of the xc-functional (Default value = “PBE”)
- folder (str) – Name of the folder where the output file is located (Default value = “./”)
Returns: Total energy if it is found, otherwise return None
Return type: float or None
-
get_fdos(jobname=None, folder=None)[source]¶ Extract density of state (DOS) at fermi level from KGRN output
Parameters: - jobname (str) – Name of the KGRN output file
- folder (str) – Name of the folder where the output file is located (Default value = “./”)
Returns: DOS at fermi level
Return type: float
-
get_jobs_status(jobids=None, toplevel=True)[source]¶ Returns status of the jobs indicated (jobsdict or list of job ids) or all jobs if no jobids supplied. Set toplevel=False for job step data.
Parameters: - jobids (dict or list) – List of job IDs (Default value = None)
- toplevel (boolean) – (Default value = True)
Returns: Job statuses
Return type: list(str)
-
get_moments(jobname=None, func='PBE', folder=None)[source]¶ Extracts magnetic moments from the KFCD output file.
Parameters: - jobname (str) – Name of the KFCD output file
- func (str) – Name of the xc-functional (Default value = “PBE”)
- folder (str) – Name of the folder where the output file is located (Default value = “./”)
Returns: Total energy if it is found, otherwise return None
Return type: float or None
-
get_status_counts(jobids=None)[source]¶ Returns the counts of all jobs by status category.
Parameters: jobids – (Default value = None) Returns: Return type:
-
lattice_constants_analyze(sws=None, ca=None, prn=True, debug=False, method='morse', return_error=False)[source]¶ Analyzes the output files generated using the lattice_constants_batch_generate function.
The results are printed on screen.
Parameters: - sws (list(float)) – List of WS-radii (Default value = None)
- ca (list(float)) – List hpc c/a ratios (Default value = None)
- prn (boolean) – True if results should be printed on screen, False if not (Default value = True)
Returns: Equilibrium WS-radius, c/a (only hcp), bulk modulus, energy, R (only hcp) and cs (only hcp)
Return type: float, float (only hcp), float, float, float (only hcp), float (only hcp)
-
lattice_constants_batch_calculate(sws=None, ca=None)[source]¶ Calculates the ground state WS-radius using the parallelism of the batch system by submitting one job for each entry in the sws list.
This is a combination of the batch_generate and batch_analyze functions. At the end results are printed on screen.
Parameters: - sws (list(float)) – List of WS-radii (Default value = None)
- ca (float) – hpc c/a ratio (Default value = None)
Returns: WS-radius, c/a (only hcp), bulk modulus, energy, R (only hcp), cs (only hcp)
Return type: float, float (only hcp), float, float, float (only hcp), float (only hcp)
-
lattice_constants_batch_generate(sws=None, ca=None, auto_ca=False)[source]¶ Generates input files and writes them to disk.
Based on the input sws and ca lists jobnames are created and then corresponding input files are generated and written on disk. List of jobnames are returned.
Parameters: - sws (list(float)) – List of WS-radii (Default value = None)
- ca (list(float)) – List of hcp c/a ratios (Default value = None)
Returns: List of jobnames
Return type: list(str)
-
lattice_constants_serial_calculate(sws=None, stype='simple', rerun=False, skip=False, delta=0.01, refine=True)[source]¶ Calculates the equilibrium lattice constants on one CPU WITHOUT the batch system.
Also the eq. bulk modulus, c/a ratio and energy are returned.
Parameters: - sws (float) – Initial guess for the eq. WS-radius (Default value = None)
- stype (str) – Type of the energy minimisation algorithm (Default value = “simple”)
- rerun (boolean) – True if (Default value = False)
- skip (boolean) – True if (Default value = False)
- delta (float) – Step size (Default value = 0.01)
- refine (boolean) – True if an optimized WS-radius vs. energy curve should be computed, False if not (Default value = True)
Returns: WS-radius, c/a, bulk modulus, energy
Return type: float, float, float, float
-
predict_next_sws(swses, en, maxdelta=0.05)[source]¶ Predict next WS-radius based on a simple gradient descent algorithm.
Parameters: - swses (list(float)) – List of current WS-radii
- en (list(float)) – List of current energies
- maxdelta (float) – Maximum step size (Default value = 0.05)
Returns: Next WS-radii and True if energy minimum has been found, False if not yet found
Return type: float, boolean
-
print_sws_ens(string, swses, energies)[source]¶ Prints the WS-radii and calculated energies of cubic systems
Parameters: - string (str) – Header for the printout
- swses (list(float)) – List of WS-radii
- energies (list(float)) – List of energies
Returns: None
Return type: None
-
print_sws_ens_hcp(string, swses, energies, cas)[source]¶ Prints the WS-radii, ca/a ratios and calculated energies of hcp systems
Parameters: - string (str) – Header for the printout
- swses (list(float)) – List of WS-radii
- energies (list(float)) – List of energies
- cas (list(float)) – List of c/a ratios
Returns: None
Return type: None
-
refine_lc(sws, delta=0.01, prn=True, xc='PBE')[source]¶ Calculates a more accurate equilibrium volume for cubic systems.
Parameters: - sws (float) – WS-radius
- delta (float) – Step size for the volume vs. energy array (Default value = 0.01)
- prn (boolean) – True if results should be printed, False if not (Default value = True)
- xc (str) – Choice of the xc-functional (Default value = ‘PBE’)
Returns: Ws-radius, bulk modulus, c/a and energy
Return type: float, float, float, float
-
refine_lc_hcp(sws, ca0, delta=0.01, prn=True, xc='PBE')[source]¶ Calculates a more accurate equilibrium volume for hcp systems.
Parameters: - sws (float) – WS-radius
- ca0 (float) – Previously computed eq. c/a ratio
- delta (float) – Step size for the volume vs. energy array (Default value = 0.01)
- prn (boolean) – True if results should be printed, False if not (Default value = True)
- xc (str) – Choice of the xc-functional (Default value = ‘PBE’)
Returns: Ws-radius, bulk modulus, c/a and energy
Return type: float, float, float, float
-
runemto(jobname, folder='./', EMTODIR=None, onlyKFCD=False)[source]¶ Run KGRN and KFCD WITHOUT using the batch system and check convergence.
Parameters: - jobname (str) – Name of the input files
- folder (str) – Name of the folder where the input files are located (Default value = “./”)
- EMTODIR (str) – Path to the EMTO installation folder (Default value = None)
- onlyKFCD (boolean) – True if only KFCD needs to calculated, False if also KGRN (Default value = False)
Returns: True if the calculations converged, False if not
Return type: boolean
-
runlattice(jobname=None, folder='./', EMTODIR=None)[source]¶ Run BMDL, KSTR and SHAPE calculation WITHOUT using the batch system.
Parameters: - jobname (str) – Name of the input files (Default value = None)
- folder (str) – Name of the folder where the input files are located (Default value = “./”)
- EMTODIR (str) – Path to the EMTO installation folder (Default value = None)
Returns: None
Return type: None
-
submit_jobs(jobnames, folder=None)[source]¶ Takes a list of jobnames and submits the corresponding batch scripts to the batch system.
Parameters: - jobnames (list(float)) – List of jobnames
- folder (str) – Folder where the batch scripts are located (Default value = None)
Returns: List of job ID numbers
Return type: list(str)
-
wait_for_jobs(jobsdict, restart_partition='general', sleeptime=60, restart_z=None, restart_stragglers_after=0.75, kill_if_all_ssusp=False)[source]¶ Loops checking status until no jobs are waiting or running / all are finished.
wait/run states:
Key Meaning Description CF CONFIGURING Job has been allocated resources, but are waiting for them to become ready for use (e.g. booting). CG COMPLETING Job is in the process of completing. Some processes on some nodes may still be active. PD PENDING Job is awaiting resource allocation. R RUNNING Job currently has an allocation. RS RESIZING Job is about to change size. S SUSPENDED Job has an allocation, but execution has been suspended. done states:
Key Meaning Description CA CANCELLED Job was explicitly cancelled by the user or system administrator. The job may or may not have been initiated. CD COMPLETED Job has terminated all processes on all nodes. F FAILED Job terminated with non-zero exit code or other failure condition. NF NODE_FAIL Job terminated due to failure of one or more allocated nodes. PR PREEMPTED Job terminated due to preemption. TO TIMEOUT Job terminated upon reaching its time limit. Parameters: - jobsdict –
- restart_partition – (Default value = ‘general’)
- sleeptime – (Default value = 60)
- restart_z – (Default value = None)
- restart_stragglers_after – (Default value = 0.75)
- kill_if_all_ssusp – (Default value = False)
Returns: None
Return type: None
-
which_error(jobname, folder='./')[source]¶ Tries to determine the reason why a given KGRN calculation did not converge.
The reason for the crash will be printed on screen.
Parameters: - jobname (str) – Name of the KGRN output file
- folder (str) – Name of the folder where the output file is located (Default value = “./”)
Returns: None
Return type: None