Skip to content

recipe

thmd.recipe

Modules:

git

gpaw

Modules:

cli_gpaw_check_PWcutoff

Some notes - calc.new() will create a new calculator that inherits all parameters from the current calculator, except for txt and timer

RFE

Attributes:

output_dir = Path('output') module-attribute
parallel_args = {'sl_auto': True, 'use_elpa': True} module-attribute
parser = argparse.ArgumentParser(description='Check convergence of PW energy cutoff') module-attribute
args = parser.parse_args() module-attribute
extxyz_file = args.poscar module-attribute
ecut = args.ecutoff module-attribute
atoms = read(extxyz_file, format='extxyz_file', index='-1') module-attribute
calc = GPAW(mode=PW(550), xc='PBE', occupations=FermiDirac(0.01), kpts={'density': 15, 'gamma': False}, parallel=parallel_args) module-attribute
new_calc = calc.new(mode=PW(ecut), txt=f'{output_dir}/calc_ecut_{ecut}.txt') module-attribute
pe = atoms.get_potential_energy() / len(atoms) module-attribute
out_file = f'{output_dir}/check_ecut_{ecut}.txt' module-attribute

cli_gpaw_check_kpoints

Some notes

RFE

Attributes:

output_dir = Path('output') module-attribute
parallel_args = {'sl_auto': True, 'use_elpa': True} module-attribute
parser = argparse.ArgumentParser(description='Check convergence of PW energy cutoff') module-attribute
args = parser.parse_args() module-attribute
extxyz_file = args.poscar module-attribute
pbc = [int(item) for item in args.pbc.split(' ')] module-attribute
atoms = read(extxyz_file, format='extxyz_file', index='-1') module-attribute
calc = GPAW(mode=PW(550), xc='PBE', occupations=FermiDirac(0.01), kpts={'size': (nkx, nky, nkz), 'gamma': True}, txt=f'{output_dir}/calc_kpoints_{nkx}x{nky}x{nkz}.txt', parallel=parallel_args) module-attribute
pe = atoms.get_potential_energy() / len(atoms) module-attribute
out_file = f'{output_dir}/check_kpoints_{nkx}x{nky}x{nkz}.txt' module-attribute

cli_gpaw_check_kpoints_density

Some notes

RFE

Attributes:

output_dir = Path('output') module-attribute
parallel_args = {'sl_auto': True, 'use_elpa': True} module-attribute
parser = argparse.ArgumentParser(description='Check convergence of PW energy cutoff') module-attribute
args = parser.parse_args() module-attribute
extxyz_file = args.poscar module-attribute
kdensity = args.kdensity module-attribute
pbc = [int(item) for item in args.pbc.split(' ')] module-attribute
atoms = read(extxyz_file, format='extxyz_file', index='-1') module-attribute
calc = GPAW(mode=PW(550), xc='PBE', occupations=FermiDirac(0.01), kpts={'density': kdensity, 'gamma': True}, txt=f'{output_dir}/calc_kdensity_{kdensity}.txt', parallel=parallel_args) module-attribute
pe = atoms.get_potential_energy() / len(atoms) module-attribute
out_file = f'{output_dir}/check_kdensity_{kdensity}.txt' module-attribute

cli_gpaw_optimize

Some notes - Must set txt='calc.txt' in GPAW calculator for backward files. - param_yaml must contain - a dict gpaw with GPAW parameters. - a dict optimize with ASE optimization parameters.

Attributes:

parser = argparse.ArgumentParser(description='Optimize structure using GPAW') module-attribute
args = parser.parse_args() module-attribute
configfile = args.param module-attribute
pdict = load_setting_file(configfile) module-attribute
extxyz_file = pdict['input_extxyz_path'] module-attribute
atoms = read(extxyz_file, format='extxyz', index='-1') module-attribute
gpaw_arg = pdict.get('gpaw_arg', {}) module-attribute
params = {'mode': {'name': 'pw', 'ecut': 500}, 'xc': 'PBE', 'convergence': {'energy': 1e-06, 'density': 0.0001, 'eigenstates': 1e-08}, 'occupations': {'name': 'fermi-dirac', 'width': 0.01}, 'txt': 'calc_optimize.txt'} module-attribute
calc = GPAW(**params) module-attribute
opt_args = pdict.get('optimize', {}) module-attribute
relax_dim = opt_args.get('relax_dim', None) module-attribute
pbc = atoms.get_pbc() module-attribute
fmax = opt_args.get('fmax', 0.05) module-attribute
nsteps = opt_args.get('nsteps', 10000) module-attribute
atoms_filter = FrechetCellFilter(atoms, mask=relax_dim) module-attribute
opt = BFGS(atoms_filter) module-attribute
pot_energy = atoms.get_potential_energy() module-attribute
forces = atoms.get_forces() module-attribute
stress = atoms.get_stress(voigt=True) module-attribute
atoms_fake = atoms.copy() module-attribute
output_file = extxyz_file.replace('.extxyz', '_labeled.extxyz') module-attribute

cli_gpaw_singlepoint

Some notes - Must set txt='calc.txt' in GPAW calculator for backward files. - param_yaml must contain - a dict gpaw with GPAW parameters.

Attributes:

parser = argparse.ArgumentParser(description='Optimize structure using GPAW') module-attribute
args = parser.parse_args() module-attribute
configfile = args.param module-attribute
pdict = load_setting_file(configfile) module-attribute
extxyz_file = pdict['input_extxyz_path'] module-attribute
atoms = read(extxyz_file, format='extxyz', index='-1') module-attribute
gpaw_arg = pdict.get('gpaw_arg', {}) module-attribute
params = {'mode': {'name': 'pw', 'ecut': 500}, 'xc': 'PBE', 'convergence': {'energy': 1e-06, 'density': 0.0001, 'eigenstates': 1e-08}, 'occupations': {'name': 'fermi-dirac', 'width': 0.01}, 'txt': 'calc_singlepoint.txt'} module-attribute
calc = GPAW(**params) module-attribute
pot_energy = atoms.get_potential_energy() module-attribute
forces = atoms.get_forces() module-attribute
stress = atoms.get_stress(voigt=True) module-attribute
atoms_fake = atoms.copy() module-attribute
output_file = extxyz_file.replace('.extxyz', '_labeled.extxyz') module-attribute

lammps

mace

Some notes

RFE

Functions:

  • cli_mace_optimize

    Return filepath of the script for running optimization using SevenNet.

cli_mace_optimize(copy_to: str = None) -> str

Return filepath of the script for running optimization using SevenNet.

mlff

ovito

Functions:

scale_RGB(RGB=(255, 255, 255))

Function to convert RGB color code from scale 0-255 to scale 0-1.

Parameters:

  • RGB (tuple, default: (255, 255, 255) ) –

    RGB code in scale 0-255

Returns:

  • rgb ( tuple ) –

    RGB code in scale 0-1

Examples:

rgb = scale_RGB((255,255,255)))
Quote
  1. rgb-values-to-0-to-1-scale

mod_set_prop_atom_name(frame, data)

Modifier to set atom names

Examples:

from thmd.visual.ovito_modifier import mod_set_prop_atom_name
from ovito.io import import_file

pipeline = import_file("test.cfg")
pipeline.add_to_scene()
## add mod
dict_name = {'type_id':[1, 2], 'atom_name':['C', 'H']}
pipeline.modifiers.append(mod_set_prop_atom_name)
Note
  • So far, can not a custom argument to modifier, see here. So we need to define a global variable before using this function
    dict_name = {'type_id':(1, 2), 'atom_name':('C', 'H')}
    
  • Do not use 'return` in modifier
  • the underscore notation mean modifiable version of the quantity in ovito
Quote
  1. Pass custom args to modifier
  2. ovito.data.Property - type.id, type.name, type.color, type.radius

mod_set_prop_atom_color_PMMAori(frame, data)

Modifier to assign atom colors based on atom_names.

Examples:

from thmd.visual.ovito_modifier import mod_set_prop_atom_color_PMMAori
from ovito.io import import_file

pipeline = import_file("test.cfg")
pipeline.add_to_scene()
## add mod
pipeline.modifiers.append(mod_set_prop_atom_color_PMMAori)

delete_pipelines(viewports: list[object] = [], pipelines: list[object] = [], scene: object = None)

delete all existed viewports, pipelines, and scene

Parameters:

  • viewports (obj, default: [] ) –

    list of ovito viewport objects

  • pipelines (obj, default: [] ) –

    list of ovito pipeline objects

  • scene (obj, default: None ) –

    ovito scene object

plumed

Functions:

script_FCCUBIC(a_fcc, zDirect, label='mcv', alpha=27, partialCompute=False, atoms='@mdatoms', atomsA=None, atomsB=None, options='')

PLUMED script to compute FCCUBIC

Parameters:

  • a_fcc (float) –

    Lattice constant of FCC crystal

  • zDirect (str) –

    specify the z-direction of crystal

  • label (str, default: 'mcv' ) –

    label of PLUMED command

  • alpha (int, default: 27 ) –

    ALPHA parameter to compute FCCUBIC colvar.

  • atoms (str, default: '@mdatoms' ) –

    specify atom-ids in computed group.

  • partialCompute (bool, default: False ) –

    compute for some atoms.

  • atomsA (str, default: None ) –

    specify atom-ids in group A.

  • atomsB (str, default: None ) –

    specify atom-ids in group B.

  • options (str, default: '' ) –

    add options.

Returns:

  • list ( list ) –

    list of strings.

script_LOCAL_CRYSTALINITY(a_fcc, zDirect, label='mcv', vectors=[[1, 0, 0], [0, 1, 0], [0, 0, 1]], atoms='@mdatoms', options='')

PLUMED script to compute LOCAL_CRYSTALINITY

Parameters:

  • a_fcc (float) –

    Lattice constant of FCC crystal

  • zDirect (str) –

    specify the z-direction of crystal

  • label (str, default: 'mcv' ) –

    label of PLUMED command

  • vectors (list, default: [[1, 0, 0], [0, 1, 0], [0, 0, 1]] ) –

    2xN list of lists, to specify directions of reciprocal vectors.

  • atoms (str, default: '@mdatoms' ) –

    specify atom-ids in computed group.

  • options (str, default: '' ) –

    add options.

Returns:

  • list ( list ) –

    list of strings.

script_LOGMFD(ARG, FICT, FICT_MIN, FICT_MAX, TEMP, DELTA_T, INTERVAL, KAPPA, deltaF, deltaX, kB, label='mfd', FLOG=5000, MFDstat='VS')

PLUMED script to compute LOGFMD

Parameters:

  • ARG (str) –

    the scalar input for this action

  • FICT (float) –

    The initial values of the fictitious dynamical variables

  • FICT_MIN (float) –

    Boundaries of CV_space

  • FICT_MAX (float) –

    Boundaries of CV_space

  • TEMP (float) –

    Temperature of the fictitious dynamical variables

  • DELTA_T (float) –

    Time step for the fictitious dynamical variables (MFD step)

  • INTERVAL (int) –

    Period of MD steps ( Nm) to update fictitious dynamical variables

  • KAPPA (int) –

    Spring constant of the harmonic restraining potential for the fictitious dynamical variables

  • deltaF (float) –

    Energy Barrier to estimate ALPHA (Alpha parameter for LogMFD)

  • deltaX (float) –

    CV distance at each MFDstep, to estimate MFICT, VFICT (mass & velocity of fictitious dynamical variable)

  • kB (float) –

    Boltzmann constant

  • label (str, default: 'mfd' ) –

    label of PLUMED command

  • FLOG (float, default: 5000 ) –

    The initial free energy value in the LogMFD, initial F(X)

  • MFDstat (str, default: 'VS' ) –

    Type of thermostat for the fictitious dynamical variables. NVE, NVT, VS are available.

Returns:

  • list ( list ) –

    list of strings.

sevennet

Some notes

RFE

Functions:

  • cli_7net_optimize

    Return filepath of the script for running optimization using SevenNet.

cli_7net_optimize(copy_to: str = None) -> str

Return filepath of the script for running optimization using SevenNet.