diff --git a/.github/workflows/test-dftd3-src.yml b/.github/workflows/test-dftd3-src.yml new file mode 100644 index 0000000..a102ac0 --- /dev/null +++ b/.github/workflows/test-dftd3-src.yml @@ -0,0 +1,54 @@ +name: test-dftd3-src + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build-static: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: run tests directly + run: | + cd dftd3-src + export DFTD3_SRC_DEV=1 + cargo test --test "*" -vv --features="build_from_source static" -- --nocapture + + build-dynamic: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: run tests directly + run: | + cd dftd3-src + cargo test --test "*" -vv --features="build_from_source" -- --nocapture + + external-static: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + - name: run tests directly + run: | + cd dftd3-src + conda install dftd3-python -c conda-forge + ls /usr/share/miniconda/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/share/miniconda/lib + export DFTD3_SRC_DEV=1 + cargo test --test "*" -vv --features="static" -- --nocapture + + external-dynamic: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + - name: run tests directly + run: | + cd dftd3-src + conda install dftd3-python -c conda-forge + ls /usr/share/miniconda/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/share/miniconda/lib + cargo test --test "*" -vv -- --nocapture diff --git a/.github/workflows/test-dftd3.yml b/.github/workflows/test-dftd3.yml new file mode 100644 index 0000000..9a9aead --- /dev/null +++ b/.github/workflows/test-dftd3.yml @@ -0,0 +1,23 @@ +name: test-dftd3 + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test-from-miniconda: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: conda-incubator/setup-miniconda@v3 + - name: run tests directly + run: | + cd dftd3 + conda install dftd3-python -c conda-forge + ls /usr/share/miniconda/lib + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/share/miniconda/lib + export DFTD3_DEV=1 + cargo test + cargo test --examples diff --git a/dftd3-src/build.rs b/dftd3-src/build.rs index 7625784..fe12e71 100644 --- a/dftd3-src/build.rs +++ b/dftd3-src/build.rs @@ -83,8 +83,11 @@ fn main() { if cfg!(feature = "static") { println!("cargo:rustc-link-lib=static=s-dftd3"); println!("cargo:rustc-link-lib=static=mctc-lib"); - println!("cargo:rerun-if-env-changed=DFTD3_DEV_LINUX"); - if std::env::var("DFTD3_DEV_LINUX").is_ok() { + // static linking may requires gomp and gfortran to be dynamically linked + // but that depends on the compiler and the system, so user should take care + // of that. We just provide a hint here. + println!("cargo:rerun-if-env-changed=DFTD3_SRC_DEV"); + if std::env::var("DFTD3_SRC_DEV").is_ok() { println!("cargo:rustc-link-lib=gomp"); println!("cargo:rustc-link-lib=gfortran"); } diff --git a/dftd3-src/src/lib.rs b/dftd3-src/src/lib.rs index 0c9ac1a..7592323 100644 --- a/dftd3-src/src/lib.rs +++ b/dftd3-src/src/lib.rs @@ -1 +1,6 @@ +//! simple-dftd3 build-from-source or library selection +//! +//! This module is only used for rust-side configuration of library linking. +//! Please see the following document for more details. +#![doc = include_str!("../readme.md")] #![no_std] diff --git a/dftd3/examples/energy_r2scan_d3zero.rs b/dftd3/examples/energy_r2scan_d3zero.rs index d2110c7..7ddb087 100644 --- a/dftd3/examples/energy_r2scan_d3zero.rs +++ b/dftd3/examples/energy_r2scan_d3zero.rs @@ -31,6 +31,8 @@ fn main_test() { let model = DFTD3Model::new(&numbers, &positions, None, None); // explicitly set DFTD3 parameters for atm in [true, false] { + let energy_ref = if atm { -0.01410721853585842 } else { -0.014100267345314462 }; + let param = DFTD3ZeroDampingParamBuilder::default() .s8(1.683) .rs6(1.139) @@ -40,7 +42,37 @@ fn main_test() { let (energy, _, _) = model.get_dispersion(¶m, false).into(); println!("Dispersion energy: {}", energy); - let energy_ref = if atm { -0.01410721853585842 } else { -0.014100267345314462 }; + assert!((energy - energy_ref).abs() < 1e-9); + + // this way to provide custom damping parameter is also valid + let param = DFTD3ZeroDampingParam { + s6: 1.0, + s8: 1.683, + rs6: 1.139, + rs8: 1.0, + alp: 14.0, + s9: if atm { 1.0 } else { 0.0 }, + }; + let param = param.new_param(); + // obtain the dispersion energy without gradient and sigma + let (energy, _, _) = model.get_dispersion(¶m, false).into(); + + println!("Dispersion energy: {}", energy); + assert!((energy - energy_ref).abs() < 1e-9); + + // this way to provide custom damping parameter is also valid + let param = DFTD3Param::new_zero_damping( + 1.0, // s6 + 1.683, // s8 + if atm { 1.0 } else { 0.0 }, // s9 + 1.139, // rs6 + 1.0, // rs8 + 14.0, // alp + ); + // obtain the dispersion energy without gradient and sigma + let (energy, _, _) = model.get_dispersion(¶m, false).into(); + + println!("Dispersion energy: {}", energy); assert!((energy - energy_ref).abs() < 1e-9); } } diff --git a/dftd3/src/damping_param_usage.md b/dftd3/src/damping_param_usage.md new file mode 100644 index 0000000..fe7275d --- /dev/null +++ b/dftd3/src/damping_param_usage.md @@ -0,0 +1,52 @@ +# Common API documentation for custom damping parameter specification + +If your task is to retrive damping parameters of some specific xc-functionals, you may wish to try [`dftd3_load_param`] function. + +In this crate, you may have three ways to define customized parameters: + +- By `DFTD3***DampingParam` struct. In this way, all parameters (include optional parameters with default value) must be provided. For example of B3-Zero: + + ```rust + # use dftd3::prelude::*; + # let atm = true; + let param = DFTD3ZeroDampingParam { + s6: 1.0, + s8: 1.683, + rs6: 1.139, + rs8: 1.0, + alp: 14.0, + s9: if atm { 1.0 } else { 0.0 }, + }; + let param = param.new_param(); + // this will give param: DFTD3Param + ``` + +- By `DFTD3***DampingParamBuilder` struct. In this way, optional parameters can be omitted. For example of B3-Zero: + + ```rust + # use dftd3::prelude::*; + # let atm = true; + let param = DFTD3ZeroDampingParamBuilder::default() + .s8(1.683) + .rs6(1.139) + .s9(if atm { 1.0 } else { 0.0 }) + .init(); + // this will give param: DFTD3Param + ``` + +- By `DFTD3Param` utility. In this way, all parameters must be provided. For example of B3-Zero: + + ```rust + # use dftd3::prelude::*; + # let atm = true; + let param = DFTD3Param::new_zero_damping( + 1.0, // s6 + 1.683, // s8 + if atm { 1.0 } else { 0.0 }, // s9 + 1.139, // rs6 + 1.0, // rs8 + 14.0, // alp + ); + ``` + +Please note that different DFT-D3 versions may have different parameters, for example modified zero damping have another parameter `bet` for beta, and rational damping (D3-BJ) have parameter name `a1`, `a2` instead of `rs6`, `rs8`. diff --git a/dftd3/src/interface.rs b/dftd3/src/interface.rs index 2ddcbda..a44f294 100644 --- a/dftd3/src/interface.rs +++ b/dftd3/src/interface.rs @@ -1,3 +1,5 @@ +//! DFTD3 interface (safe wrapper). + use crate::ffi; use derive_builder::{Builder, UninitializedFieldError}; use duplicate::duplicate_item; @@ -555,14 +557,37 @@ impl DFTD3Param { /* #region DFTD3 Damping derivatives */ -/// Load damping parameters by functional and DFT-D3 versions. +/// Load damping parameters by xc-functional and DFT-D3 versions. +/// +/// # Arguments +/// +/// - `version` - DFT-D3 variant (`d3bj`, `d3zero`, `d3bjm`, `d3zerom`, `d3op`) +/// - `method` - xc-functional name (e.g. `pbe0`, `b3lyp`, etc.) +/// - `atm` - use three-body correction (true) or two-body correction (false) +/// +/// # Available DFTD3 variants (versions) /// -/// Available versions are: /// - `d3bj`: rational damping; /// - `d3zero`: zero damping; /// - `d3bjm`: modified rational damping; /// - `d3zerom`: modified zero damping; /// - `d3op`: optimized power damping. +/// +/// # Notes +/// +/// If you want to specify custom parameters, please use +/// - [`DFTD3RationalDampingParam`] for rational damping; +/// - [`DFTD3ZeroDampingParam`] for zero damping; +/// - [`DFTD3ModifiedRationalDampingParam`] for modified rational damping; +/// - [`DFTD3ModifiedZeroDampingParam`] for modified zero damping; +/// - [`DFTD3OptimizedPowerDampingParam`] for optimized power damping. +/// +/// You may also check [`DFTD3Param`], but note that this struct is somehow +/// low-level API, so use it with more care. +/// +/// Please note that parameters object can be retrived, only means that we can +/// use these parameters for program computation, and does not necessarily means +/// that `s6`, `s8`, etc is available and can be printed. pub fn dftd3_load_param(version: &str, method: &str, atm: bool) -> DFTD3Param { dftd3_load_param_f(version, method, atm).unwrap() } @@ -607,17 +632,38 @@ pub trait DFTD3LoadParamAPI { } } +/// Rational damping function for DFT-D3. +/// +/// The original scheme was proposed by Becke and Johnson [^becke2005] +/// [^johnson2005] [^johnson2006] and implemented in a slightly adjusted form +/// using only the C8/C6 ratio in the critical for DFT-D3 [^grimme2011]. The +/// rational damping scheme has the advantage of damping the dispersion energy +/// to finite value, rather than removing it at short distances. +/// +/// # Note +/// +/// The zero damping function is retained for the three-body contributions from +/// the ATM term. +/// +/// [^becke2005]: Becke, A. D.; Johnson, E. R. A density-functional model of the dispersion interaction. *J. Chem. Phys.*, **2005**, *123*(15), 154101. doi: [10.1063/1.2065267](https://dx.doi.org/10.1063/1.2065267). +/// [^johnson2005]: Johnson, E. R.; Becke, A. D. A post-hartree–fock model of intermolecular interactions. *J. Chem. Phys.*, **2005**, *123*(2), 024101. doi:[10.1063/1.1949201](https://dx.doi.org/10.1063/1.1949201). +/// [^johnson2006]: Johnson, E. R.; Becke, A. D. A post-hartree-fock model of intermolecular interactions: inclusion of higher-order corrections. *J. Chem. Phys.*, **2006**, *124*(17), 174104. doi: [10.1063/1.2190220](https://dx.doi.org/10.1063/1.2190220). +/// [^grimme2011]: Grimme, S.; Ehrlich, S.; Goerigk, L. Effect of the damping function in dispersion corrected density functional theory. *J. Comput. Chem.*, **2011**, *32*, 1456–1465. doi: [10.1002/jcc.21759](https://dx.doi.org/10.1002/jcc.21759). +#[doc = include_str!("damping_param_usage.md")] #[derive(Builder, Debug, Clone)] #[builder(pattern = "owned", build_fn(error = "DFTD3Error"))] pub struct DFTD3RationalDampingParam { #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub s6: f64, pub s8: f64, #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub s9: f64, pub a1: f64, pub a2: f64, #[builder(default = 14.0)] + #[doc = r"optional, default 14.0"] pub alp: f64, } @@ -628,24 +674,35 @@ impl DFTD3ParamAPI for DFTD3RationalDampingParam { } } -/// Original DFT-D3 damping function,\ :footcite:`grimme2010` based on a variant -/// proposed by Chai and Head-Gordon.\ :footcite:`chai2008` -/// Since it is damping the dispersion energy to zero at short distances it is -/// usually called zero damping scheme for simplicity. However, due to this -/// short-range limit of the dispersion energy a repulsive contribution to the -/// gradient can arise, which is considered artificial.\ :footcite:`grimme2011` +/// Original DFT-D3 damping function with variant. +/// +/// Original DFT-D3 damping function [^grimme2010], based on a variant proposed +/// by Chai and Head-Gordon [^chai2008]. Since it is damping the dispersion +/// energy to zero at short distances it is usually called zero damping scheme +/// for simplicity. However, due to this short-range limit of the dispersion +/// energy a repulsive contribution to the gradient can arise, which is +/// considered artificial [^grimme2011]. +/// +/// [^grimme2010]: S. Grimme, J. Antony, S. Ehrlich, and H. Krieg. A consistent and accurate ab initio parametrization of density functional dispersion correction (DFT-D) for the 94 elements H-Pu. J. Chem. Phys., 132:154104, 2010. doi: [10.1063/1.3382344](https://dx.doi.org/10.1063/1.3382344). +/// [^chai2008]: Chai, J.-D.; Head-Gordon, M. Long-range corrected hybrid density functionals with damped atom–atom dispersion corrections. *Phys. Chem. Chem. Phys.*, **2008**, *10*(44), 6615–6620. doi: [10.1039/B810189B](https://dx.doi.org/10.1039/B810189B). +/// [^grimme2011]: Grimme, S.; Ehrlich, S.; Goerigk, L. Effect of the damping function in dispersion corrected density functional theory. *J. Comput. Chem.*, **2011**, *32*, 1456–1465. doi: [10.1002/jcc.21759](https://dx.doi.org/10.1002/jcc.21759). +#[doc = include_str!("damping_param_usage.md")] #[derive(Builder, Debug, Clone)] #[builder(pattern = "owned", build_fn(error = "DFTD3Error"))] pub struct DFTD3ZeroDampingParam { #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub s6: f64, pub s8: f64, #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub s9: f64, pub rs6: f64, #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub rs8: f64, #[builder(default = 14.0)] + #[doc = r"optional, default 14.0"] pub alp: f64, } @@ -656,26 +713,28 @@ impl DFTD3ParamAPI for DFTD3ZeroDampingParam { } } -/// Modified version of the rational damping parameters. The functional form of -/// the damping function is *unmodified* with respect to the original rational -/// damping scheme. However, for a number of functionals new parameters were -/// introduced.:footcite:`smith2016` +/// Modified version of the rational damping parameters. /// -/// This constructor allows to automatically load the reparameterized damping -/// function from the library rather than the original one. Providing a full -/// parameter set is functionally equivalent to using the `RationalDampingParam` -/// constructor. +/// The functional form of the damping function is **unmodified** with respect +/// to the original rational damping scheme. However, for a number of +/// functionals new parameters were introduced [^smith2016]. +/// +/// [^smith2016]: Smith, D. G. A.; Burns, L. A.; Patkowski, K.; Sherrill, C. D. Revised damping parameters for the D3 dispersion correction to density functional theory. *J. Phys. Chem. Lett.*, **2016**, *7*(12), 2197–2203. doi: [10.1021/acs.jpclett.6b00780](https://dx.doi.org/10.1021/acs.jpclett.6b00780). +#[doc = include_str!("damping_param_usage.md")] #[derive(Builder, Debug, Clone)] #[builder(pattern = "owned", build_fn(error = "DFTD3Error"))] pub struct DFTD3ModifiedRationalDampingParam { #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub s6: f64, pub s8: f64, #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub s9: f64, pub a1: f64, pub a2: f64, #[builder(default = 14.0)] + #[doc = r"optional, default 14.0"] pub alp: f64, } @@ -686,25 +745,33 @@ impl DFTD3ParamAPI for DFTD3ModifiedRationalDampingParam { } } -/// Modified zero damping function for DFT-D3.\ :footcite:`smith2016` -/// This scheme adds an additional offset parameter to the zero damping scheme -/// of the original DFT-D3. +/// Modified zero damping function for DFT-D3. /// -/// .. note:: +/// This scheme [^smith2016] adds an additional offset parameter to the zero +/// damping scheme of the original DFT-D3. /// -/// This damping function is identical to zero damping for ``bet=0.0``. +/// # Note +/// +/// This damping function is identical to zero damping for `bet=0.0`. +/// +/// [^smith2016]: Smith, D. G. A.; Burns, L. A.; Patkowski, K.; Sherrill, C. D. Revised damping parameters for the D3 dispersion correction to density functional theory. *J. Phys. Chem. Lett.*, **2016**, *7*(12), 2197–2203. doi: [10.1021/acs.jpclett.6b00780](https://dx.doi.org/10.1021/acs.jpclett.6b00780). +#[doc = include_str!("damping_param_usage.md")] #[derive(Builder, Debug, Clone)] #[builder(pattern = "owned", build_fn(error = "DFTD3Error"))] pub struct DFTD3ModifiedZeroDampingParam { #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub s6: f64, pub s8: f64, #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub s9: f64, pub rs6: f64, #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub rs8: f64, #[builder(default = 14.0)] + #[doc = r"optional, default 14.0"] pub alp: f64, pub bet: f64, } @@ -716,25 +783,32 @@ impl DFTD3ParamAPI for DFTD3ModifiedZeroDampingParam { } } -/// Optimized power version of the rational damping parameters.\ -/// :footcite:`witte2017` The functional form of the damping function is -/// modified by adding an additional zero-damping like power function. +/// Optimized power version of the rational damping parameters. +/// +/// The functional form of the damping function is modified by adding an +/// additional zero-damping like power function [^witte2017]. /// /// This constructor allows to automatically load the reparameterized damping /// function from the library rather than the original one. Providing the -/// parameter `bet=0` is equivalent to using rational the `RationalDampingParam` -/// constructor. +/// parameter `bet=0` is equivalent to using rational the +/// [`DFTD3RationalDampingParam`] constructor. +/// +/// [^witte2017]: Witte, J.; Mardirossian, N.; Neaton, J. B.; Head-Gordon, M. Assessing DFT-D3 damping functions across widely used density functionals: Can we do better? *J. Chem. Theory Comput.*, **2017**, *13*(5), 2043–2052. doi: [10.1021/acs.jctc.7b00176](https://dx.doi.org/10.1021/acs.jctc.7b00176). +#[doc = include_str!("damping_param_usage.md")] #[derive(Builder, Debug, Clone)] #[builder(pattern = "owned", build_fn(error = "DFTD3Error"))] pub struct DFTD3OptimizedPowerDampingParam { #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub s6: f64, pub s8: f64, #[builder(default = 1.0)] + #[doc = r"optional, default 1.0"] pub s9: f64, pub a1: f64, pub a2: f64, #[builder(default = 14.0)] + #[doc = r"optional, default 14.0"] pub alp: f64, pub bet: f64, } diff --git a/dftd3/src/lib.rs b/dftd3/src/lib.rs index 6ad886b..d52d64a 100644 --- a/dftd3/src/lib.rs +++ b/dftd3/src/lib.rs @@ -4,10 +4,22 @@ For API users, the most important part of this crate is the [`interface`] module. The commonly used functions and structs can be -- [`DFTD3Model`](interface::DFTD3Model) -- [`dftd3_load_param`](interface::dftd3_load_param) + +- [`DFTD3Model`](interface::DFTD3Model): serve as main driver struct for DFTD3. +- [`dftd3_load_param`](interface::dftd3_load_param): load parameters with xc-functional and DFT-D3 version specified. + +To specify custom DFT-D3 parameters, some structs you may interest. + +- [`DFTD3RationalDampingParam`](interface::DFTD3RationalDampingParam) for rational damping; +- [`DFTD3ZeroDampingParam`](interface::DFTD3ZeroDampingParam) for zero damping; +- [`DFTD3ModifiedRationalDampingParam`](interface::DFTD3ModifiedRationalDampingParam) for modified rational damping; +- [`DFTD3ModifiedZeroDampingParam`](interface::DFTD3ModifiedZeroDampingParam) for modified zero damping; +- [`DFTD3OptimizedPowerDampingParam`](interface::DFTD3OptimizedPowerDampingParam) for optimized power damping. + +You may also check [`DFTD3Param`](interface::DFTD3Param), but note that this struct is somehow low-level API, so use it with more care. */ +#![doc = include_str!("../readme.md")] pub mod ffi; pub mod interface; @@ -16,5 +28,10 @@ pub mod interface; pub mod interface_gcp; pub mod prelude { + //! Use `dftd3::prelude::*` to import all the commonly used structs and + //! functions. pub use crate::interface::*; + + #[cfg(feature = "gcp")] + pub use crate::interface_gcp::*; } diff --git a/readme.md b/readme.md index 52ceed8..d705b66 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,11 @@ This crate is not official bindgen project. It is originally intended to potenti This crate contains simple-dftd3 FFI bindings and wrapper. -Crate version: [![Crate](https://img.shields.io/crates/v/dftd3.svg)](https://crates.io/crates/dftd3) +| Resources | Badges | +|--|--| +| Crate | [![Crate](https://img.shields.io/crates/v/dftd3.svg)](https://crates.io/crates/dftd3) | +| API Document | [![API Documentation](https://docs.rs/dftd3/badge.svg)](https://docs.rs/dftd3) | +| FFI Binding | [bd59f81](https://github.com/dftd3/simple-dftd3/commit/bd59f81e9f3ab3cf383e4699e1dda03dce5d9845) after [![v1.2.1](https://img.shields.io/github/v/release/dftd3/simple-dftd3)](https://github.com/dftd3/simple-dftd3/releases/v1.2.1) | ### Cargo features of `dftd3` @@ -22,7 +26,7 @@ Crate version: [![Crate](https://img.shields.io/crates/v/dftd3.svg)](https://cra For example, full code for computing r2SCAN dispersion energy with D3(BJ): -```rust, ignore +```rust fn main() { use dftd3::prelude::*; @@ -68,6 +72,59 @@ fn main() { } ``` +## Installation guide and Crate `dftd3-src` + +| Resources | Badges | +|--|--| +| Crate | [![Crate](https://img.shields.io/crates/v/dftd3-src.svg)](https://crates.io/crates/dftd3-src) | + +To use crate `dftd3` in rust, you may need to perform some configuration to properly link `libs-dftd3.so` into your own program. + +### Install `s-dftd3` + +Please refer to original [github](https://github.com/dftd3/simple-dftd3) repository for more instructions. + +The easiest way is install from conda/mamba, and you can retrive the shared/static library therein. + +### Manually link `s-dftd3` into your project + +Similar to other projects, after library search path properly defined +```rust,ignore +println!("cargo:rustc-link-search=native={}", path); +``` +you may link `s-dftd3` and `mctc-lib` by cargo instructions **in your own project**: +```rust,ignore +// following code is for static linking +println!("cargo:rustc-link-lib=static=s-dftd3"); +println!("cargo:rustc-link-lib=static=mctc-lib"); +// following code is for dynamic linking +println!("cargo:rustc-link-lib=s-dftd3"); +println!("cargo:rustc-link-lib=mctc-lib"); +``` +It should be noted that, for static linking, you may also need to dynamic link Fortran and OpenMP libraries (for the library installed by conda or mamba, it is usually `gfortran` and `gomp`). + +### Link `s-dftd3` by crate `dftd3-src` + +You can also link `s-dftd3` by crate `dftd3-src`. + +First, **in your own project**'s `lib.rs` or `main.rs`, you need to add a line for explicitly importing this library: +```rust,ignore +extern crate dftd3_src; +``` + +If you have compiled `s-dftd3` library, make sure path of it (together with `mctc-lib`) is either in +- `DFTD3_DIR` +- `REST_EXT_DIR` +- `LD_LIBRARY_PATH` +- or in other common system library paths. + +If you have not compiled `s-dftd3` library, you may try out cargo feature `build_from_source`, but that can also cause trobule when distributing your program binary, so use with caution. + +### Cargo features of `dftd3-src` + +- **`build_from_source`**: This will use CMake and meson, and pull code from github to first perform build for simple-dftd3. Though this option can be developer-friendly (you do not need to perform any other configurations to make program compile and run by cargo), `build_from_source` does not provide customized compilation. +- **`static`**: This will link static libary instead of dynamic one. Please note that 1. static linking may require additional Fortran and OpenMP linking, which is not provided in this crate; 2. staticly linking LGPL-3.0 license may require your project to be GPL-3.0. + ## License This repository is licensed under LGPL-3.0, the same to simple-dftd3.