sparc.calculator module

class sparc.calculator.SPARC(restart=None, directory='.', *, label=None, atoms=None, command=None, psp_dir=None, log='sparc.log', sparc_json_file=None, sparc_doc_path=None, check_version=False, keep_old_files=True, use_socket=False, socket_params={}, **kwargs)[source]

Bases: FileIOCalculator, IOContext

Calculator interface to the SPARC codes via the FileIOCalculator

ase_objtype = 'sparc_calculator'
atoms_dict()
calculate(atoms=None, properties=['energy'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]

Perform a calculation step

check_input_atoms(atoms)[source]

Check if input atoms are valid for SPARC inputs. :raises ValueError: if the atoms structure is not suitable for SPARC input file

check_state(atoms, tol=1e-08)[source]

Updated check_state method. By default self.atoms (cached from output files) contains the initial_magmoms, so we add a zero magmoms to the atoms for comparison if it does not exist.

reading a result from the .out file has only precision up to 10 digits

close(keep_out_socket=False)[source]

Close the socket communication, the SPARC process etc

concatinate_output()
default_params = {'h': 0.25, 'kpts': (1, 1, 1), 'xc': 'pbe'}
detect_socket_compatibility()[source]

Test if the sparc binary supports socket mode

detect_sparc_version()[source]

Run a short sparc test to determine which sparc is used

dict_atoms()
property directory
ensure_socket()[source]
estimate_memory(atoms=None, units='GB', **kwargs)[source]

a function to estimate the amount of memory required to run the selected calculation. This function takes in **kwargs, but if none are passed in, it will fall back on the parameters input when the class was instantiated

execute()[source]

Make a normal SPARC calculation without socket. Note we probably need to use a better handling of background process!

generate_command(**kwargs)
get_fermi_level()[source]
get_geometric_steps(**kwargs)
get_nstates()[source]
get_pseudopotential_directory(**kwargs)
get_runtime()[source]
get_scf_steps(include_uncompleted_last_step=False)[source]
get_stress(atoms=None)[source]

Warn user the dimensionality change when using stress

implemented_properties: List[str] = ['energy', 'forces', 'fermi', 'stress']

Properties calculator can handle (energy, forces, …)

property in_socket_filename
interpret_downsampling_input(**kwargs)
interpret_grid_input(**kwargs)
interpret_kpoint_input(**kwargs)
interpret_kpoint_shift(**kwargs)
property label

Rewrite the label from Calculator class, since we don’t want to contain pathsep

property log
name = 'sparc'
parse_MD()
parse_input_args()
parse_output()
parse_relax()
property pid

The pid for the stored process

print_sysinfo(command=None)[source]

Record current runtime information

property raw_results
read_line()
read_results()[source]

Parse from the SparcBundle

recover_index_order_from_ion_file()
property resort

Like Vasp calculator SPARC –> resort –> ASE atoms

run_client(atoms=None, use_stress=False)[source]

Main method to start the client code

set(**kwargs)[source]

Overwrite the initial parameters

setup_parallel_env(**kwargs)
property socket_mode

The mode of the socket calculator:

disabled: pure SPARC file IO interface local: Serves as a local SPARC calculator with socket support client: Relay SPARC calculation server: Remote server

property sort

Like Vasp calculator ASE atoms –> sort –> SPARC

special_inputs = ['xc', 'h', 'kpts', 'convergence', 'gpts', 'nbands']
property use_socket
write_input(atoms, properties=[], system_changes=[])[source]

Create input files via SparcBundle Will use the self.keep_sold_files options to keep old output files like .out_01, .out_02 etc