API Reference

CrystalCumulants.jl exposes two functions. The Julia and Python interfaces use the same argument names and semantics; only syntax differs (keyword vs **kwargs, true vs True, etc.).

make_stdep_ifcs

Generate self-consistent TDEP force constants. Second-order IFCs are iterated to convergence; 3rd- and 4th-order IFCs are fit from the final configuration set. Harmonic free energy per iteration is written to harmonic_free_energy.txt to aid in assesing convergence. DOS and dispersion are also calculated at each iteration.

Arguments (positional, in order):

ArgumentDescription
ucposcar_pathPath to unit-cell POSCAR (TDEP format)
ssposcar_pathPath to supercell POSCAR (TDEP format)
outdirOutput directory for sTDEP results
pot_cmdsLAMMPS potential commands (Vector{String} / list[str])
n_iterNumber of self-consistent sTDEP iterations
r_cutPair potential cutoff for 2nd-order IFCs
TTemperature (K)
maximum_frequencyMaximum frequency for the initial IFC guess
quantumSample quantum or classical configurations
rc3Cutoff radius for 3rd-order IFC fitting
rc4Cutoff radius for 4th-order IFC fitting

Optional keyword arguments are forwarded to sTDEP (Julia: kwargs...; Python: **kwargs). Common options include mix, nconf_init, and max_configs.

Output files (2nd- through 4th-order IFCs and related sTDEP outputs) are written under outdir.

crystal_thermodynamic_properties

Calculate thermodynamic properties across a temperature range using the free energy cumulant expansion.

Arguments (positional, in order):

ArgumentDescription
temperaturesTemperatures to evaluate (K), e.g. [24] or [100, 200, 300]
outpathOutput directory (or temperature-dependent path; see below)
ucposcar_pathUnit-cell POSCAR (TDEP format)
ssposcar_pathSupercell POSCAR (TDEP format)
ifc2_path2nd-order IFC file (infile.forceconstant)
ifc3_path3rd-order IFC file (infile.forceconstant_thirdorder)
ifc4_path4th-order IFC file (infile.forceconstant_fourthorder)
pot_cmdsLAMMPS potential commands for the true potential energy

Keyword arguments:

KeywordDefaultDescription
quantumfalseUse quantum (true) or classical (false) statistics
nconf100_000Configurations sampled for the 0th-order correction
nboot2500Bootstrap samples for 0th-order standard error
size_studyfalseIf enabled, write 0th-order correction vs. sample count
harmonic_q_mesh[30, 30, 30]q-mesh for the harmonic contribution
free_energy_q_mesh[25, 25, 25]q-mesh for 1st- and 2nd-order corrections
n_threadsall Julia threadsParallel thread count (be sure to set JULIA_NUM_THREADS / PYTHON_JULIACALL_THREADS)

Output files

For each property, the code writes F_mean.txt, U_mean.txt, S_mean.txt, and Cv_mean.txt with rows broken down into harmonic (F0, etc.), 0th-order offset, 1st-order, 2nd-order, and total. Only the 0th-order correction has an associated bootstrap standard error. HDF5 versions (.h5) are also written.

Temperature-dependent paths

For crystal_thermodynamic_properties, the path arguments (outpath, ucposcar_path, ssposcar_path, ifc2_path, ifc3_path, ifc4_path) may be either:

  • a fixed path string, when inputs are the same for every temperature, or
  • a function of temperature T (in K), when structures or IFCs vary with T.

In Julia, pass an anonymous function (T) -> path. In Python, pass a lambda.

Julia

using CrystalCumulants

base = "/data/stdep/RESULTS"
temperatures = [100.0, 200.0, 300.0]

crystal_thermodynamic_properties(
    temperatures,
    (T) -> "/out/T$(Int(T))",
    (T) -> joinpath(base, "T$(Int(T))_0", "infile.ucposcar"),
    (T) -> joinpath(base, "T$(Int(T))_0", "infile.ssposcar"),
    (T) -> joinpath(base, "T$(Int(T))_0", "infile.forceconstant"),
    (T) -> joinpath(base, "T$(Int(T))_0", "infile.forceconstant_thirdorder"),
    (T) -> joinpath(base, "T$(Int(T))_0", "infile.forceconstant_fourthorder"),
    pot_cmds,
)

Python

from os.path import join

from cumulant_analysis import crystal_thermodynamic_properties

base = "/data/stdep/RESULTS"
temperatures = [100.0, 200.0, 300.0]

crystal_thermodynamic_properties(
    temperatures,
    lambda T: f"/out/T{int(T)}",
    lambda T: join(base, f"T{int(T)}_0", "infile.ucposcar"),
    lambda T: join(base, f"T{int(T)}_0", "infile.ssposcar"),
    lambda T: join(base, f"T{int(T)}_0", "infile.forceconstant"),
    lambda T: join(base, f"T{int(T)}_0", "infile.forceconstant_thirdorder"),
    lambda T: join(base, f"T{int(T)}_0", "infile.forceconstant_fourthorder"),
    pot_cmds,
)

Each function receives the temperature T for the current evaluation and must return a path string.