Expand description
Flexible parsing of DFT-D3 damping parameters from TOML or JSON input.
This module provides functions to parse parameter specifications that can
combine method lookups from the database with direct parameter values,
overrides, and the atm flag for three-body dispersion control.
§Supported input formats
- Usual case with method:
{version = "d3bj", method = "b3lyp"}Lookup B3LYP-D3(BJ) parameters from the database. - Version without d3 prefix:
{version = "bj", method = "b3lyp"}Thed3prefix is optional. Theversionfield is case-insensitive, soBJworks too. - Direct parameters:
{version = "d3bj", a1 = 0.3981, s8 = 1.9889, a2 = 4.4211}Specify parameters directly without using the database. - ATM flag (no three-body):
{version = "bj", method = "b3lyp", atm = false}Setss9 = 0.0. Default isatm = true(s9 = 1.0). - Parameter override:
{version = "d3bj", method = "b3lyp", a1 = 0.5}Use database values but overridea1to 0.5. - Direct params + ATM:
{version = "d3bj", a1 = 0.3981, s8 = 1.9889, a2 = 4.4211, atm = false}Direct parameters withs9 = 0.0. If boths9andatmare provided,s9takes precedence. - Method name normalization:
{version = "zero", method = "m06-2x"}Separators like-,_are removed automatically (normalized tom062xfor lookup). - Invalid field error:
{version = "d3bj", method = "b3lyp", rs6 = 0.5}Returns an error becausers6is not a valid parameter for thebjvariant.
§Example
use dftd3::prelude::*;
// B3LYP with Becke-Johnson damping, no overrides, atm = true (default)
let input = r#"{version = "d3bj", method = "b3lyp"}"#;
// toml parameter type
let damping_param = dftd3_parse_damping_param_from_toml(input);
// FFI parameter type
let dftd3_param = damping_param.new_param();
let atom_charges = vec![8, 1, 1];
// coordinates in bohr
#[rustfmt::skip]
let coordinates = vec![
0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 1.807355,
1.807355, 0.000000, -0.452500,
];
let model = DFTD3Model::new(&atom_charges, &coordinates, None, None);
let res = model.get_dispersion(&dftd3_param, false);
let eng = res.energy;
println!("Dispersion energy: {eng}");Functions§
- dftd3_
parse_ damping_ param - Parse damping parameters from a TOML table.
- dftd3_
parse_ damping_ param_ f - dftd3_
parse_ damping_ param_ from_ json - Parse damping parameters from a JSON string (panics on error).
- dftd3_
parse_ damping_ param_ from_ json_ f - Parse damping parameters from a JSON string (fallible version).
- dftd3_
parse_ damping_ param_ from_ toml - Parse damping parameters from a TOML string (panics on error).
- dftd3_
parse_ damping_ param_ from_ toml_ f - Parse damping parameters from a TOML string (fallible version).