Skip to main content

Module ffi_dynamic

Module ffi_dynamic 

Source
Expand description

FFI module for dftd4 (dynamic loading).

This module provides dynamic loading support.

§Rule and guide of dynamic loading

By enabling the dynamic_loading feature (which is the default), the crate will attempt to load the dftd4 shared library at runtime. The loading process will search for the library in multiple locations, by the following order:

  1. User-defined candidates via environment variables DFTD4_DYLOAD.
  2. LD_LIBRARY_PATH style discovery via environment variables LD_LIBRARY_PATH (Linux), DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH (macOS), PATH (Windows). Note we are not distinguishing different operating systems, so all these environment variables will be checked on all platforms.
  3. Python interpreter path discovery: For each python interpreter found, the library is expected to be at the lib directory of the python installation. For example, if python is at /path/bin/python, the library is expected at /path/lib/libdftd4.so.
    • The python interpreter path of DFTD4_PYTHON_PATH environment variable, if set.
    • The conda prefix path of CONDA_PREFIX environment variable, if set.
    • The python interpreter path in PATH environment variable, if exists. Will first check python, then python3.
  4. Standard system candidates, such as lib{LIB_NAME_LINK}.so in some common library directories such as /usr/lib, /usr/local/lib, and /lib.

For API developer, if you want to check the library libdftd4.so loading sequence, you can try the following code:

let candidates = unsafe { &dftd4::ffi::dyload_lib().__libraries_path };
println!("Library loading candidates: {candidates:#?}");

Structs§

DyLoadLib
_dftd4_error
_dftd4_model
_dftd4_param
_dftd4_structure

Constants§

LIB_NAME
LIB_NAME_LINK
LIB_NAME_SHOW
MOD_NAME

Functions§

dftd4_check_error
dftd4_custom_d4_model
dftd4_custom_d4s_model
dftd4_delete_error
dftd4_delete_model
dftd4_delete_param
dftd4_delete_structure
dftd4_get_dispersion
dftd4_get_error
dftd4_get_numerical_hessian
dftd4_get_pairwise_dispersion
dftd4_get_properties
dftd4_get_version
dftd4_load_rational_damping
dftd4_new_d4_model
dftd4_new_d4s_model
dftd4_new_error
dftd4_new_rational_damping
dftd4_new_structure
dftd4_set_model_realspace_cutoff
dftd4_set_model_realspace_cutoff_smooth
dftd4_update_structure
dyload_lib

Type Aliases§

dftd4_error
Error handle class
dftd4_model
Dispersion model class
dftd4_param
Damping parameter class
dftd4_structure
Molecular structure data class