From dbf900ff9929006a97f1dc854d735c2d30ba6a87 Mon Sep 17 00:00:00 2001 From: ajz34 Date: Fri, 15 May 2026 22:56:14 +0800 Subject: [PATCH 01/10] prepare import libxc --- Cargo.toml | 2 ++ build.rs | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ecbe752942..6c89b34fd4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,8 @@ derive_builder = { version = "0.20" } dftd3 = { version = "0.2", optional = true } dftd4 = { version = "0.2", optional = true } +libxc = { version = "0.1" } +libxc-ffi = { version = "0.1" } geometric-pyo3 = { version = "0.1.1", optional = true } approx = "0.5" diff --git a/build.rs b/build.rs index 74ac4744f0..5a5712f733 100644 --- a/build.rs +++ b/build.rs @@ -1,10 +1,12 @@ extern crate dunce; -use std::{env, fs}; +use std::env; use std::path::PathBuf; fn main() -> miette::Result<()> { - generate_libxc_names_and_values(); + // AJZ34: This function should not be called in normal build. + // Also, we are trying to use the external crate `libxc` for better maintainability. + // generate_libxc_names_and_values(); // conditionally link to the libraries based on the features @@ -48,7 +50,9 @@ fn main() -> miette::Result<()> { } +#[allow(dead_code)] fn generate_libxc_names_and_values() { + use std::fs; // Retrieve the REST_HOME environment variable or use an empty string if not set let rest_dir = if let Ok(rest_dir) = env::var("REST_HOME") { rest_dir -- Gitee From 624f3b136697e7ee360f711de25acc5e5e9bbc4d Mon Sep 17 00:00:00 2001 From: ajz34 Date: Sat, 16 May 2026 00:09:29 +0800 Subject: [PATCH 02/10] Replace hand-rolled libxc wrapper with external libxc crate Swap the internal FFI bindings, name maps, and safe wrapper in src/dft/libxc/ for the external `libxc` crate (v0.1, features api-v7_0 + dynamic_loading). The new XcFuncType wraps LibXCFunctional with the same method signatures; LibXCFamily compat enum preserves the 6-variant API. Drop handles cleanup so xc_func_end() is now a no-op. Removes ~5700 lines of hand-maintained FFI code. Co-authored-by: Claude Code Co-authored-by: glm-5 --- Cargo.toml | 2 +- build.rs | 58 +- src/dft/libxc/ffi_xc.rs | 1788 ------------------- src/dft/libxc/libxc_full.rs | 3009 -------------------------------- src/dft/libxc/mod.rs | 1371 +++------------ src/dft/libxc_itrf.rs | 3 +- src/dft/mod.rs | 75 +- src/dft/parse_xc/dispersion.rs | 6 +- src/dft/parse_xc/parse.rs | 24 +- src/dft/parse_xc/xc_helper.rs | 23 +- 10 files changed, 316 insertions(+), 6043 deletions(-) delete mode 100644 src/dft/libxc/ffi_xc.rs delete mode 100644 src/dft/libxc/libxc_full.rs diff --git a/Cargo.toml b/Cargo.toml index 6c89b34fd4..c22faeec32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ derive_builder = { version = "0.20" } dftd3 = { version = "0.2", optional = true } dftd4 = { version = "0.2", optional = true } -libxc = { version = "0.1" } +libxc = { version = "0.1", features = ["api-v7_0", "dynamic_loading"] } libxc-ffi = { version = "0.1" } geometric-pyo3 = { version = "0.1.1", optional = true } diff --git a/build.rs b/build.rs index 5a5712f733..851bbed26b 100644 --- a/build.rs +++ b/build.rs @@ -4,11 +4,6 @@ use std::path::PathBuf; fn main() -> miette::Result<()> { - // AJZ34: This function should not be called in normal build. - // Also, we are trying to use the external crate `libxc` for better maintainability. - // generate_libxc_names_and_values(); - - // conditionally link to the libraries based on the features #[cfg(feature = "intel-mkl")] { println!("cargo:rustc-link-lib=mkl_rt"); @@ -27,7 +22,7 @@ fn main() -> miette::Result<()> { // #[cfg(feature = "dftd4")] // println!("cargo:rustc-link-lib=dftd4"); - let library_names = ["cint","restmatr","xc","hdf5","rest2fch","openblas","gomp"]; + let library_names = ["cint","restmatr","hdf5","rest2fch","openblas","gomp"]; library_names.iter().for_each(|name| { println!("cargo:rustc-link-lib={}",*name); }); @@ -49,54 +44,3 @@ fn main() -> miette::Result<()> { Ok(()) } - -#[allow(dead_code)] -fn generate_libxc_names_and_values() { - use std::fs; - // Retrieve the REST_HOME environment variable or use an empty string if not set - let rest_dir = if let Ok(rest_dir) = env::var("REST_HOME") { - rest_dir - } else {"".to_string()}; - - // Define the output directory and destination path for the generated libxc code - let _out_dir = format!("{}/rest/src/dft/libxc", &rest_dir); - let dest_path = format!("{}/rest/src/dft/libxc/names_and_values.rs", &rest_dir); - let libxc_full_path = format!("{}/rest/src/dft/libxc/libxc_full.rs", &rest_dir); - - // if std::path::Path::new(&dest_path).exists() { - // println!("File {} already exists. Skipping libxc code generation.", dest_path); - // return; - // } - println!("Generating libxc code from {} to {}", libxc_full_path, dest_path); - - // Read the contents of libxc_full.rs and parse lines that start with "pub const" - let constants_code = fs::read_to_string(libxc_full_path).unwrap(); - let const_lines: Vec<_> = constants_code - .lines() - .filter(|line| line.trim().starts_with("pub const")) - .map(|line| { - let parts: Vec<_> = line.split_whitespace().collect(); - let name = parts[2].trim_end_matches(':'); - (name, line) - }) - .collect(); - - // Generate the MAP code by filtering and formatting the parsed lines - let generated_code = format!( - "// This map of libxc names and values is auto-generated by reading libxc_full.rs\npub const MAP: &[(&str, usize)] = &[\n{}\n];", - const_lines - .iter() - .filter(|(_, line)| line.contains("u32")) - .map(|(name, line)| { - let value: Vec<_> = line.split('=').collect(); - let value = value[1].trim().trim_end_matches(';'); - format!(" (\"{}\", {}),", name, value) - }) - .collect::>() - .join("\n") - ); - - // Write the generated code to the destination path - fs::write(&dest_path, generated_code).unwrap(); - println!("cargo:rerun-if-changed={}", dest_path); -} diff --git a/src/dft/libxc/ffi_xc.rs b/src/dft/libxc/ffi_xc.rs deleted file mode 100644 index 3b638fca93..0000000000 --- a/src/dft/libxc/ffi_xc.rs +++ /dev/null @@ -1,1788 +0,0 @@ -/* automatically generated by rust-bindgen 0.59.1 */ - -pub const XC_UNPOLARIZED: u32 = 1; -pub const XC_POLARIZED: u32 = 2; -pub const XC_NON_RELATIVISTIC: u32 = 0; -pub const XC_RELATIVISTIC: u32 = 1; -pub const XC_EXCHANGE: u32 = 0; -pub const XC_CORRELATION: u32 = 1; -pub const XC_EXCHANGE_CORRELATION: u32 = 2; -pub const XC_KINETIC: u32 = 3; -pub const XC_FAMILY_UNKNOWN: i32 = -1; -pub const XC_FAMILY_LDA: u32 = 1; -pub const XC_FAMILY_GGA: u32 = 2; -pub const XC_FAMILY_MGGA: u32 = 4; -pub const XC_FAMILY_LCA: u32 = 8; -pub const XC_FAMILY_OEP: u32 = 16; -pub const XC_FAMILY_HYB_GGA: u32 = 32; -pub const XC_FAMILY_HYB_MGGA: u32 = 64; -pub const XC_FAMILY_HYB_LDA: u32 = 128; -pub const XC_FLAGS_HAVE_EXC: u32 = 1; -pub const XC_FLAGS_HAVE_VXC: u32 = 2; -pub const XC_FLAGS_HAVE_FXC: u32 = 4; -pub const XC_FLAGS_HAVE_KXC: u32 = 8; -pub const XC_FLAGS_HAVE_LXC: u32 = 16; -pub const XC_FLAGS_1D: u32 = 32; -pub const XC_FLAGS_2D: u32 = 64; -pub const XC_FLAGS_3D: u32 = 128; -pub const XC_FLAGS_HYB_CAM: u32 = 256; -pub const XC_FLAGS_HYB_CAMY: u32 = 512; -pub const XC_FLAGS_VV10: u32 = 1024; -pub const XC_FLAGS_HYB_LC: u32 = 2048; -pub const XC_FLAGS_HYB_LCY: u32 = 4096; -pub const XC_FLAGS_STABLE: u32 = 8192; -pub const XC_FLAGS_DEVELOPMENT: u32 = 16384; -pub const XC_FLAGS_NEEDS_LAPLACIAN: u32 = 32768; -pub const XC_FLAGS_HAVE_ALL: u32 = 31; -pub const XC_EXT_PARAMS_DEFAULT: i32 = -999998888; -pub const XC_TAU_EXPLICIT: u32 = 0; -pub const XC_TAU_EXPANSION: u32 = 1; -pub const XC_MAX_REFERENCES: u32 = 5; -pub const XC_HYB_LDA_XC_LDA0: u32 = 177; -pub const XC_HYB_LDA_XC_CAM_LDA0: u32 = 178; -pub const XC_HYB_LDA_XC_BN05: u32 = 588; -pub const XC_LDA_X: u32 = 1; -pub const XC_LDA_C_WIGNER: u32 = 2; -pub const XC_LDA_C_RPA: u32 = 3; -pub const XC_LDA_C_HL: u32 = 4; -pub const XC_LDA_C_GL: u32 = 5; -pub const XC_LDA_C_XALPHA: u32 = 6; -pub const XC_LDA_C_VWN: u32 = 7; -pub const XC_LDA_C_VWN_RPA: u32 = 8; -pub const XC_LDA_C_PZ: u32 = 9; -pub const XC_LDA_C_PZ_MOD: u32 = 10; -pub const XC_LDA_C_OB_PZ: u32 = 11; -pub const XC_LDA_C_PW: u32 = 12; -pub const XC_LDA_C_PW_MOD: u32 = 13; -pub const XC_LDA_C_OB_PW: u32 = 14; -pub const XC_LDA_C_2D_AMGB: u32 = 15; -pub const XC_LDA_C_2D_PRM: u32 = 16; -pub const XC_LDA_C_VBH: u32 = 17; -pub const XC_LDA_C_1D_CSC: u32 = 18; -pub const XC_LDA_X_2D: u32 = 19; -pub const XC_LDA_XC_TETER93: u32 = 20; -pub const XC_LDA_X_1D_SOFT: u32 = 21; -pub const XC_LDA_C_ML1: u32 = 22; -pub const XC_LDA_C_ML2: u32 = 23; -pub const XC_LDA_C_GOMBAS: u32 = 24; -pub const XC_LDA_C_PW_RPA: u32 = 25; -pub const XC_LDA_C_1D_LOOS: u32 = 26; -pub const XC_LDA_C_RC04: u32 = 27; -pub const XC_LDA_C_VWN_1: u32 = 28; -pub const XC_LDA_C_VWN_2: u32 = 29; -pub const XC_LDA_C_VWN_3: u32 = 30; -pub const XC_LDA_C_VWN_4: u32 = 31; -pub const XC_LDA_XC_ZLP: u32 = 43; -pub const XC_LDA_K_TF: u32 = 50; -pub const XC_LDA_K_LP: u32 = 51; -pub const XC_LDA_XC_KSDT: u32 = 259; -pub const XC_LDA_C_CHACHIYO: u32 = 287; -pub const XC_LDA_C_LP96: u32 = 289; -pub const XC_LDA_C_CHACHIYO_MOD: u32 = 307; -pub const XC_LDA_C_KARASIEV_MOD: u32 = 308; -pub const XC_LDA_C_W20: u32 = 317; -pub const XC_LDA_XC_CORRKSDT: u32 = 318; -pub const XC_LDA_X_REL: u32 = 532; -pub const XC_LDA_XC_1D_EHWLRG_1: u32 = 536; -pub const XC_LDA_XC_1D_EHWLRG_2: u32 = 537; -pub const XC_LDA_XC_1D_EHWLRG_3: u32 = 538; -pub const XC_LDA_X_ERF: u32 = 546; -pub const XC_LDA_XC_LP_A: u32 = 547; -pub const XC_LDA_XC_LP_B: u32 = 548; -pub const XC_LDA_X_RAE: u32 = 549; -pub const XC_LDA_K_ZLP: u32 = 550; -pub const XC_LDA_C_MCWEENY: u32 = 551; -pub const XC_LDA_C_BR78: u32 = 552; -pub const XC_LDA_C_PK09: u32 = 554; -pub const XC_LDA_C_OW_LYP: u32 = 573; -pub const XC_LDA_C_OW: u32 = 574; -pub const XC_LDA_XC_GDSMFB: u32 = 577; -pub const XC_LDA_C_GK72: u32 = 578; -pub const XC_LDA_C_KARASIEV: u32 = 579; -pub const XC_LDA_K_LP96: u32 = 580; -pub const XC_LDA_C_PMGB06: u32 = 590; -pub const XC_LDA_XC_TIH: u32 = 599; -pub const XC_LDA_X_1D_EXPONENTIAL: u32 = 600; -pub const XC_LDA_X_YUKAWA: u32 = 641; -pub const XC_LDA_C_UPW92: u32 = 683; -pub const XC_LDA_C_RPW92: u32 = 684; -pub const XC_LDA_X_SLOC: u32 = 692; -pub const XC_HYB_GGA_X_N12_SX: u32 = 81; -pub const XC_HYB_GGA_XC_B97_1P: u32 = 266; -pub const XC_HYB_GGA_XC_PBE_MOL0: u32 = 273; -pub const XC_HYB_GGA_XC_PBE_SOL0: u32 = 274; -pub const XC_HYB_GGA_XC_PBEB0: u32 = 275; -pub const XC_HYB_GGA_XC_PBE_MOLB0: u32 = 276; -pub const XC_HYB_GGA_XC_PBE50: u32 = 290; -pub const XC_HYB_GGA_XC_HFLYP: u32 = 314; -pub const XC_HYB_GGA_XC_CASE21: u32 = 390; -pub const XC_HYB_GGA_XC_PBE_2X: u32 = 392; -pub const XC_HYB_GGA_XC_PBE38: u32 = 393; -pub const XC_HYB_GGA_XC_B3LYP3: u32 = 394; -pub const XC_HYB_GGA_XC_CAM_O3LYP: u32 = 395; -pub const XC_HYB_GGA_XC_WB97X_D3: u32 = 399; -pub const XC_HYB_GGA_XC_LC_BLYP: u32 = 400; -pub const XC_HYB_GGA_XC_B3PW91: u32 = 401; -pub const XC_HYB_GGA_XC_B3LYP: u32 = 402; -pub const XC_HYB_GGA_XC_B3P86: u32 = 403; -pub const XC_HYB_GGA_XC_O3LYP: u32 = 404; -pub const XC_HYB_GGA_XC_MPW1K: u32 = 405; -pub const XC_HYB_GGA_XC_PBEH: u32 = 406; -pub const XC_HYB_GGA_XC_B97: u32 = 407; -pub const XC_HYB_GGA_XC_B97_1: u32 = 408; -pub const XC_HYB_GGA_XC_APF: u32 = 409; -pub const XC_HYB_GGA_XC_B97_2: u32 = 410; -pub const XC_HYB_GGA_XC_X3LYP: u32 = 411; -pub const XC_HYB_GGA_XC_B1WC: u32 = 412; -pub const XC_HYB_GGA_XC_B97_K: u32 = 413; -pub const XC_HYB_GGA_XC_B97_3: u32 = 414; -pub const XC_HYB_GGA_XC_MPW3PW: u32 = 415; -pub const XC_HYB_GGA_XC_B1LYP: u32 = 416; -pub const XC_HYB_GGA_XC_B1PW91: u32 = 417; -pub const XC_HYB_GGA_XC_MPW1PW: u32 = 418; -pub const XC_HYB_GGA_XC_MPW3LYP: u32 = 419; -pub const XC_HYB_GGA_XC_SB98_1A: u32 = 420; -pub const XC_HYB_GGA_XC_SB98_1B: u32 = 421; -pub const XC_HYB_GGA_XC_SB98_1C: u32 = 422; -pub const XC_HYB_GGA_XC_SB98_2A: u32 = 423; -pub const XC_HYB_GGA_XC_SB98_2B: u32 = 424; -pub const XC_HYB_GGA_XC_SB98_2C: u32 = 425; -pub const XC_HYB_GGA_X_SOGGA11_X: u32 = 426; -pub const XC_HYB_GGA_XC_HSE03: u32 = 427; -pub const XC_HYB_GGA_XC_HSE06: u32 = 428; -pub const XC_HYB_GGA_XC_HJS_PBE: u32 = 429; -pub const XC_HYB_GGA_XC_HJS_PBE_SOL: u32 = 430; -pub const XC_HYB_GGA_XC_HJS_B88: u32 = 431; -pub const XC_HYB_GGA_XC_HJS_B97X: u32 = 432; -pub const XC_HYB_GGA_XC_CAM_B3LYP: u32 = 433; -pub const XC_HYB_GGA_XC_TUNED_CAM_B3LYP: u32 = 434; -pub const XC_HYB_GGA_XC_BHANDH: u32 = 435; -pub const XC_HYB_GGA_XC_BHANDHLYP: u32 = 436; -pub const XC_HYB_GGA_XC_MB3LYP_RC04: u32 = 437; -pub const XC_HYB_GGA_XC_MPWLYP1M: u32 = 453; -pub const XC_HYB_GGA_XC_REVB3LYP: u32 = 454; -pub const XC_HYB_GGA_XC_CAMY_BLYP: u32 = 455; -pub const XC_HYB_GGA_XC_PBE0_13: u32 = 456; -pub const XC_HYB_GGA_XC_B3LYPS: u32 = 459; -pub const XC_HYB_GGA_XC_QTP17: u32 = 460; -pub const XC_HYB_GGA_XC_B3LYP_MCM1: u32 = 461; -pub const XC_HYB_GGA_XC_B3LYP_MCM2: u32 = 462; -pub const XC_HYB_GGA_XC_WB97: u32 = 463; -pub const XC_HYB_GGA_XC_WB97X: u32 = 464; -pub const XC_HYB_GGA_XC_LRC_WPBEH: u32 = 465; -pub const XC_HYB_GGA_XC_WB97X_V: u32 = 466; -pub const XC_HYB_GGA_XC_LCY_PBE: u32 = 467; -pub const XC_HYB_GGA_XC_LCY_BLYP: u32 = 468; -pub const XC_HYB_GGA_XC_LC_VV10: u32 = 469; -pub const XC_HYB_GGA_XC_CAMY_B3LYP: u32 = 470; -pub const XC_HYB_GGA_XC_WB97X_D: u32 = 471; -pub const XC_HYB_GGA_XC_HPBEINT: u32 = 472; -pub const XC_HYB_GGA_XC_LRC_WPBE: u32 = 473; -pub const XC_HYB_GGA_XC_B3LYP5: u32 = 475; -pub const XC_HYB_GGA_XC_EDF2: u32 = 476; -pub const XC_HYB_GGA_XC_CAP0: u32 = 477; -pub const XC_HYB_GGA_XC_LC_WPBE: u32 = 478; -pub const XC_HYB_GGA_XC_HSE12: u32 = 479; -pub const XC_HYB_GGA_XC_HSE12S: u32 = 480; -pub const XC_HYB_GGA_XC_HSE_SOL: u32 = 481; -pub const XC_HYB_GGA_XC_CAM_QTP_01: u32 = 482; -pub const XC_HYB_GGA_XC_MPW1LYP: u32 = 483; -pub const XC_HYB_GGA_XC_MPW1PBE: u32 = 484; -pub const XC_HYB_GGA_XC_KMLYP: u32 = 485; -pub const XC_HYB_GGA_XC_LC_WPBE_WHS: u32 = 486; -pub const XC_HYB_GGA_XC_LC_WPBEH_WHS: u32 = 487; -pub const XC_HYB_GGA_XC_LC_WPBE08_WHS: u32 = 488; -pub const XC_HYB_GGA_XC_LC_WPBESOL_WHS: u32 = 489; -pub const XC_HYB_GGA_XC_CAM_QTP_00: u32 = 490; -pub const XC_HYB_GGA_XC_CAM_QTP_02: u32 = 491; -pub const XC_HYB_GGA_XC_LC_QTP: u32 = 492; -pub const XC_HYB_GGA_X_S12H: u32 = 496; -pub const XC_HYB_GGA_XC_BLYP35: u32 = 499; -pub const XC_HYB_GGA_XC_B5050LYP: u32 = 572; -pub const XC_HYB_GGA_XC_LB07: u32 = 589; -pub const XC_HYB_GGA_XC_APBE0: u32 = 607; -pub const XC_HYB_GGA_XC_HAPBE: u32 = 608; -pub const XC_HYB_GGA_XC_RCAM_B3LYP: u32 = 610; -pub const XC_HYB_GGA_XC_WC04: u32 = 611; -pub const XC_HYB_GGA_XC_WP04: u32 = 612; -pub const XC_HYB_GGA_XC_CAMH_B3LYP: u32 = 614; -pub const XC_HYB_GGA_XC_WHPBE0: u32 = 615; -pub const XC_HYB_GGA_XC_LC_BLYP_EA: u32 = 625; -pub const XC_HYB_GGA_XC_LC_BOP: u32 = 636; -pub const XC_HYB_GGA_XC_LC_PBEOP: u32 = 637; -pub const XC_HYB_GGA_XC_LC_BLYPR: u32 = 639; -pub const XC_HYB_GGA_XC_MCAM_B3LYP: u32 = 640; -pub const XC_HYB_GGA_X_CAM_S12G: u32 = 646; -pub const XC_HYB_GGA_X_CAM_S12H: u32 = 647; -pub const XC_HYB_GGA_XC_CAM_PBEH: u32 = 681; -pub const XC_HYB_GGA_XC_CAMY_PBEH: u32 = 682; -pub const XC_GGA_X_GAM: u32 = 32; -pub const XC_GGA_C_GAM: u32 = 33; -pub const XC_GGA_X_HCTH_A: u32 = 34; -pub const XC_GGA_X_EV93: u32 = 35; -pub const XC_GGA_X_BCGP: u32 = 38; -pub const XC_GGA_C_ACGGA: u32 = 39; -pub const XC_GGA_X_LAMBDA_OC2_N: u32 = 40; -pub const XC_GGA_X_B86_R: u32 = 41; -pub const XC_GGA_X_LAMBDA_CH_N: u32 = 44; -pub const XC_GGA_X_LAMBDA_LO_N: u32 = 45; -pub const XC_GGA_X_HJS_B88_V2: u32 = 46; -pub const XC_GGA_C_Q2D: u32 = 47; -pub const XC_GGA_X_Q2D: u32 = 48; -pub const XC_GGA_X_PBE_MOL: u32 = 49; -pub const XC_GGA_K_TFVW: u32 = 52; -pub const XC_GGA_K_REVAPBEINT: u32 = 53; -pub const XC_GGA_K_APBEINT: u32 = 54; -pub const XC_GGA_K_REVAPBE: u32 = 55; -pub const XC_GGA_X_AK13: u32 = 56; -pub const XC_GGA_K_MEYER: u32 = 57; -pub const XC_GGA_X_LV_RPW86: u32 = 58; -pub const XC_GGA_X_PBE_TCA: u32 = 59; -pub const XC_GGA_X_PBEINT: u32 = 60; -pub const XC_GGA_C_ZPBEINT: u32 = 61; -pub const XC_GGA_C_PBEINT: u32 = 62; -pub const XC_GGA_C_ZPBESOL: u32 = 63; -pub const XC_GGA_XC_OPBE_D: u32 = 65; -pub const XC_GGA_XC_OPWLYP_D: u32 = 66; -pub const XC_GGA_XC_OBLYP_D: u32 = 67; -pub const XC_GGA_X_VMT84_GE: u32 = 68; -pub const XC_GGA_X_VMT84_PBE: u32 = 69; -pub const XC_GGA_X_VMT_GE: u32 = 70; -pub const XC_GGA_X_VMT_PBE: u32 = 71; -pub const XC_GGA_C_N12_SX: u32 = 79; -pub const XC_GGA_C_N12: u32 = 80; -pub const XC_GGA_X_N12: u32 = 82; -pub const XC_GGA_C_REGTPSS: u32 = 83; -pub const XC_GGA_C_OP_XALPHA: u32 = 84; -pub const XC_GGA_C_OP_G96: u32 = 85; -pub const XC_GGA_C_OP_PBE: u32 = 86; -pub const XC_GGA_C_OP_B88: u32 = 87; -pub const XC_GGA_C_FT97: u32 = 88; -pub const XC_GGA_C_SPBE: u32 = 89; -pub const XC_GGA_X_SSB_SW: u32 = 90; -pub const XC_GGA_X_SSB: u32 = 91; -pub const XC_GGA_X_SSB_D: u32 = 92; -pub const XC_GGA_XC_HCTH_407P: u32 = 93; -pub const XC_GGA_XC_HCTH_P76: u32 = 94; -pub const XC_GGA_XC_HCTH_P14: u32 = 95; -pub const XC_GGA_XC_B97_GGA1: u32 = 96; -pub const XC_GGA_C_HCTH_A: u32 = 97; -pub const XC_GGA_X_BPCCAC: u32 = 98; -pub const XC_GGA_C_REVTCA: u32 = 99; -pub const XC_GGA_C_TCA: u32 = 100; -pub const XC_GGA_X_PBE: u32 = 101; -pub const XC_GGA_X_PBE_R: u32 = 102; -pub const XC_GGA_X_B86: u32 = 103; -pub const XC_GGA_X_HERMAN: u32 = 104; -pub const XC_GGA_X_B86_MGC: u32 = 105; -pub const XC_GGA_X_B88: u32 = 106; -pub const XC_GGA_X_G96: u32 = 107; -pub const XC_GGA_X_PW86: u32 = 108; -pub const XC_GGA_X_PW91: u32 = 109; -pub const XC_GGA_X_OPTX: u32 = 110; -pub const XC_GGA_X_DK87_R1: u32 = 111; -pub const XC_GGA_X_DK87_R2: u32 = 112; -pub const XC_GGA_X_LG93: u32 = 113; -pub const XC_GGA_X_FT97_A: u32 = 114; -pub const XC_GGA_X_FT97_B: u32 = 115; -pub const XC_GGA_X_PBE_SOL: u32 = 116; -pub const XC_GGA_X_RPBE: u32 = 117; -pub const XC_GGA_X_WC: u32 = 118; -pub const XC_GGA_X_MPW91: u32 = 119; -pub const XC_GGA_X_AM05: u32 = 120; -pub const XC_GGA_X_PBEA: u32 = 121; -pub const XC_GGA_X_MPBE: u32 = 122; -pub const XC_GGA_X_XPBE: u32 = 123; -pub const XC_GGA_X_2D_B86_MGC: u32 = 124; -pub const XC_GGA_X_BAYESIAN: u32 = 125; -pub const XC_GGA_X_PBE_JSJR: u32 = 126; -pub const XC_GGA_X_2D_B88: u32 = 127; -pub const XC_GGA_X_2D_B86: u32 = 128; -pub const XC_GGA_X_2D_PBE: u32 = 129; -pub const XC_GGA_C_PBE: u32 = 130; -pub const XC_GGA_C_LYP: u32 = 131; -pub const XC_GGA_C_P86: u32 = 132; -pub const XC_GGA_C_PBE_SOL: u32 = 133; -pub const XC_GGA_C_PW91: u32 = 134; -pub const XC_GGA_C_AM05: u32 = 135; -pub const XC_GGA_C_XPBE: u32 = 136; -pub const XC_GGA_C_LM: u32 = 137; -pub const XC_GGA_C_PBE_JRGX: u32 = 138; -pub const XC_GGA_X_OPTB88_VDW: u32 = 139; -pub const XC_GGA_X_PBEK1_VDW: u32 = 140; -pub const XC_GGA_X_OPTPBE_VDW: u32 = 141; -pub const XC_GGA_X_RGE2: u32 = 142; -pub const XC_GGA_C_RGE2: u32 = 143; -pub const XC_GGA_X_RPW86: u32 = 144; -pub const XC_GGA_X_KT1: u32 = 145; -pub const XC_GGA_XC_KT2: u32 = 146; -pub const XC_GGA_C_WL: u32 = 147; -pub const XC_GGA_C_WI: u32 = 148; -pub const XC_GGA_X_MB88: u32 = 149; -pub const XC_GGA_X_SOGGA: u32 = 150; -pub const XC_GGA_X_SOGGA11: u32 = 151; -pub const XC_GGA_C_SOGGA11: u32 = 152; -pub const XC_GGA_C_WI0: u32 = 153; -pub const XC_GGA_XC_TH1: u32 = 154; -pub const XC_GGA_XC_TH2: u32 = 155; -pub const XC_GGA_XC_TH3: u32 = 156; -pub const XC_GGA_XC_TH4: u32 = 157; -pub const XC_GGA_X_C09X: u32 = 158; -pub const XC_GGA_C_SOGGA11_X: u32 = 159; -pub const XC_GGA_X_LB: u32 = 160; -pub const XC_GGA_XC_HCTH_93: u32 = 161; -pub const XC_GGA_XC_HCTH_120: u32 = 162; -pub const XC_GGA_XC_HCTH_147: u32 = 163; -pub const XC_GGA_XC_HCTH_407: u32 = 164; -pub const XC_GGA_XC_EDF1: u32 = 165; -pub const XC_GGA_XC_XLYP: u32 = 166; -pub const XC_GGA_XC_KT1: u32 = 167; -pub const XC_GGA_X_LSPBE: u32 = 168; -pub const XC_GGA_X_LSRPBE: u32 = 169; -pub const XC_GGA_XC_B97_D: u32 = 170; -pub const XC_GGA_X_OPTB86B_VDW: u32 = 171; -pub const XC_GGA_XC_PBE1W: u32 = 173; -pub const XC_GGA_XC_MPWLYP1W: u32 = 174; -pub const XC_GGA_XC_PBELYP1W: u32 = 175; -pub const XC_GGA_C_ACGGAP: u32 = 176; -pub const XC_GGA_X_B88_6311G: u32 = 179; -pub const XC_GGA_X_NCAP: u32 = 180; -pub const XC_GGA_XC_NCAP: u32 = 181; -pub const XC_GGA_X_LBM: u32 = 182; -pub const XC_GGA_X_OL2: u32 = 183; -pub const XC_GGA_X_APBE: u32 = 184; -pub const XC_GGA_K_APBE: u32 = 185; -pub const XC_GGA_C_APBE: u32 = 186; -pub const XC_GGA_K_TW1: u32 = 187; -pub const XC_GGA_K_TW2: u32 = 188; -pub const XC_GGA_K_TW3: u32 = 189; -pub const XC_GGA_K_TW4: u32 = 190; -pub const XC_GGA_X_HTBS: u32 = 191; -pub const XC_GGA_X_AIRY: u32 = 192; -pub const XC_GGA_X_LAG: u32 = 193; -pub const XC_GGA_XC_MOHLYP: u32 = 194; -pub const XC_GGA_XC_MOHLYP2: u32 = 195; -pub const XC_GGA_XC_TH_FL: u32 = 196; -pub const XC_GGA_XC_TH_FC: u32 = 197; -pub const XC_GGA_XC_TH_FCFO: u32 = 198; -pub const XC_GGA_XC_TH_FCO: u32 = 199; -pub const XC_GGA_C_OPTC: u32 = 200; -pub const XC_GGA_X_ECMV92: u32 = 215; -pub const XC_GGA_C_PBE_VWN: u32 = 216; -pub const XC_GGA_C_P86_FT: u32 = 217; -pub const XC_GGA_K_RATIONAL_P: u32 = 218; -pub const XC_GGA_K_PG1: u32 = 219; -pub const XC_GGA_C_PBELOC: u32 = 246; -pub const XC_GGA_C_P86VWN: u32 = 252; -pub const XC_GGA_C_P86VWN_FT: u32 = 253; -pub const XC_GGA_XC_VV10: u32 = 255; -pub const XC_GGA_C_PBEFE: u32 = 258; -pub const XC_GGA_C_OP_PW91: u32 = 262; -pub const XC_GGA_X_PBEFE: u32 = 265; -pub const XC_GGA_X_CAP: u32 = 270; -pub const XC_GGA_X_EB88: u32 = 271; -pub const XC_GGA_C_PBE_MOL: u32 = 272; -pub const XC_GGA_K_ABSP3: u32 = 277; -pub const XC_GGA_K_ABSP4: u32 = 278; -pub const XC_GGA_C_BMK: u32 = 280; -pub const XC_GGA_C_TAU_HCTH: u32 = 281; -pub const XC_GGA_C_HYB_TAU_HCTH: u32 = 283; -pub const XC_GGA_X_BEEFVDW: u32 = 285; -pub const XC_GGA_XC_BEEFVDW: u32 = 286; -pub const XC_GGA_X_PBETRANS: u32 = 291; -pub const XC_GGA_X_CHACHIYO: u32 = 298; -pub const XC_GGA_C_CHACHIYO: u32 = 309; -pub const XC_GGA_X_REVSSB_D: u32 = 312; -pub const XC_GGA_C_CCDF: u32 = 313; -pub const XC_GGA_X_PW91_MOD: u32 = 316; -pub const XC_GGA_X_S12G: u32 = 495; -pub const XC_GGA_K_VW: u32 = 500; -pub const XC_GGA_K_GE2: u32 = 501; -pub const XC_GGA_K_GOLDEN: u32 = 502; -pub const XC_GGA_K_YT65: u32 = 503; -pub const XC_GGA_K_BALTIN: u32 = 504; -pub const XC_GGA_K_LIEB: u32 = 505; -pub const XC_GGA_K_ABSP1: u32 = 506; -pub const XC_GGA_K_ABSP2: u32 = 507; -pub const XC_GGA_K_GR: u32 = 508; -pub const XC_GGA_K_LUDENA: u32 = 509; -pub const XC_GGA_K_GP85: u32 = 510; -pub const XC_GGA_K_PEARSON: u32 = 511; -pub const XC_GGA_K_OL1: u32 = 512; -pub const XC_GGA_K_OL2: u32 = 513; -pub const XC_GGA_K_FR_B88: u32 = 514; -pub const XC_GGA_K_FR_PW86: u32 = 515; -pub const XC_GGA_K_DK: u32 = 516; -pub const XC_GGA_K_PERDEW: u32 = 517; -pub const XC_GGA_K_VSK: u32 = 518; -pub const XC_GGA_K_VJKS: u32 = 519; -pub const XC_GGA_K_ERNZERHOF: u32 = 520; -pub const XC_GGA_K_LC94: u32 = 521; -pub const XC_GGA_K_LLP: u32 = 522; -pub const XC_GGA_K_THAKKAR: u32 = 523; -pub const XC_GGA_X_WPBEH: u32 = 524; -pub const XC_GGA_X_HJS_PBE: u32 = 525; -pub const XC_GGA_X_HJS_PBE_SOL: u32 = 526; -pub const XC_GGA_X_HJS_B88: u32 = 527; -pub const XC_GGA_X_HJS_B97X: u32 = 528; -pub const XC_GGA_X_ITYH: u32 = 529; -pub const XC_GGA_X_SFAT: u32 = 530; -pub const XC_GGA_X_SG4: u32 = 533; -pub const XC_GGA_C_SG4: u32 = 534; -pub const XC_GGA_X_GG99: u32 = 535; -pub const XC_GGA_X_PBEPOW: u32 = 539; -pub const XC_GGA_X_KGG99: u32 = 544; -pub const XC_GGA_XC_HLE16: u32 = 545; -pub const XC_GGA_C_SCAN_E0: u32 = 553; -pub const XC_GGA_C_GAPC: u32 = 555; -pub const XC_GGA_C_GAPLOC: u32 = 556; -pub const XC_GGA_C_ZVPBEINT: u32 = 557; -pub const XC_GGA_C_ZVPBESOL: u32 = 558; -pub const XC_GGA_C_TM_LYP: u32 = 559; -pub const XC_GGA_C_TM_PBE: u32 = 560; -pub const XC_GGA_C_W94: u32 = 561; -pub const XC_GGA_C_CS1: u32 = 565; -pub const XC_GGA_X_B88M: u32 = 570; -pub const XC_GGA_XC_KT3: u32 = 587; -pub const XC_GGA_K_GDS08: u32 = 591; -pub const XC_GGA_K_GHDS10: u32 = 592; -pub const XC_GGA_K_GHDS10R: u32 = 593; -pub const XC_GGA_K_TKVLN: u32 = 594; -pub const XC_GGA_K_PBE3: u32 = 595; -pub const XC_GGA_K_PBE4: u32 = 596; -pub const XC_GGA_K_EXP4: u32 = 597; -pub const XC_GGA_X_SFAT_PBE: u32 = 601; -pub const XC_GGA_X_FD_LB94: u32 = 604; -pub const XC_GGA_X_FD_REVLB94: u32 = 605; -pub const XC_GGA_C_ZVPBELOC: u32 = 606; -pub const XC_GGA_K_LKT: u32 = 613; -pub const XC_GGA_K_PBE2: u32 = 616; -pub const XC_GGA_K_VT84F: u32 = 619; -pub const XC_GGA_K_LGAP: u32 = 620; -pub const XC_GGA_X_ITYH_OPTX: u32 = 622; -pub const XC_GGA_X_ITYH_PBE: u32 = 623; -pub const XC_GGA_C_LYPR: u32 = 624; -pub const XC_GGA_K_LGAP_GE: u32 = 633; -pub const XC_GGA_K_TFVW_OPT: u32 = 635; -pub const XC_GGA_C_MGGAC: u32 = 712; -pub const XC_GGA_X_Q1D: u32 = 734; -pub const XC_HYB_MGGA_X_DLDF: u32 = 36; -pub const XC_HYB_MGGA_X_MS2H: u32 = 224; -pub const XC_HYB_MGGA_X_MN12_SX: u32 = 248; -pub const XC_HYB_MGGA_X_SCAN0: u32 = 264; -pub const XC_HYB_MGGA_X_MN15: u32 = 268; -pub const XC_HYB_MGGA_X_BMK: u32 = 279; -pub const XC_HYB_MGGA_X_TAU_HCTH: u32 = 282; -pub const XC_HYB_MGGA_X_M08_HX: u32 = 295; -pub const XC_HYB_MGGA_X_M08_SO: u32 = 296; -pub const XC_HYB_MGGA_X_M11: u32 = 297; -pub const XC_HYB_MGGA_X_REVM11: u32 = 304; -pub const XC_HYB_MGGA_X_REVM06: u32 = 305; -pub const XC_HYB_MGGA_X_M06_SX: u32 = 310; -pub const XC_HYB_MGGA_XC_TPSS0: u32 = 396; -pub const XC_HYB_MGGA_XC_B94_HYB: u32 = 398; -pub const XC_HYB_MGGA_X_M05: u32 = 438; -pub const XC_HYB_MGGA_X_M05_2X: u32 = 439; -pub const XC_HYB_MGGA_XC_B88B95: u32 = 440; -pub const XC_HYB_MGGA_XC_B86B95: u32 = 441; -pub const XC_HYB_MGGA_XC_PW86B95: u32 = 442; -pub const XC_HYB_MGGA_XC_BB1K: u32 = 443; -pub const XC_HYB_MGGA_X_M06_HF: u32 = 444; -pub const XC_HYB_MGGA_XC_MPW1B95: u32 = 445; -pub const XC_HYB_MGGA_XC_MPWB1K: u32 = 446; -pub const XC_HYB_MGGA_XC_X1B95: u32 = 447; -pub const XC_HYB_MGGA_XC_XB1K: u32 = 448; -pub const XC_HYB_MGGA_X_M06: u32 = 449; -pub const XC_HYB_MGGA_X_M06_2X: u32 = 450; -pub const XC_HYB_MGGA_XC_PW6B95: u32 = 451; -pub const XC_HYB_MGGA_XC_PWB6K: u32 = 452; -pub const XC_HYB_MGGA_XC_TPSSH: u32 = 457; -pub const XC_HYB_MGGA_XC_REVTPSSH: u32 = 458; -pub const XC_HYB_MGGA_X_MVSH: u32 = 474; -pub const XC_HYB_MGGA_XC_WB97M_V: u32 = 531; -pub const XC_HYB_MGGA_XC_B0KCIS: u32 = 563; -pub const XC_HYB_MGGA_XC_MPW1KCIS: u32 = 566; -pub const XC_HYB_MGGA_XC_MPWKCIS1K: u32 = 567; -pub const XC_HYB_MGGA_XC_PBE1KCIS: u32 = 568; -pub const XC_HYB_MGGA_XC_TPSS1KCIS: u32 = 569; -pub const XC_HYB_MGGA_X_REVSCAN0: u32 = 583; -pub const XC_HYB_MGGA_XC_B98: u32 = 598; -pub const XC_HYB_MGGA_XC_EDMGGAH: u32 = 695; -pub const XC_HYB_MGGA_X_JS18: u32 = 705; -pub const XC_HYB_MGGA_X_PJS18: u32 = 706; -pub const XC_HYB_MGGA_XC_LC_TMLYP: u32 = 720; -pub const XC_MGGA_C_DLDF: u32 = 37; -pub const XC_MGGA_XC_ZLP: u32 = 42; -pub const XC_MGGA_XC_OTPSS_D: u32 = 64; -pub const XC_MGGA_C_CS: u32 = 72; -pub const XC_MGGA_C_MN12_SX: u32 = 73; -pub const XC_MGGA_C_MN12_L: u32 = 74; -pub const XC_MGGA_C_M11_L: u32 = 75; -pub const XC_MGGA_C_M11: u32 = 76; -pub const XC_MGGA_C_M08_SO: u32 = 77; -pub const XC_MGGA_C_M08_HX: u32 = 78; -pub const XC_MGGA_C_REVM11: u32 = 172; -pub const XC_MGGA_X_LTA: u32 = 201; -pub const XC_MGGA_X_TPSS: u32 = 202; -pub const XC_MGGA_X_M06_L: u32 = 203; -pub const XC_MGGA_X_GVT4: u32 = 204; -pub const XC_MGGA_X_TAU_HCTH: u32 = 205; -pub const XC_MGGA_X_BR89: u32 = 206; -pub const XC_MGGA_X_BJ06: u32 = 207; -pub const XC_MGGA_X_TB09: u32 = 208; -pub const XC_MGGA_X_RPP09: u32 = 209; -pub const XC_MGGA_X_2D_PRHG07: u32 = 210; -pub const XC_MGGA_X_2D_PRHG07_PRP10: u32 = 211; -pub const XC_MGGA_X_REVTPSS: u32 = 212; -pub const XC_MGGA_X_PKZB: u32 = 213; -pub const XC_MGGA_X_BR89_1: u32 = 214; -pub const XC_MGGA_K_PGSL025: u32 = 220; -pub const XC_MGGA_X_MS0: u32 = 221; -pub const XC_MGGA_X_MS1: u32 = 222; -pub const XC_MGGA_X_MS2: u32 = 223; -pub const XC_MGGA_X_TH: u32 = 225; -pub const XC_MGGA_X_M11_L: u32 = 226; -pub const XC_MGGA_X_MN12_L: u32 = 227; -pub const XC_MGGA_X_MS2_REV: u32 = 228; -pub const XC_MGGA_XC_CC06: u32 = 229; -pub const XC_MGGA_X_MK00: u32 = 230; -pub const XC_MGGA_C_TPSS: u32 = 231; -pub const XC_MGGA_C_VSXC: u32 = 232; -pub const XC_MGGA_C_M06_L: u32 = 233; -pub const XC_MGGA_C_M06_HF: u32 = 234; -pub const XC_MGGA_C_M06: u32 = 235; -pub const XC_MGGA_C_M06_2X: u32 = 236; -pub const XC_MGGA_C_M05: u32 = 237; -pub const XC_MGGA_C_M05_2X: u32 = 238; -pub const XC_MGGA_C_PKZB: u32 = 239; -pub const XC_MGGA_C_BC95: u32 = 240; -pub const XC_MGGA_C_REVTPSS: u32 = 241; -pub const XC_MGGA_XC_TPSSLYP1W: u32 = 242; -pub const XC_MGGA_X_MK00B: u32 = 243; -pub const XC_MGGA_X_BLOC: u32 = 244; -pub const XC_MGGA_X_MODTPSS: u32 = 245; -pub const XC_MGGA_C_TPSSLOC: u32 = 247; -pub const XC_MGGA_X_MBEEF: u32 = 249; -pub const XC_MGGA_X_MBEEFVDW: u32 = 250; -pub const XC_MGGA_C_TM: u32 = 251; -pub const XC_MGGA_XC_B97M_V: u32 = 254; -pub const XC_MGGA_X_JK: u32 = 256; -pub const XC_MGGA_X_MVS: u32 = 257; -pub const XC_MGGA_X_MN15_L: u32 = 260; -pub const XC_MGGA_C_MN15_L: u32 = 261; -pub const XC_MGGA_X_SCAN: u32 = 263; -pub const XC_MGGA_C_SCAN: u32 = 267; -pub const XC_MGGA_C_MN15: u32 = 269; -pub const XC_MGGA_X_B00: u32 = 284; -pub const XC_MGGA_XC_HLE17: u32 = 288; -pub const XC_MGGA_C_SCAN_RVV10: u32 = 292; -pub const XC_MGGA_X_REVM06_L: u32 = 293; -pub const XC_MGGA_C_REVM06_L: u32 = 294; -pub const XC_MGGA_X_RTPSS: u32 = 299; -pub const XC_MGGA_X_MS2B: u32 = 300; -pub const XC_MGGA_X_MS2BS: u32 = 301; -pub const XC_MGGA_X_MVSB: u32 = 302; -pub const XC_MGGA_X_MVSBS: u32 = 303; -pub const XC_MGGA_C_REVM06: u32 = 306; -pub const XC_MGGA_C_M06_SX: u32 = 311; -pub const XC_MGGA_X_FT98: u32 = 319; -pub const XC_MGGA_C_RREGTM: u32 = 391; -pub const XC_MGGA_C_B94: u32 = 397; -pub const XC_MGGA_X_RSCAN: u32 = 493; -pub const XC_MGGA_C_RSCAN: u32 = 494; -pub const XC_MGGA_X_R2SCAN: u32 = 497; -pub const XC_MGGA_C_R2SCAN: u32 = 498; -pub const XC_MGGA_X_TM: u32 = 540; -pub const XC_MGGA_X_VT84: u32 = 541; -pub const XC_MGGA_X_SA_TPSS: u32 = 542; -pub const XC_MGGA_K_PC07: u32 = 543; -pub const XC_MGGA_C_KCIS: u32 = 562; -pub const XC_MGGA_XC_LP90: u32 = 564; -pub const XC_MGGA_C_B88: u32 = 571; -pub const XC_MGGA_X_GX: u32 = 575; -pub const XC_MGGA_X_PBE_GX: u32 = 576; -pub const XC_MGGA_X_REVSCAN: u32 = 581; -pub const XC_MGGA_C_REVSCAN: u32 = 582; -pub const XC_MGGA_C_SCAN_VV10: u32 = 584; -pub const XC_MGGA_C_REVSCAN_VV10: u32 = 585; -pub const XC_MGGA_X_BR89_EXPLICIT: u32 = 586; -pub const XC_MGGA_X_BR89_EXPLICIT_1: u32 = 602; -pub const XC_MGGA_X_REGTPSS: u32 = 603; -pub const XC_MGGA_X_2D_JS17: u32 = 609; -pub const XC_MGGA_K_L04: u32 = 617; -pub const XC_MGGA_K_L06: u32 = 618; -pub const XC_MGGA_K_RDA: u32 = 621; -pub const XC_MGGA_X_REGTM: u32 = 626; -pub const XC_MGGA_K_GEA2: u32 = 627; -pub const XC_MGGA_K_GEA4: u32 = 628; -pub const XC_MGGA_K_CSK1: u32 = 629; -pub const XC_MGGA_K_CSK4: u32 = 630; -pub const XC_MGGA_K_CSK_LOC1: u32 = 631; -pub const XC_MGGA_K_CSK_LOC4: u32 = 632; -pub const XC_MGGA_K_PC07_OPT: u32 = 634; -pub const XC_MGGA_C_KCISK: u32 = 638; -pub const XC_MGGA_C_R2SCAN01: u32 = 642; -pub const XC_MGGA_C_RMGGAC: u32 = 643; -pub const XC_MGGA_X_MCML: u32 = 644; -pub const XC_MGGA_X_R2SCAN01: u32 = 645; -pub const XC_MGGA_X_RPPSCAN: u32 = 648; -pub const XC_MGGA_C_RPPSCAN: u32 = 649; -pub const XC_MGGA_X_R4SCAN: u32 = 650; -pub const XC_MGGA_X_TLDA: u32 = 685; -pub const XC_MGGA_X_EDMGGA: u32 = 686; -pub const XC_MGGA_X_GDME_NV: u32 = 687; -pub const XC_MGGA_X_RLDA: u32 = 688; -pub const XC_MGGA_X_GDME_0: u32 = 689; -pub const XC_MGGA_X_GDME_KOS: u32 = 690; -pub const XC_MGGA_X_GDME_VT: u32 = 691; -pub const XC_MGGA_X_REVTM: u32 = 693; -pub const XC_MGGA_C_REVTM: u32 = 694; -pub const XC_MGGA_X_MBRXC_BG: u32 = 696; -pub const XC_MGGA_X_MBRXH_BG: u32 = 697; -pub const XC_MGGA_X_HLTA: u32 = 698; -pub const XC_MGGA_C_HLTAPW: u32 = 699; -pub const XC_MGGA_X_SCANL: u32 = 700; -pub const XC_MGGA_X_REVSCANL: u32 = 701; -pub const XC_MGGA_C_SCANL: u32 = 702; -pub const XC_MGGA_C_SCANL_RVV10: u32 = 703; -pub const XC_MGGA_C_SCANL_VV10: u32 = 704; -pub const XC_MGGA_X_TASK: u32 = 707; -pub const XC_MGGA_X_MGGAC: u32 = 711; -pub const XC_MGGA_X_MBR: u32 = 716; -pub const XC_MGGA_X_R2SCANL: u32 = 718; -pub const XC_MGGA_C_R2SCANL: u32 = 719; -pub const XC_MGGA_X_MTASK: u32 = 724; -pub const XC_LDA_X_1D: u32 = 21; -pub const XC_GGA_X_BGCP: u32 = 38; -pub const XC_GGA_C_BGCP: u32 = 39; -pub const XC_GGA_C_BCGP: u32 = 39; -pub const XC_GGA_C_VPBE: u32 = 83; -pub const XC_GGA_XC_LB: u32 = 160; -pub const XC_MGGA_C_CC06: u32 = 229; -pub const XC_GGA_K_ABSR1: u32 = 506; -pub const XC_GGA_K_ABSR2: u32 = 507; -pub const XC_LDA_C_LP_A: u32 = 547; -pub const XC_LDA_C_LP_B: u32 = 548; -pub const XC_MGGA_C_LP90: u32 = 564; -#[allow(non_upper_case_globals)] -pub const XC_LDA_C_vBH: u32 = 17; -#[allow(non_upper_case_globals)] -pub const XC_HYB_GGA_XC_B97_1p: u32 = 266; -#[allow(non_upper_case_globals)] -pub const XC_HYB_GGA_XC_mPW1K: u32 = 405; -#[allow(non_upper_case_globals)] -pub const XC_HYB_GGA_XC_mPW1PW: u32 = 418; -#[allow(non_upper_case_globals)] -pub const XC_HYB_GGA_XC_SB98_1a: u32 = 420; -#[allow(non_upper_case_globals)] -pub const XC_HYB_GGA_XC_SB98_1b: u32 = 421; -#[allow(non_upper_case_globals)] -pub const XC_HYB_GGA_XC_SB98_1c: u32 = 422; -#[allow(non_upper_case_globals)] -pub const XC_HYB_GGA_XC_SB98_2a: u32 = 423; -#[allow(non_upper_case_globals)] -pub const XC_HYB_GGA_XC_SB98_2b: u32 = 424; -#[allow(non_upper_case_globals)] -pub const XC_HYB_GGA_XC_SB98_2c: u32 = 425; -#[allow(non_upper_case_globals)] -pub const XC_HYB_GGA_XC_B3LYPs: u32 = 459; -#[allow(non_upper_case_globals)] -pub const XC_GGA_X_PBEpow: u32 = 539; -#[allow(non_upper_case_globals)] -pub const XC_GGA_XC_B97: u32 = 167; -pub const XC_GGA_XC_B97_1: u32 = 168; -pub const XC_GGA_XC_B97_2: u32 = 169; -pub const XC_GGA_XC_B97_K: u32 = 171; -pub const XC_GGA_XC_B97_3: u32 = 172; -#[allow(non_upper_case_globals)] -pub const XC_GGA_XC_SB98_1a: u32 = 176; -#[allow(non_upper_case_globals)] -pub const XC_GGA_XC_SB98_1b: u32 = 177; -#[allow(non_upper_case_globals)] -pub const XC_GGA_XC_SB98_1c: u32 = 178; -#[allow(non_upper_case_globals)] -pub const XC_GGA_XC_SB98_2a: u32 = 179; -#[allow(non_upper_case_globals)] -pub const XC_GGA_XC_SB98_2b: u32 = 180; -#[allow(non_upper_case_globals)] -pub const XC_GGA_XC_SB98_2c: u32 = 181; -#[allow(non_upper_case_globals)] -pub const XC_MGGA_X_M05: u32 = 214; -pub const XC_MGGA_X_M05_2X: u32 = 215; -pub const XC_MGGA_X_M06_HF: u32 = 216; -pub const XC_MGGA_X_M06: u32 = 217; -pub const XC_MGGA_X_M06_2X: u32 = 218; -pub const XC_MGGA_X_M08_HX: u32 = 219; -pub const XC_MGGA_X_M08_SO: u32 = 220; -pub const XC_MGGA_X_M11: u32 = 225; -pub const XC_MGGA_X_MN12_SX: u32 = 228; -pub const XC_GGA_XC_WB97: u32 = 251; -pub const XC_GGA_XC_WB97X: u32 = 252; -pub const XC_GGA_XC_WB97X_V: u32 = 253; -pub const XC_GGA_XC_WB97X_D: u32 = 256; -pub const XC_HYB_MGGA_XC_M08_HX: u32 = 460; -pub const XC_HYB_MGGA_XC_M08_SO: u32 = 461; -pub const XC_HYB_MGGA_XC_M11: u32 = 462; -extern "C" { - pub fn xc_reference() -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_reference_doi() -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_version_string() -> *const ::std::os::raw::c_char; -} -#[allow(non_camel_case_types)] -pub type size_t = ::std::os::raw::c_ulong; -#[allow(non_camel_case_types)] -pub type wchar_t = ::std::os::raw::c_int; -#[repr(C)] -#[repr(align(16))] -#[derive(Debug, Copy, Clone)] -#[allow(non_camel_case_types)] -pub struct max_align_t { - pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, - pub __bindgen_padding_0: u64, - pub __clang_max_align_nonce2: u128, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -#[allow(non_camel_case_types)] -pub struct func_reference_type { - pub ref_: *const ::std::os::raw::c_char, - pub doi: *const ::std::os::raw::c_char, - pub bibtex: *const ::std::os::raw::c_char, -} -#[link(name="xc")] -extern "C" { - pub fn xc_func_reference_get_ref( - reference: *const func_reference_type, - ) -> *const ::std::os::raw::c_char; - pub fn xc_func_reference_get_doi( - reference: *const func_reference_type, - ) -> *const ::std::os::raw::c_char; - pub fn xc_func_reference_get_bibtex( - reference: *const func_reference_type, - ) -> *const ::std::os::raw::c_char; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct func_params_type { - pub n: ::std::os::raw::c_int, - pub names: *mut *const ::std::os::raw::c_char, - pub descriptions: *mut *const ::std::os::raw::c_char, - pub values: *const f64, - pub set: - ::std::option::Option, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct xc_func_info_type { - pub number: ::std::os::raw::c_int, - pub kind: ::std::os::raw::c_int, - pub name: *const ::std::os::raw::c_char, - pub family: ::std::os::raw::c_int, - pub refs: [*mut func_reference_type; 5usize], - pub flags: ::std::os::raw::c_int, - pub dens_threshold: f64, - pub ext_params: func_params_type, - pub init: ::std::option::Option, - pub end: ::std::option::Option, - pub lda: ::std::option::Option< - unsafe extern "C" fn( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - zk: *mut f64, - vrho: *mut f64, - v2rho2: *mut f64, - v3rho3: *mut f64, - v4rho4: *mut f64, - ), - >, - pub gga: ::std::option::Option< - unsafe extern "C" fn( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rhosigma2: *mut f64, - v3sigma3: *mut f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho2sigma2: *mut f64, - v4rhosigma3: *mut f64, - v4sigma4: *mut f64, - ), - >, - pub mgga: ::std::option::Option< - unsafe extern "C" fn( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl_rho: *const f64, - tau: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rho2lapl: *mut f64, - v3rho2tau: *mut f64, - v3rhosigma2: *mut f64, - v3rhosigmalapl: *mut f64, - v3rhosigmatau: *mut f64, - v3rholapl2: *mut f64, - v3rholapltau: *mut f64, - v3rhotau2: *mut f64, - v3sigma3: *mut f64, - v3sigma2lapl: *mut f64, - v3sigma2tau: *mut f64, - v3sigmalapl2: *mut f64, - v3sigmalapltau: *mut f64, - v3sigmatau2: *mut f64, - v3lapl3: *mut f64, - v3lapl2tau: *mut f64, - v3lapltau2: *mut f64, - v3tau3: *mut f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho3lapl: *mut f64, - v4rho3tau: *mut f64, - v4rho2sigma2: *mut f64, - v4rho2sigmalapl: *mut f64, - v4rho2sigmatau: *mut f64, - v4rho2lapl2: *mut f64, - v4rho2lapltau: *mut f64, - v4rho2tau2: *mut f64, - v4rhosigma3: *mut f64, - v4rhosigma2lapl: *mut f64, - v4rhosigma2tau: *mut f64, - v4rhosigmalapl2: *mut f64, - v4rhosigmalapltau: *mut f64, - v4rhosigmatau2: *mut f64, - v4rholapl3: *mut f64, - v4rholapl2tau: *mut f64, - v4rholapltau2: *mut f64, - v4rhotau3: *mut f64, - v4sigma4: *mut f64, - v4sigma3lapl: *mut f64, - v4sigma3tau: *mut f64, - v4sigma2lapl2: *mut f64, - v4sigma2lapltau: *mut f64, - v4sigma2tau2: *mut f64, - v4sigmalapl3: *mut f64, - v4sigmalapl2tau: *mut f64, - v4sigmalapltau2: *mut f64, - v4sigmatau3: *mut f64, - v4lapl4: *mut f64, - v4lapl3tau: *mut f64, - v4lapl2tau2: *mut f64, - v4lapltau3: *mut f64, - v4tau4: *mut f64, - ), - >, -} - -//#[link(name="xc",kind="static")] -extern "C" { - pub fn xc_func_info_get_number(info: *const xc_func_info_type) -> ::std::os::raw::c_int; - pub fn xc_func_info_get_kind(info: *const xc_func_info_type) -> ::std::os::raw::c_int; - pub fn xc_func_info_get_name(info: *const xc_func_info_type) -> *const ::std::os::raw::c_char; - pub fn xc_func_info_get_family(info: *const xc_func_info_type) -> ::std::os::raw::c_int; - pub fn xc_func_info_get_flags(info: *const xc_func_info_type) -> ::std::os::raw::c_int; - pub fn xc_func_info_get_references( - info: *const xc_func_info_type, - number: ::std::os::raw::c_int, - ) -> *const func_reference_type; - pub fn xc_func_info_get_n_ext_params(info: *const xc_func_info_type) -> ::std::os::raw::c_int; - pub fn xc_func_info_get_ext_params_name( - p: *const xc_func_info_type, - number: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_func_info_get_ext_params_description( - info: *const xc_func_info_type, - number: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_func_info_get_ext_params_default_value( - info: *const xc_func_info_type, - number: ::std::os::raw::c_int, - ) -> f64; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct xc_dimensions { - pub rho: ::std::os::raw::c_int, - pub sigma: ::std::os::raw::c_int, - pub lapl: ::std::os::raw::c_int, - pub tau: ::std::os::raw::c_int, - pub zk: ::std::os::raw::c_int, - pub vrho: ::std::os::raw::c_int, - pub vsigma: ::std::os::raw::c_int, - pub vlapl: ::std::os::raw::c_int, - pub vtau: ::std::os::raw::c_int, - pub v2rho2: ::std::os::raw::c_int, - pub v2rhosigma: ::std::os::raw::c_int, - pub v2rholapl: ::std::os::raw::c_int, - pub v2rhotau: ::std::os::raw::c_int, - pub v2sigma2: ::std::os::raw::c_int, - pub v2sigmalapl: ::std::os::raw::c_int, - pub v2sigmatau: ::std::os::raw::c_int, - pub v2lapl2: ::std::os::raw::c_int, - pub v2lapltau: ::std::os::raw::c_int, - pub v2tau2: ::std::os::raw::c_int, - pub v3rho3: ::std::os::raw::c_int, - pub v3rho2sigma: ::std::os::raw::c_int, - pub v3rho2lapl: ::std::os::raw::c_int, - pub v3rho2tau: ::std::os::raw::c_int, - pub v3rhosigma2: ::std::os::raw::c_int, - pub v3rhosigmalapl: ::std::os::raw::c_int, - pub v3rhosigmatau: ::std::os::raw::c_int, - pub v3rholapl2: ::std::os::raw::c_int, - pub v3rholapltau: ::std::os::raw::c_int, - pub v3rhotau2: ::std::os::raw::c_int, - pub v3sigma3: ::std::os::raw::c_int, - pub v3sigma2lapl: ::std::os::raw::c_int, - pub v3sigma2tau: ::std::os::raw::c_int, - pub v3sigmalapl2: ::std::os::raw::c_int, - pub v3sigmalapltau: ::std::os::raw::c_int, - pub v3sigmatau2: ::std::os::raw::c_int, - pub v3lapl3: ::std::os::raw::c_int, - pub v3lapl2tau: ::std::os::raw::c_int, - pub v3lapltau2: ::std::os::raw::c_int, - pub v3tau3: ::std::os::raw::c_int, - pub v4rho4: ::std::os::raw::c_int, - pub v4rho3sigma: ::std::os::raw::c_int, - pub v4rho3lapl: ::std::os::raw::c_int, - pub v4rho3tau: ::std::os::raw::c_int, - pub v4rho2sigma2: ::std::os::raw::c_int, - pub v4rho2sigmalapl: ::std::os::raw::c_int, - pub v4rho2sigmatau: ::std::os::raw::c_int, - pub v4rho2lapl2: ::std::os::raw::c_int, - pub v4rho2lapltau: ::std::os::raw::c_int, - pub v4rho2tau2: ::std::os::raw::c_int, - pub v4rhosigma3: ::std::os::raw::c_int, - pub v4rhosigma2lapl: ::std::os::raw::c_int, - pub v4rhosigma2tau: ::std::os::raw::c_int, - pub v4rhosigmalapl2: ::std::os::raw::c_int, - pub v4rhosigmalapltau: ::std::os::raw::c_int, - pub v4rhosigmatau2: ::std::os::raw::c_int, - pub v4rholapl3: ::std::os::raw::c_int, - pub v4rholapl2tau: ::std::os::raw::c_int, - pub v4rholapltau2: ::std::os::raw::c_int, - pub v4rhotau3: ::std::os::raw::c_int, - pub v4sigma4: ::std::os::raw::c_int, - pub v4sigma3lapl: ::std::os::raw::c_int, - pub v4sigma3tau: ::std::os::raw::c_int, - pub v4sigma2lapl2: ::std::os::raw::c_int, - pub v4sigma2lapltau: ::std::os::raw::c_int, - pub v4sigma2tau2: ::std::os::raw::c_int, - pub v4sigmalapl3: ::std::os::raw::c_int, - pub v4sigmalapl2tau: ::std::os::raw::c_int, - pub v4sigmalapltau2: ::std::os::raw::c_int, - pub v4sigmatau3: ::std::os::raw::c_int, - pub v4lapl4: ::std::os::raw::c_int, - pub v4lapl3tau: ::std::os::raw::c_int, - pub v4lapl2tau2: ::std::os::raw::c_int, - pub v4lapltau3: ::std::os::raw::c_int, - pub v4tau4: ::std::os::raw::c_int, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -#[allow(non_snake_case)] -pub struct xc_func_type { - pub info: *const xc_func_info_type, - pub nspin: ::std::os::raw::c_int, - pub n_func_aux: ::std::os::raw::c_int, - pub func_aux: *mut *mut xc_func_type, - pub mix_coef: *mut f64, - #[doc = "Parameters for range-separated hybrids"] - #[doc = "cam_omega: the range separation constant"] - #[doc = "cam_alpha: fraction of full Hartree-Fock exchange, used both for"] - #[doc = "usual hybrids as well as range-separated ones"] - #[doc = "cam_beta: fraction of short-range only(!) exchange in"] - #[doc = "range-separated hybrids"] - #[doc = ""] - #[doc = "N.B. Different conventions for alpha and beta can be found in"] - #[doc = "literature. In the convention used in libxc, at short range the"] - #[doc = "fraction of exact exchange is cam_alpha+cam_beta, while at long"] - #[doc = "range it is cam_alpha."] - pub cam_omega: f64, - #[doc = "Parameters for range-separated hybrids"] - #[doc = "cam_omega: the range separation constant"] - #[doc = "cam_alpha: fraction of full Hartree-Fock exchange, used both for"] - #[doc = "usual hybrids as well as range-separated ones"] - #[doc = "cam_beta: fraction of short-range only(!) exchange in"] - #[doc = "range-separated hybrids"] - #[doc = ""] - #[doc = "N.B. Different conventions for alpha and beta can be found in"] - #[doc = "literature. In the convention used in libxc, at short range the"] - #[doc = "fraction of exact exchange is cam_alpha+cam_beta, while at long"] - #[doc = "range it is cam_alpha."] - pub cam_alpha: f64, - #[doc = "Parameters for range-separated hybrids"] - #[doc = "cam_omega: the range separation constant"] - #[doc = "cam_alpha: fraction of full Hartree-Fock exchange, used both for"] - #[doc = "usual hybrids as well as range-separated ones"] - #[doc = "cam_beta: fraction of short-range only(!) exchange in"] - #[doc = "range-separated hybrids"] - #[doc = ""] - #[doc = "N.B. Different conventions for alpha and beta can be found in"] - #[doc = "literature. In the convention used in libxc, at short range the"] - #[doc = "fraction of exact exchange is cam_alpha+cam_beta, while at long"] - #[doc = "range it is cam_alpha."] - pub cam_beta: f64, - pub nlc_b: f64, - pub nlc_C: f64, - pub dim: xc_dimensions, - pub params: *mut ::std::os::raw::c_void, - pub dens_threshold: f64, - pub zeta_threshold: f64, - pub sigma_threshold: f64, - pub tau_threshold: f64, -} -extern "C" { - #[doc = " Get a functional's id number from its name"] - pub fn xc_functional_get_number(name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " Get a functional's name from its id number"] - pub fn xc_functional_get_name(number: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; -} -extern "C" { - #[doc = " Get a functional's family and the number within the family from the id number"] - pub fn xc_family_from_id( - id: ::std::os::raw::c_int, - family: *mut ::std::os::raw::c_int, - number: *mut ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " The number of functionals implemented in this version of libxc"] - pub fn xc_number_of_functionals() -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " The maximum name length of any functional"] - pub fn xc_maximum_name_length() -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " Returns the available functional number sorted by id"] - pub fn xc_available_functional_numbers(list: *mut ::std::os::raw::c_int); -} -extern "C" { - #[doc = " Returns the available functional number sorted by the functionals'"] - #[doc = "names; this function is a helper for the Python frontend."] - pub fn xc_available_functional_numbers_by_name(list: *mut ::std::os::raw::c_int); -} -extern "C" { - #[doc = " Fills the list with the names of the available functionals,"] - #[doc = "ordered by name. The list array should be [Nfuncs][maxlen+1]."] - pub fn xc_available_functional_names(list: *mut *mut ::std::os::raw::c_char); -} - -//#[link(name="xc",kind="static")] -extern "C" { - pub fn xc_version( - major: *mut ::std::os::raw::c_int, - minor: *mut ::std::os::raw::c_int, - micro: *mut ::std::os::raw::c_int, - ); - #[doc = " Dynamically allocates a libxc functional; which will also need to be initialized."] - pub fn xc_func_alloc() -> *mut xc_func_type; - #[doc = " Initializes a functional by id with nspin spin channels"] - pub fn xc_func_init( - p: *mut xc_func_type, - functional: ::std::os::raw::c_int, - nspin: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; - #[doc = " Destructor for an initialized functional"] - pub fn xc_func_end(p: *mut xc_func_type); - #[doc = " Evaluates the energy density for an LDA functional"] - pub fn xc_lda_exc(p: *const xc_func_type, np: size_t, rho: *const f64, zk: *mut f64); - #[doc = " Evaluates the energy density and its first derivative for an LDA functional"] - pub fn xc_lda_exc_vxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - zk: *mut f64, - vrho: *mut f64, - ); - #[doc = " Evaluates the energy density for a GGA functional"] - pub fn xc_gga_exc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - ); - #[doc = " Evaluates the energy density for a meta-GGA functional"] - pub fn xc_mgga_exc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - zk: *mut f64, - ); - #[doc = " Evaluates the energy density and its first derivative for a GGA functional"] - pub fn xc_gga_exc_vxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - ); - #[doc = " Evaluates the energy density and its first derivative for a meta-GGA functional"] - pub fn xc_mgga_exc_vxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - ); - #[doc = " Get information on a functional"] - pub fn xc_func_get_info(p: *const xc_func_type) -> *const xc_func_info_type; - #[doc = " Get the hybrid coefficient"] - pub fn xc_hyb_exx_coef(p: *const xc_func_type) -> f64; -} -extern "C" { - #[doc = " Frees a dynamically allocated functional"] - pub fn xc_func_free(p: *mut xc_func_type); -} -extern "C" { - #[doc = " Sets the density threshold for a functional"] - pub fn xc_func_set_dens_threshold(p: *mut xc_func_type, t_dens: f64); -} -extern "C" { - #[doc = " Sets the spin polarization threshold for a functional"] - pub fn xc_func_set_zeta_threshold(p: *mut xc_func_type, t_zeta: f64); -} -extern "C" { - #[doc = " Sets the reduced gradient threshold for a functional"] - pub fn xc_func_set_sigma_threshold(p: *mut xc_func_type, t_sigma: f64); -} -extern "C" { - #[doc = " Sets the kinetic energy density threshold for a functional"] - pub fn xc_func_set_tau_threshold(p: *mut xc_func_type, t_tau: f64); -} -extern "C" { - #[doc = " Sets all external parameters for a functional"] - pub fn xc_func_set_ext_params(p: *mut xc_func_type, ext_params: *const f64); -} -extern "C" { - #[doc = " Sets an external parameter by name for a functional"] - pub fn xc_func_set_ext_params_name( - p: *mut xc_func_type, - name: *const ::std::os::raw::c_char, - par: f64, - ); -} -extern "C" { - #[doc = " Evaluate an LDA functional"] - pub fn xc_lda( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - zk: *mut f64, - vrho: *mut f64, - v2rho2: *mut f64, - v3rho3: *mut f64, - v4rho4: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluate a GGA functional"] - pub fn xc_gga( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rhosigma2: *mut f64, - v3sigma3: *mut f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho2sigma2: *mut f64, - v4rhosigma3: *mut f64, - v4sigma4: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluate a meta-GGA functional"] - pub fn xc_mgga( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl_rho: *const f64, - tau: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rho2lapl: *mut f64, - v3rho2tau: *mut f64, - v3rhosigma2: *mut f64, - v3rhosigmalapl: *mut f64, - v3rhosigmatau: *mut f64, - v3rholapl2: *mut f64, - v3rholapltau: *mut f64, - v3rhotau2: *mut f64, - v3sigma3: *mut f64, - v3sigma2lapl: *mut f64, - v3sigma2tau: *mut f64, - v3sigmalapl2: *mut f64, - v3sigmalapltau: *mut f64, - v3sigmatau2: *mut f64, - v3lapl3: *mut f64, - v3lapl2tau: *mut f64, - v3lapltau2: *mut f64, - v3tau3: *mut f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho3lapl: *mut f64, - v4rho3tau: *mut f64, - v4rho2sigma2: *mut f64, - v4rho2sigmalapl: *mut f64, - v4rho2sigmatau: *mut f64, - v4rho2lapl2: *mut f64, - v4rho2lapltau: *mut f64, - v4rho2tau2: *mut f64, - v4rhosigma3: *mut f64, - v4rhosigma2lapl: *mut f64, - v4rhosigma2tau: *mut f64, - v4rhosigmalapl2: *mut f64, - v4rhosigmalapltau: *mut f64, - v4rhosigmatau2: *mut f64, - v4rholapl3: *mut f64, - v4rholapl2tau: *mut f64, - v4rholapltau2: *mut f64, - v4rhotau3: *mut f64, - v4sigma4: *mut f64, - v4sigma3lapl: *mut f64, - v4sigma3tau: *mut f64, - v4sigma2lapl2: *mut f64, - v4sigma2lapltau: *mut f64, - v4sigma2tau2: *mut f64, - v4sigmalapl3: *mut f64, - v4sigmalapl2tau: *mut f64, - v4sigmalapltau2: *mut f64, - v4sigmatau3: *mut f64, - v4lapl4: *mut f64, - v4lapl3tau: *mut f64, - v4lapl2tau2: *mut f64, - v4lapltau3: *mut f64, - v4tau4: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first derivative of the energy density for an LDA functional"] - pub fn xc_lda_vxc(p: *const xc_func_type, np: size_t, rho: *const f64, vrho: *mut f64); -} -extern "C" { - #[doc = " Evaluates the first derivative of the energy density for a GGA functional"] - pub fn xc_gga_vxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first derivative of the energy density for a meta-GGA functional"] - pub fn xc_mgga_vxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first and second derivatives for an LDA functional"] - pub fn xc_lda_exc_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - zk: *mut f64, - vrho: *mut f64, - v2rho2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first and second derivatives for a GGA functional"] - pub fn xc_gga_exc_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first and second derivatives for a meta-GGA functional"] - pub fn xc_mgga_exc_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first and second derivatives for an LDA functional"] - pub fn xc_lda_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - vrho: *mut f64, - v2rho2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first and second derivatives for a GGA functional"] - pub fn xc_gga_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first and second derivatives for a meta-GGA functional"] - pub fn xc_mgga_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the second derivative for an LDA functional"] - pub fn xc_lda_fxc(p: *const xc_func_type, np: size_t, rho: *const f64, v2rho2: *mut f64); -} -extern "C" { - #[doc = " Evaluates the second derivative for a GGA functional"] - pub fn xc_gga_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the second derivative for a meta-GGA functional"] - pub fn xc_mgga_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first, second, and third derivatives for an LDA functional"] - pub fn xc_lda_exc_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - zk: *mut f64, - vrho: *mut f64, - v2rho2: *mut f64, - v3rho3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first, second, and third derivatives for a GGA functional"] - pub fn xc_gga_exc_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rhosigma2: *mut f64, - v3sigma3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first, second, and third derivatives for a meta-GGA functional"] - pub fn xc_mgga_exc_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rho2lapl: *mut f64, - v3rho2tau: *mut f64, - v3rhosigma2: *mut f64, - v3rhosigmalapl: *mut f64, - v3rhosigmatau: *mut f64, - v3rholapl2: *mut f64, - v3rholapltau: *mut f64, - v3rhotau2: *mut f64, - v3sigma3: *mut f64, - v3sigma2lapl: *mut f64, - v3sigma2tau: *mut f64, - v3sigmalapl2: *mut f64, - v3sigmalapltau: *mut f64, - v3sigmatau2: *mut f64, - v3lapl3: *mut f64, - v3lapl2tau: *mut f64, - v3lapltau2: *mut f64, - v3tau3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first, second, and third derivatives for an LDA functional"] - pub fn xc_lda_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - vrho: *mut f64, - v2rho2: *mut f64, - v3rho3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first, second, and third derivatives for a GGA functional"] - pub fn xc_gga_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rhosigma2: *mut f64, - v3sigma3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first, second, and third derivatives for a meta-GGA functional"] - pub fn xc_mgga_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rho2lapl: *mut f64, - v3rho2tau: *mut f64, - v3rhosigma2: *mut f64, - v3rhosigmalapl: *mut f64, - v3rhosigmatau: *mut f64, - v3rholapl2: *mut f64, - v3rholapltau: *mut f64, - v3rhotau2: *mut f64, - v3sigma3: *mut f64, - v3sigma2lapl: *mut f64, - v3sigma2tau: *mut f64, - v3sigmalapl2: *mut f64, - v3sigmalapltau: *mut f64, - v3sigmatau2: *mut f64, - v3lapl3: *mut f64, - v3lapl2tau: *mut f64, - v3lapltau2: *mut f64, - v3tau3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the third derivative for an LDA functional"] - pub fn xc_lda_kxc(p: *const xc_func_type, np: size_t, rho: *const f64, v3rho3: *mut f64); -} -extern "C" { - #[doc = " Evaluates the third derivative for a GGA functional"] - pub fn xc_gga_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rhosigma2: *mut f64, - v3sigma3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the third derivative for a meta-GGA functional"] - pub fn xc_mgga_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rho2lapl: *mut f64, - v3rho2tau: *mut f64, - v3rhosigma2: *mut f64, - v3rhosigmalapl: *mut f64, - v3rhosigmatau: *mut f64, - v3rholapl2: *mut f64, - v3rholapltau: *mut f64, - v3rhotau2: *mut f64, - v3sigma3: *mut f64, - v3sigma2lapl: *mut f64, - v3sigma2tau: *mut f64, - v3sigmalapl2: *mut f64, - v3sigmalapltau: *mut f64, - v3sigmatau2: *mut f64, - v3lapl3: *mut f64, - v3lapl2tau: *mut f64, - v3lapltau2: *mut f64, - v3tau3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the fourth derivative for an LDA functional"] - pub fn xc_lda_lxc(p: *const xc_func_type, np: size_t, rho: *const f64, v4rho4: *mut f64); -} -extern "C" { - #[doc = " Evaluates the fourth derivative for a GGA functional"] - pub fn xc_gga_lxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho2sigma2: *mut f64, - v4rhosigma3: *mut f64, - v4sigma4: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the fourth derivative for a meta-GGA functional"] - pub fn xc_mgga_lxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho3lapl: *mut f64, - v4rho3tau: *mut f64, - v4rho2sigma2: *mut f64, - v4rho2sigmalapl: *mut f64, - v4rho2sigmatau: *mut f64, - v4rho2lapl2: *mut f64, - v4rho2lapltau: *mut f64, - v4rho2tau2: *mut f64, - v4rhosigma3: *mut f64, - v4rhosigma2lapl: *mut f64, - v4rhosigma2tau: *mut f64, - v4rhosigmalapl2: *mut f64, - v4rhosigmalapltau: *mut f64, - v4rhosigmatau2: *mut f64, - v4rholapl3: *mut f64, - v4rholapl2tau: *mut f64, - v4rholapltau2: *mut f64, - v4rhotau3: *mut f64, - v4sigma4: *mut f64, - v4sigma3lapl: *mut f64, - v4sigma3tau: *mut f64, - v4sigma2lapl2: *mut f64, - v4sigma2lapltau: *mut f64, - v4sigma2tau2: *mut f64, - v4sigmalapl3: *mut f64, - v4sigmalapl2tau: *mut f64, - v4sigmalapltau2: *mut f64, - v4sigmatau3: *mut f64, - v4lapl4: *mut f64, - v4lapl3tau: *mut f64, - v4lapl2tau2: *mut f64, - v4lapltau3: *mut f64, - v4tau4: *mut f64, - ); -} -extern "C" { - pub fn xc_gga_ak13_get_asymptotic(homo: f64) -> f64; -} -extern "C" { - pub fn xc_gga_ak13_pars_get_asymptotic(homo: f64, ext_params: *const f64) -> f64; -} -extern "C" { - pub fn xc_hyb_cam_coef( - p: *const xc_func_type, - omega: *mut f64, - alpha: *mut f64, - beta: *mut f64, - ); -} -extern "C" { - pub fn xc_nlc_coef(p: *const xc_func_type, nlc_b: *mut f64, nlc_C: *mut f64); -} -extern "C" { - pub fn xc_num_aux_funcs(p: *const xc_func_type) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn xc_aux_func_ids(p: *const xc_func_type, ids: *mut ::std::os::raw::c_int); -} -extern "C" { - pub fn xc_aux_func_weights(p: *const xc_func_type, weights: *mut f64); -} diff --git a/src/dft/libxc/libxc_full.rs b/src/dft/libxc/libxc_full.rs deleted file mode 100644 index c4224b2e03..0000000000 --- a/src/dft/libxc/libxc_full.rs +++ /dev/null @@ -1,3009 +0,0 @@ -/* automatically generated by rust-bindgen 0.59.1 */ - -pub const XC_UNPOLARIZED: u32 = 1; -pub const XC_POLARIZED: u32 = 2; -pub const XC_NON_RELATIVISTIC: u32 = 0; -pub const XC_RELATIVISTIC: u32 = 1; -pub const XC_EXCHANGE: u32 = 0; -pub const XC_CORRELATION: u32 = 1; -pub const XC_EXCHANGE_CORRELATION: u32 = 2; -pub const XC_KINETIC: u32 = 3; -pub const XC_FAMILY_UNKNOWN: i32 = -1; -pub const XC_FAMILY_LDA: u32 = 1; -pub const XC_FAMILY_GGA: u32 = 2; -pub const XC_FAMILY_MGGA: u32 = 4; -pub const XC_FAMILY_LCA: u32 = 8; -pub const XC_FAMILY_OEP: u32 = 16; -pub const XC_FAMILY_HYB_GGA: u32 = 32; -pub const XC_FAMILY_HYB_MGGA: u32 = 64; -pub const XC_FAMILY_HYB_LDA: u32 = 128; -pub const XC_FLAGS_HAVE_EXC: u32 = 1; -pub const XC_FLAGS_HAVE_VXC: u32 = 2; -pub const XC_FLAGS_HAVE_FXC: u32 = 4; -pub const XC_FLAGS_HAVE_KXC: u32 = 8; -pub const XC_FLAGS_HAVE_LXC: u32 = 16; -pub const XC_FLAGS_1D: u32 = 32; -pub const XC_FLAGS_2D: u32 = 64; -pub const XC_FLAGS_3D: u32 = 128; -pub const XC_FLAGS_HYB_CAM: u32 = 256; -pub const XC_FLAGS_HYB_CAMY: u32 = 512; -pub const XC_FLAGS_VV10: u32 = 1024; -pub const XC_FLAGS_HYB_LC: u32 = 2048; -pub const XC_FLAGS_HYB_LCY: u32 = 4096; -pub const XC_FLAGS_STABLE: u32 = 8192; -pub const XC_FLAGS_DEVELOPMENT: u32 = 16384; -pub const XC_FLAGS_NEEDS_LAPLACIAN: u32 = 32768; -pub const XC_FLAGS_HAVE_ALL: u32 = 31; -pub const XC_EXT_PARAMS_DEFAULT: i32 = -999998888; -pub const XC_TAU_EXPLICIT: u32 = 0; -pub const XC_TAU_EXPANSION: u32 = 1; -pub const XC_MAX_REFERENCES: u32 = 5; -pub const XC_HYB_LDA_XC_LDA0: u32 = 177; -pub const XC_HYB_LDA_XC_CAM_LDA0: u32 = 178; -pub const XC_HYB_LDA_XC_BN05: u32 = 588; -pub const XC_LDA_X: u32 = 1; -pub const XC_LDA_C_WIGNER: u32 = 2; -pub const XC_LDA_C_RPA: u32 = 3; -pub const XC_LDA_C_HL: u32 = 4; -pub const XC_LDA_C_GL: u32 = 5; -pub const XC_LDA_C_XALPHA: u32 = 6; -pub const XC_LDA_C_VWN: u32 = 7; -pub const XC_LDA_C_VWN_RPA: u32 = 8; -pub const XC_LDA_C_PZ: u32 = 9; -pub const XC_LDA_C_PZ_MOD: u32 = 10; -pub const XC_LDA_C_OB_PZ: u32 = 11; -pub const XC_LDA_C_PW: u32 = 12; -pub const XC_LDA_C_PW_MOD: u32 = 13; -pub const XC_LDA_C_OB_PW: u32 = 14; -pub const XC_LDA_C_2D_AMGB: u32 = 15; -pub const XC_LDA_C_2D_PRM: u32 = 16; -pub const XC_LDA_C_VBH: u32 = 17; -pub const XC_LDA_C_1D_CSC: u32 = 18; -pub const XC_LDA_X_2D: u32 = 19; -pub const XC_LDA_XC_TETER93: u32 = 20; -pub const XC_LDA_X_1D_SOFT: u32 = 21; -pub const XC_LDA_C_ML1: u32 = 22; -pub const XC_LDA_C_ML2: u32 = 23; -pub const XC_LDA_C_GOMBAS: u32 = 24; -pub const XC_LDA_C_PW_RPA: u32 = 25; -pub const XC_LDA_C_1D_LOOS: u32 = 26; -pub const XC_LDA_C_RC04: u32 = 27; -pub const XC_LDA_C_VWN_1: u32 = 28; -pub const XC_LDA_C_VWN_2: u32 = 29; -pub const XC_LDA_C_VWN_3: u32 = 30; -pub const XC_LDA_C_VWN_4: u32 = 31; -pub const XC_LDA_XC_ZLP: u32 = 43; -pub const XC_LDA_K_TF: u32 = 50; -pub const XC_LDA_K_LP: u32 = 51; -pub const XC_LDA_XC_KSDT: u32 = 259; -pub const XC_LDA_C_CHACHIYO: u32 = 287; -pub const XC_LDA_C_LP96: u32 = 289; -pub const XC_LDA_C_CHACHIYO_MOD: u32 = 307; -pub const XC_LDA_C_KARASIEV_MOD: u32 = 308; -pub const XC_LDA_C_W20: u32 = 317; -pub const XC_LDA_XC_CORRKSDT: u32 = 318; -pub const XC_LDA_X_REL: u32 = 532; -pub const XC_LDA_XC_1D_EHWLRG_1: u32 = 536; -pub const XC_LDA_XC_1D_EHWLRG_2: u32 = 537; -pub const XC_LDA_XC_1D_EHWLRG_3: u32 = 538; -pub const XC_LDA_X_ERF: u32 = 546; -pub const XC_LDA_XC_LP_A: u32 = 547; -pub const XC_LDA_XC_LP_B: u32 = 548; -pub const XC_LDA_X_RAE: u32 = 549; -pub const XC_LDA_K_ZLP: u32 = 550; -pub const XC_LDA_C_MCWEENY: u32 = 551; -pub const XC_LDA_C_BR78: u32 = 552; -pub const XC_LDA_C_PK09: u32 = 554; -pub const XC_LDA_C_OW_LYP: u32 = 573; -pub const XC_LDA_C_OW: u32 = 574; -pub const XC_LDA_XC_GDSMFB: u32 = 577; -pub const XC_LDA_C_GK72: u32 = 578; -pub const XC_LDA_C_KARASIEV: u32 = 579; -pub const XC_LDA_K_LP96: u32 = 580; -pub const XC_LDA_C_PMGB06: u32 = 590; -pub const XC_LDA_XC_TIH: u32 = 599; -pub const XC_LDA_X_1D_EXPONENTIAL: u32 = 600; -pub const XC_LDA_X_YUKAWA: u32 = 641; -pub const XC_LDA_C_UPW92: u32 = 683; -pub const XC_LDA_C_RPW92: u32 = 684; -pub const XC_LDA_X_SLOC: u32 = 692; -pub const XC_HYB_GGA_X_N12_SX: u32 = 81; -pub const XC_HYB_GGA_XC_B97_1P: u32 = 266; -pub const XC_HYB_GGA_XC_PBE_MOL0: u32 = 273; -pub const XC_HYB_GGA_XC_PBE_SOL0: u32 = 274; -pub const XC_HYB_GGA_XC_PBEB0: u32 = 275; -pub const XC_HYB_GGA_XC_PBE_MOLB0: u32 = 276; -pub const XC_HYB_GGA_XC_PBE50: u32 = 290; -pub const XC_HYB_GGA_XC_HFLYP: u32 = 314; -pub const XC_HYB_GGA_XC_CASE21: u32 = 390; -pub const XC_HYB_GGA_XC_PBE_2X: u32 = 392; -pub const XC_HYB_GGA_XC_PBE38: u32 = 393; -pub const XC_HYB_GGA_XC_B3LYP3: u32 = 394; -pub const XC_HYB_GGA_XC_CAM_O3LYP: u32 = 395; -pub const XC_HYB_GGA_XC_WB97X_D3: u32 = 399; -pub const XC_HYB_GGA_XC_LC_BLYP: u32 = 400; -pub const XC_HYB_GGA_XC_B3PW91: u32 = 401; -pub const XC_HYB_GGA_XC_B3LYP: u32 = 402; -pub const XC_HYB_GGA_XC_B3P86: u32 = 403; -pub const XC_HYB_GGA_XC_O3LYP: u32 = 404; -pub const XC_HYB_GGA_XC_MPW1K: u32 = 405; -pub const XC_HYB_GGA_XC_PBEH: u32 = 406; -pub const XC_HYB_GGA_XC_B97: u32 = 407; -pub const XC_HYB_GGA_XC_B97_1: u32 = 408; -pub const XC_HYB_GGA_XC_APF: u32 = 409; -pub const XC_HYB_GGA_XC_B97_2: u32 = 410; -pub const XC_HYB_GGA_XC_X3LYP: u32 = 411; -pub const XC_HYB_GGA_XC_B1WC: u32 = 412; -pub const XC_HYB_GGA_XC_B97_K: u32 = 413; -pub const XC_HYB_GGA_XC_B97_3: u32 = 414; -pub const XC_HYB_GGA_XC_MPW3PW: u32 = 415; -pub const XC_HYB_GGA_XC_B1LYP: u32 = 416; -pub const XC_HYB_GGA_XC_B1PW91: u32 = 417; -pub const XC_HYB_GGA_XC_MPW1PW: u32 = 418; -pub const XC_HYB_GGA_XC_MPW3LYP: u32 = 419; -pub const XC_HYB_GGA_XC_SB98_1A: u32 = 420; -pub const XC_HYB_GGA_XC_SB98_1B: u32 = 421; -pub const XC_HYB_GGA_XC_SB98_1C: u32 = 422; -pub const XC_HYB_GGA_XC_SB98_2A: u32 = 423; -pub const XC_HYB_GGA_XC_SB98_2B: u32 = 424; -pub const XC_HYB_GGA_XC_SB98_2C: u32 = 425; -pub const XC_HYB_GGA_X_SOGGA11_X: u32 = 426; -pub const XC_HYB_GGA_XC_HSE03: u32 = 427; -pub const XC_HYB_GGA_XC_HSE06: u32 = 428; -pub const XC_HYB_GGA_XC_HJS_PBE: u32 = 429; -pub const XC_HYB_GGA_XC_HJS_PBE_SOL: u32 = 430; -pub const XC_HYB_GGA_XC_HJS_B88: u32 = 431; -pub const XC_HYB_GGA_XC_HJS_B97X: u32 = 432; -pub const XC_HYB_GGA_XC_CAM_B3LYP: u32 = 433; -pub const XC_HYB_GGA_XC_TUNED_CAM_B3LYP: u32 = 434; -pub const XC_HYB_GGA_XC_BHANDH: u32 = 435; -pub const XC_HYB_GGA_XC_BHANDHLYP: u32 = 436; -pub const XC_HYB_GGA_XC_MB3LYP_RC04: u32 = 437; -pub const XC_HYB_GGA_XC_MPWLYP1M: u32 = 453; -pub const XC_HYB_GGA_XC_REVB3LYP: u32 = 454; -pub const XC_HYB_GGA_XC_CAMY_BLYP: u32 = 455; -pub const XC_HYB_GGA_XC_PBE0_13: u32 = 456; -pub const XC_HYB_GGA_XC_B3LYPS: u32 = 459; -pub const XC_HYB_GGA_XC_QTP17: u32 = 460; -pub const XC_HYB_GGA_XC_B3LYP_MCM1: u32 = 461; -pub const XC_HYB_GGA_XC_B3LYP_MCM2: u32 = 462; -pub const XC_HYB_GGA_XC_WB97: u32 = 463; -pub const XC_HYB_GGA_XC_WB97X: u32 = 464; -pub const XC_HYB_GGA_XC_LRC_WPBEH: u32 = 465; -pub const XC_HYB_GGA_XC_WB97X_V: u32 = 466; -pub const XC_HYB_GGA_XC_LCY_PBE: u32 = 467; -pub const XC_HYB_GGA_XC_LCY_BLYP: u32 = 468; -pub const XC_HYB_GGA_XC_LC_VV10: u32 = 469; -pub const XC_HYB_GGA_XC_CAMY_B3LYP: u32 = 470; -pub const XC_HYB_GGA_XC_WB97X_D: u32 = 471; -pub const XC_HYB_GGA_XC_HPBEINT: u32 = 472; -pub const XC_HYB_GGA_XC_LRC_WPBE: u32 = 473; -pub const XC_HYB_GGA_XC_B3LYP5: u32 = 475; -pub const XC_HYB_GGA_XC_EDF2: u32 = 476; -pub const XC_HYB_GGA_XC_CAP0: u32 = 477; -pub const XC_HYB_GGA_XC_LC_WPBE: u32 = 478; -pub const XC_HYB_GGA_XC_HSE12: u32 = 479; -pub const XC_HYB_GGA_XC_HSE12S: u32 = 480; -pub const XC_HYB_GGA_XC_HSE_SOL: u32 = 481; -pub const XC_HYB_GGA_XC_CAM_QTP_01: u32 = 482; -pub const XC_HYB_GGA_XC_MPW1LYP: u32 = 483; -pub const XC_HYB_GGA_XC_MPW1PBE: u32 = 484; -pub const XC_HYB_GGA_XC_KMLYP: u32 = 485; -pub const XC_HYB_GGA_XC_LC_WPBE_WHS: u32 = 486; -pub const XC_HYB_GGA_XC_LC_WPBEH_WHS: u32 = 487; -pub const XC_HYB_GGA_XC_LC_WPBE08_WHS: u32 = 488; -pub const XC_HYB_GGA_XC_LC_WPBESOL_WHS: u32 = 489; -pub const XC_HYB_GGA_XC_CAM_QTP_00: u32 = 490; -pub const XC_HYB_GGA_XC_CAM_QTP_02: u32 = 491; -pub const XC_HYB_GGA_XC_LC_QTP: u32 = 492; -pub const XC_HYB_GGA_X_S12H: u32 = 496; -pub const XC_HYB_GGA_XC_BLYP35: u32 = 499; -pub const XC_HYB_GGA_XC_B5050LYP: u32 = 572; -pub const XC_HYB_GGA_XC_LB07: u32 = 589; -pub const XC_HYB_GGA_XC_APBE0: u32 = 607; -pub const XC_HYB_GGA_XC_HAPBE: u32 = 608; -pub const XC_HYB_GGA_XC_RCAM_B3LYP: u32 = 610; -pub const XC_HYB_GGA_XC_WC04: u32 = 611; -pub const XC_HYB_GGA_XC_WP04: u32 = 612; -pub const XC_HYB_GGA_XC_CAMH_B3LYP: u32 = 614; -pub const XC_HYB_GGA_XC_WHPBE0: u32 = 615; -pub const XC_HYB_GGA_XC_LC_BLYP_EA: u32 = 625; -pub const XC_HYB_GGA_XC_LC_BOP: u32 = 636; -pub const XC_HYB_GGA_XC_LC_PBEOP: u32 = 637; -pub const XC_HYB_GGA_XC_LC_BLYPR: u32 = 639; -pub const XC_HYB_GGA_XC_MCAM_B3LYP: u32 = 640; -pub const XC_HYB_GGA_X_CAM_S12G: u32 = 646; -pub const XC_HYB_GGA_X_CAM_S12H: u32 = 647; -pub const XC_HYB_GGA_XC_CAM_PBEH: u32 = 681; -pub const XC_HYB_GGA_XC_CAMY_PBEH: u32 = 682; -pub const XC_GGA_X_GAM: u32 = 32; -pub const XC_GGA_C_GAM: u32 = 33; -pub const XC_GGA_X_HCTH_A: u32 = 34; -pub const XC_GGA_X_EV93: u32 = 35; -pub const XC_GGA_X_BCGP: u32 = 38; -pub const XC_GGA_C_ACGGA: u32 = 39; -pub const XC_GGA_X_LAMBDA_OC2_N: u32 = 40; -pub const XC_GGA_X_B86_R: u32 = 41; -pub const XC_GGA_X_LAMBDA_CH_N: u32 = 44; -pub const XC_GGA_X_LAMBDA_LO_N: u32 = 45; -pub const XC_GGA_X_HJS_B88_V2: u32 = 46; -pub const XC_GGA_C_Q2D: u32 = 47; -pub const XC_GGA_X_Q2D: u32 = 48; -pub const XC_GGA_X_PBE_MOL: u32 = 49; -pub const XC_GGA_K_TFVW: u32 = 52; -pub const XC_GGA_K_REVAPBEINT: u32 = 53; -pub const XC_GGA_K_APBEINT: u32 = 54; -pub const XC_GGA_K_REVAPBE: u32 = 55; -pub const XC_GGA_X_AK13: u32 = 56; -pub const XC_GGA_K_MEYER: u32 = 57; -pub const XC_GGA_X_LV_RPW86: u32 = 58; -pub const XC_GGA_X_PBE_TCA: u32 = 59; -pub const XC_GGA_X_PBEINT: u32 = 60; -pub const XC_GGA_C_ZPBEINT: u32 = 61; -pub const XC_GGA_C_PBEINT: u32 = 62; -pub const XC_GGA_C_ZPBESOL: u32 = 63; -pub const XC_GGA_XC_OPBE_D: u32 = 65; -pub const XC_GGA_XC_OPWLYP_D: u32 = 66; -pub const XC_GGA_XC_OBLYP_D: u32 = 67; -pub const XC_GGA_X_VMT84_GE: u32 = 68; -pub const XC_GGA_X_VMT84_PBE: u32 = 69; -pub const XC_GGA_X_VMT_GE: u32 = 70; -pub const XC_GGA_X_VMT_PBE: u32 = 71; -pub const XC_GGA_C_N12_SX: u32 = 79; -pub const XC_GGA_C_N12: u32 = 80; -pub const XC_GGA_X_N12: u32 = 82; -pub const XC_GGA_C_REGTPSS: u32 = 83; -pub const XC_GGA_C_OP_XALPHA: u32 = 84; -pub const XC_GGA_C_OP_G96: u32 = 85; -pub const XC_GGA_C_OP_PBE: u32 = 86; -pub const XC_GGA_C_OP_B88: u32 = 87; -pub const XC_GGA_C_FT97: u32 = 88; -pub const XC_GGA_C_SPBE: u32 = 89; -pub const XC_GGA_X_SSB_SW: u32 = 90; -pub const XC_GGA_X_SSB: u32 = 91; -pub const XC_GGA_X_SSB_D: u32 = 92; -pub const XC_GGA_XC_HCTH_407P: u32 = 93; -pub const XC_GGA_XC_HCTH_P76: u32 = 94; -pub const XC_GGA_XC_HCTH_P14: u32 = 95; -pub const XC_GGA_XC_B97_GGA1: u32 = 96; -pub const XC_GGA_C_HCTH_A: u32 = 97; -pub const XC_GGA_X_BPCCAC: u32 = 98; -pub const XC_GGA_C_REVTCA: u32 = 99; -pub const XC_GGA_C_TCA: u32 = 100; -pub const XC_GGA_X_PBE: u32 = 101; -pub const XC_GGA_X_PBE_R: u32 = 102; -pub const XC_GGA_X_B86: u32 = 103; -pub const XC_GGA_X_HERMAN: u32 = 104; -pub const XC_GGA_X_B86_MGC: u32 = 105; -pub const XC_GGA_X_B88: u32 = 106; -pub const XC_GGA_X_G96: u32 = 107; -pub const XC_GGA_X_PW86: u32 = 108; -pub const XC_GGA_X_PW91: u32 = 109; -pub const XC_GGA_X_OPTX: u32 = 110; -pub const XC_GGA_X_DK87_R1: u32 = 111; -pub const XC_GGA_X_DK87_R2: u32 = 112; -pub const XC_GGA_X_LG93: u32 = 113; -pub const XC_GGA_X_FT97_A: u32 = 114; -pub const XC_GGA_X_FT97_B: u32 = 115; -pub const XC_GGA_X_PBE_SOL: u32 = 116; -pub const XC_GGA_X_RPBE: u32 = 117; -pub const XC_GGA_X_WC: u32 = 118; -pub const XC_GGA_X_MPW91: u32 = 119; -pub const XC_GGA_X_AM05: u32 = 120; -pub const XC_GGA_X_PBEA: u32 = 121; -pub const XC_GGA_X_MPBE: u32 = 122; -pub const XC_GGA_X_XPBE: u32 = 123; -pub const XC_GGA_X_2D_B86_MGC: u32 = 124; -pub const XC_GGA_X_BAYESIAN: u32 = 125; -pub const XC_GGA_X_PBE_JSJR: u32 = 126; -pub const XC_GGA_X_2D_B88: u32 = 127; -pub const XC_GGA_X_2D_B86: u32 = 128; -pub const XC_GGA_X_2D_PBE: u32 = 129; -pub const XC_GGA_C_PBE: u32 = 130; -pub const XC_GGA_C_LYP: u32 = 131; -pub const XC_GGA_C_P86: u32 = 132; -pub const XC_GGA_C_PBE_SOL: u32 = 133; -pub const XC_GGA_C_PW91: u32 = 134; -pub const XC_GGA_C_AM05: u32 = 135; -pub const XC_GGA_C_XPBE: u32 = 136; -pub const XC_GGA_C_LM: u32 = 137; -pub const XC_GGA_C_PBE_JRGX: u32 = 138; -pub const XC_GGA_X_OPTB88_VDW: u32 = 139; -pub const XC_GGA_X_PBEK1_VDW: u32 = 140; -pub const XC_GGA_X_OPTPBE_VDW: u32 = 141; -pub const XC_GGA_X_RGE2: u32 = 142; -pub const XC_GGA_C_RGE2: u32 = 143; -pub const XC_GGA_X_RPW86: u32 = 144; -pub const XC_GGA_X_KT1: u32 = 145; -pub const XC_GGA_XC_KT2: u32 = 146; -pub const XC_GGA_C_WL: u32 = 147; -pub const XC_GGA_C_WI: u32 = 148; -pub const XC_GGA_X_MB88: u32 = 149; -pub const XC_GGA_X_SOGGA: u32 = 150; -pub const XC_GGA_X_SOGGA11: u32 = 151; -pub const XC_GGA_C_SOGGA11: u32 = 152; -pub const XC_GGA_C_WI0: u32 = 153; -pub const XC_GGA_XC_TH1: u32 = 154; -pub const XC_GGA_XC_TH2: u32 = 155; -pub const XC_GGA_XC_TH3: u32 = 156; -pub const XC_GGA_XC_TH4: u32 = 157; -pub const XC_GGA_X_C09X: u32 = 158; -pub const XC_GGA_C_SOGGA11_X: u32 = 159; -pub const XC_GGA_X_LB: u32 = 160; -pub const XC_GGA_XC_HCTH_93: u32 = 161; -pub const XC_GGA_XC_HCTH_120: u32 = 162; -pub const XC_GGA_XC_HCTH_147: u32 = 163; -pub const XC_GGA_XC_HCTH_407: u32 = 164; -pub const XC_GGA_XC_EDF1: u32 = 165; -pub const XC_GGA_XC_XLYP: u32 = 166; -pub const XC_GGA_XC_KT1: u32 = 167; -pub const XC_GGA_X_LSPBE: u32 = 168; -pub const XC_GGA_X_LSRPBE: u32 = 169; -pub const XC_GGA_XC_B97_D: u32 = 170; -pub const XC_GGA_X_OPTB86B_VDW: u32 = 171; -pub const XC_GGA_XC_PBE1W: u32 = 173; -pub const XC_GGA_XC_MPWLYP1W: u32 = 174; -pub const XC_GGA_XC_PBELYP1W: u32 = 175; -pub const XC_GGA_C_ACGGAP: u32 = 176; -pub const XC_GGA_X_B88_6311G: u32 = 179; -pub const XC_GGA_X_NCAP: u32 = 180; -pub const XC_GGA_XC_NCAP: u32 = 181; -pub const XC_GGA_X_LBM: u32 = 182; -pub const XC_GGA_X_OL2: u32 = 183; -pub const XC_GGA_X_APBE: u32 = 184; -pub const XC_GGA_K_APBE: u32 = 185; -pub const XC_GGA_C_APBE: u32 = 186; -pub const XC_GGA_K_TW1: u32 = 187; -pub const XC_GGA_K_TW2: u32 = 188; -pub const XC_GGA_K_TW3: u32 = 189; -pub const XC_GGA_K_TW4: u32 = 190; -pub const XC_GGA_X_HTBS: u32 = 191; -pub const XC_GGA_X_AIRY: u32 = 192; -pub const XC_GGA_X_LAG: u32 = 193; -pub const XC_GGA_XC_MOHLYP: u32 = 194; -pub const XC_GGA_XC_MOHLYP2: u32 = 195; -pub const XC_GGA_XC_TH_FL: u32 = 196; -pub const XC_GGA_XC_TH_FC: u32 = 197; -pub const XC_GGA_XC_TH_FCFO: u32 = 198; -pub const XC_GGA_XC_TH_FCO: u32 = 199; -pub const XC_GGA_C_OPTC: u32 = 200; -pub const XC_GGA_X_ECMV92: u32 = 215; -pub const XC_GGA_C_PBE_VWN: u32 = 216; -pub const XC_GGA_C_P86_FT: u32 = 217; -pub const XC_GGA_K_RATIONAL_P: u32 = 218; -pub const XC_GGA_K_PG1: u32 = 219; -pub const XC_GGA_C_PBELOC: u32 = 246; -pub const XC_GGA_C_P86VWN: u32 = 252; -pub const XC_GGA_C_P86VWN_FT: u32 = 253; -pub const XC_GGA_XC_VV10: u32 = 255; -pub const XC_GGA_C_PBEFE: u32 = 258; -pub const XC_GGA_C_OP_PW91: u32 = 262; -pub const XC_GGA_X_PBEFE: u32 = 265; -pub const XC_GGA_X_CAP: u32 = 270; -pub const XC_GGA_X_EB88: u32 = 271; -pub const XC_GGA_C_PBE_MOL: u32 = 272; -pub const XC_GGA_K_ABSP3: u32 = 277; -pub const XC_GGA_K_ABSP4: u32 = 278; -pub const XC_GGA_C_BMK: u32 = 280; -pub const XC_GGA_C_TAU_HCTH: u32 = 281; -pub const XC_GGA_C_HYB_TAU_HCTH: u32 = 283; -pub const XC_GGA_X_BEEFVDW: u32 = 285; -pub const XC_GGA_XC_BEEFVDW: u32 = 286; -pub const XC_GGA_X_PBETRANS: u32 = 291; -pub const XC_GGA_X_CHACHIYO: u32 = 298; -pub const XC_GGA_C_CHACHIYO: u32 = 309; -pub const XC_GGA_X_REVSSB_D: u32 = 312; -pub const XC_GGA_C_CCDF: u32 = 313; -pub const XC_GGA_X_PW91_MOD: u32 = 316; -pub const XC_GGA_X_S12G: u32 = 495; -pub const XC_GGA_K_VW: u32 = 500; -pub const XC_GGA_K_GE2: u32 = 501; -pub const XC_GGA_K_GOLDEN: u32 = 502; -pub const XC_GGA_K_YT65: u32 = 503; -pub const XC_GGA_K_BALTIN: u32 = 504; -pub const XC_GGA_K_LIEB: u32 = 505; -pub const XC_GGA_K_ABSP1: u32 = 506; -pub const XC_GGA_K_ABSP2: u32 = 507; -pub const XC_GGA_K_GR: u32 = 508; -pub const XC_GGA_K_LUDENA: u32 = 509; -pub const XC_GGA_K_GP85: u32 = 510; -pub const XC_GGA_K_PEARSON: u32 = 511; -pub const XC_GGA_K_OL1: u32 = 512; -pub const XC_GGA_K_OL2: u32 = 513; -pub const XC_GGA_K_FR_B88: u32 = 514; -pub const XC_GGA_K_FR_PW86: u32 = 515; -pub const XC_GGA_K_DK: u32 = 516; -pub const XC_GGA_K_PERDEW: u32 = 517; -pub const XC_GGA_K_VSK: u32 = 518; -pub const XC_GGA_K_VJKS: u32 = 519; -pub const XC_GGA_K_ERNZERHOF: u32 = 520; -pub const XC_GGA_K_LC94: u32 = 521; -pub const XC_GGA_K_LLP: u32 = 522; -pub const XC_GGA_K_THAKKAR: u32 = 523; -pub const XC_GGA_X_WPBEH: u32 = 524; -pub const XC_GGA_X_HJS_PBE: u32 = 525; -pub const XC_GGA_X_HJS_PBE_SOL: u32 = 526; -pub const XC_GGA_X_HJS_B88: u32 = 527; -pub const XC_GGA_X_HJS_B97X: u32 = 528; -pub const XC_GGA_X_ITYH: u32 = 529; -pub const XC_GGA_X_SFAT: u32 = 530; -pub const XC_GGA_X_SG4: u32 = 533; -pub const XC_GGA_C_SG4: u32 = 534; -pub const XC_GGA_X_GG99: u32 = 535; -pub const XC_GGA_X_PBEPOW: u32 = 539; -pub const XC_GGA_X_KGG99: u32 = 544; -pub const XC_GGA_XC_HLE16: u32 = 545; -pub const XC_GGA_C_SCAN_E0: u32 = 553; -pub const XC_GGA_C_GAPC: u32 = 555; -pub const XC_GGA_C_GAPLOC: u32 = 556; -pub const XC_GGA_C_ZVPBEINT: u32 = 557; -pub const XC_GGA_C_ZVPBESOL: u32 = 558; -pub const XC_GGA_C_TM_LYP: u32 = 559; -pub const XC_GGA_C_TM_PBE: u32 = 560; -pub const XC_GGA_C_W94: u32 = 561; -pub const XC_GGA_C_CS1: u32 = 565; -pub const XC_GGA_X_B88M: u32 = 570; -pub const XC_GGA_XC_KT3: u32 = 587; -pub const XC_GGA_K_GDS08: u32 = 591; -pub const XC_GGA_K_GHDS10: u32 = 592; -pub const XC_GGA_K_GHDS10R: u32 = 593; -pub const XC_GGA_K_TKVLN: u32 = 594; -pub const XC_GGA_K_PBE3: u32 = 595; -pub const XC_GGA_K_PBE4: u32 = 596; -pub const XC_GGA_K_EXP4: u32 = 597; -pub const XC_GGA_X_SFAT_PBE: u32 = 601; -pub const XC_GGA_X_FD_LB94: u32 = 604; -pub const XC_GGA_X_FD_REVLB94: u32 = 605; -pub const XC_GGA_C_ZVPBELOC: u32 = 606; -pub const XC_GGA_K_LKT: u32 = 613; -pub const XC_GGA_K_PBE2: u32 = 616; -pub const XC_GGA_K_VT84F: u32 = 619; -pub const XC_GGA_K_LGAP: u32 = 620; -pub const XC_GGA_X_ITYH_OPTX: u32 = 622; -pub const XC_GGA_X_ITYH_PBE: u32 = 623; -pub const XC_GGA_C_LYPR: u32 = 624; -pub const XC_GGA_K_LGAP_GE: u32 = 633; -pub const XC_GGA_K_TFVW_OPT: u32 = 635; -pub const XC_GGA_C_MGGAC: u32 = 712; -pub const XC_GGA_X_Q1D: u32 = 734; -pub const XC_HYB_MGGA_X_DLDF: u32 = 36; -pub const XC_HYB_MGGA_X_MS2H: u32 = 224; -pub const XC_HYB_MGGA_X_MN12_SX: u32 = 248; -pub const XC_HYB_MGGA_X_SCAN0: u32 = 264; -pub const XC_HYB_MGGA_X_MN15: u32 = 268; -pub const XC_HYB_MGGA_X_BMK: u32 = 279; -pub const XC_HYB_MGGA_X_TAU_HCTH: u32 = 282; -pub const XC_HYB_MGGA_X_M08_HX: u32 = 295; -pub const XC_HYB_MGGA_X_M08_SO: u32 = 296; -pub const XC_HYB_MGGA_X_M11: u32 = 297; -pub const XC_HYB_MGGA_X_REVM11: u32 = 304; -pub const XC_HYB_MGGA_X_REVM06: u32 = 305; -pub const XC_HYB_MGGA_X_M06_SX: u32 = 310; -pub const XC_HYB_MGGA_XC_TPSS0: u32 = 396; -pub const XC_HYB_MGGA_XC_B94_HYB: u32 = 398; -pub const XC_HYB_MGGA_X_M05: u32 = 438; -pub const XC_HYB_MGGA_X_M05_2X: u32 = 439; -pub const XC_HYB_MGGA_XC_B88B95: u32 = 440; -pub const XC_HYB_MGGA_XC_B86B95: u32 = 441; -pub const XC_HYB_MGGA_XC_PW86B95: u32 = 442; -pub const XC_HYB_MGGA_XC_BB1K: u32 = 443; -pub const XC_HYB_MGGA_X_M06_HF: u32 = 444; -pub const XC_HYB_MGGA_XC_MPW1B95: u32 = 445; -pub const XC_HYB_MGGA_XC_MPWB1K: u32 = 446; -pub const XC_HYB_MGGA_XC_X1B95: u32 = 447; -pub const XC_HYB_MGGA_XC_XB1K: u32 = 448; -pub const XC_HYB_MGGA_X_M06: u32 = 449; -pub const XC_HYB_MGGA_X_M06_2X: u32 = 450; -pub const XC_HYB_MGGA_XC_PW6B95: u32 = 451; -pub const XC_HYB_MGGA_XC_PWB6K: u32 = 452; -pub const XC_HYB_MGGA_XC_TPSSH: u32 = 457; -pub const XC_HYB_MGGA_XC_REVTPSSH: u32 = 458; -pub const XC_HYB_MGGA_X_MVSH: u32 = 474; -pub const XC_HYB_MGGA_XC_WB97M_V: u32 = 531; -pub const XC_HYB_MGGA_XC_B0KCIS: u32 = 563; -pub const XC_HYB_MGGA_XC_MPW1KCIS: u32 = 566; -pub const XC_HYB_MGGA_XC_MPWKCIS1K: u32 = 567; -pub const XC_HYB_MGGA_XC_PBE1KCIS: u32 = 568; -pub const XC_HYB_MGGA_XC_TPSS1KCIS: u32 = 569; -pub const XC_HYB_MGGA_X_REVSCAN0: u32 = 583; -pub const XC_HYB_MGGA_XC_B98: u32 = 598; -pub const XC_HYB_MGGA_XC_EDMGGAH: u32 = 695; -pub const XC_HYB_MGGA_X_JS18: u32 = 705; -pub const XC_HYB_MGGA_X_PJS18: u32 = 706; -pub const XC_HYB_MGGA_XC_LC_TMLYP: u32 = 720; -pub const XC_MGGA_C_DLDF: u32 = 37; -pub const XC_MGGA_XC_ZLP: u32 = 42; -pub const XC_MGGA_XC_OTPSS_D: u32 = 64; -pub const XC_MGGA_C_CS: u32 = 72; -pub const XC_MGGA_C_MN12_SX: u32 = 73; -pub const XC_MGGA_C_MN12_L: u32 = 74; -pub const XC_MGGA_C_M11_L: u32 = 75; -pub const XC_MGGA_C_M11: u32 = 76; -pub const XC_MGGA_C_M08_SO: u32 = 77; -pub const XC_MGGA_C_M08_HX: u32 = 78; -pub const XC_MGGA_C_REVM11: u32 = 172; -pub const XC_MGGA_X_LTA: u32 = 201; -pub const XC_MGGA_X_TPSS: u32 = 202; -pub const XC_MGGA_X_M06_L: u32 = 203; -pub const XC_MGGA_X_GVT4: u32 = 204; -pub const XC_MGGA_X_TAU_HCTH: u32 = 205; -pub const XC_MGGA_X_BR89: u32 = 206; -pub const XC_MGGA_X_BJ06: u32 = 207; -pub const XC_MGGA_X_TB09: u32 = 208; -pub const XC_MGGA_X_RPP09: u32 = 209; -pub const XC_MGGA_X_2D_PRHG07: u32 = 210; -pub const XC_MGGA_X_2D_PRHG07_PRP10: u32 = 211; -pub const XC_MGGA_X_REVTPSS: u32 = 212; -pub const XC_MGGA_X_PKZB: u32 = 213; -pub const XC_MGGA_X_BR89_1: u32 = 214; -pub const XC_MGGA_K_PGSL025: u32 = 220; -pub const XC_MGGA_X_MS0: u32 = 221; -pub const XC_MGGA_X_MS1: u32 = 222; -pub const XC_MGGA_X_MS2: u32 = 223; -pub const XC_MGGA_X_TH: u32 = 225; -pub const XC_MGGA_X_M11_L: u32 = 226; -pub const XC_MGGA_X_MN12_L: u32 = 227; -pub const XC_MGGA_X_MS2_REV: u32 = 228; -pub const XC_MGGA_XC_CC06: u32 = 229; -pub const XC_MGGA_X_MK00: u32 = 230; -pub const XC_MGGA_C_TPSS: u32 = 231; -pub const XC_MGGA_C_VSXC: u32 = 232; -pub const XC_MGGA_C_M06_L: u32 = 233; -pub const XC_MGGA_C_M06_HF: u32 = 234; -pub const XC_MGGA_C_M06: u32 = 235; -pub const XC_MGGA_C_M06_2X: u32 = 236; -pub const XC_MGGA_C_M05: u32 = 237; -pub const XC_MGGA_C_M05_2X: u32 = 238; -pub const XC_MGGA_C_PKZB: u32 = 239; -pub const XC_MGGA_C_BC95: u32 = 240; -pub const XC_MGGA_C_REVTPSS: u32 = 241; -pub const XC_MGGA_XC_TPSSLYP1W: u32 = 242; -pub const XC_MGGA_X_MK00B: u32 = 243; -pub const XC_MGGA_X_BLOC: u32 = 244; -pub const XC_MGGA_X_MODTPSS: u32 = 245; -pub const XC_MGGA_C_TPSSLOC: u32 = 247; -pub const XC_MGGA_X_MBEEF: u32 = 249; -pub const XC_MGGA_X_MBEEFVDW: u32 = 250; -pub const XC_MGGA_C_TM: u32 = 251; -pub const XC_MGGA_XC_B97M_V: u32 = 254; -pub const XC_MGGA_X_JK: u32 = 256; -pub const XC_MGGA_X_MVS: u32 = 257; -pub const XC_MGGA_X_MN15_L: u32 = 260; -pub const XC_MGGA_C_MN15_L: u32 = 261; -pub const XC_MGGA_X_SCAN: u32 = 263; -pub const XC_MGGA_C_SCAN: u32 = 267; -pub const XC_MGGA_C_MN15: u32 = 269; -pub const XC_MGGA_X_B00: u32 = 284; -pub const XC_MGGA_XC_HLE17: u32 = 288; -pub const XC_MGGA_C_SCAN_RVV10: u32 = 292; -pub const XC_MGGA_X_REVM06_L: u32 = 293; -pub const XC_MGGA_C_REVM06_L: u32 = 294; -pub const XC_MGGA_X_RTPSS: u32 = 299; -pub const XC_MGGA_X_MS2B: u32 = 300; -pub const XC_MGGA_X_MS2BS: u32 = 301; -pub const XC_MGGA_X_MVSB: u32 = 302; -pub const XC_MGGA_X_MVSBS: u32 = 303; -pub const XC_MGGA_C_REVM06: u32 = 306; -pub const XC_MGGA_C_M06_SX: u32 = 311; -pub const XC_MGGA_X_FT98: u32 = 319; -pub const XC_MGGA_C_RREGTM: u32 = 391; -pub const XC_MGGA_C_B94: u32 = 397; -pub const XC_MGGA_X_RSCAN: u32 = 493; -pub const XC_MGGA_C_RSCAN: u32 = 494; -pub const XC_MGGA_X_R2SCAN: u32 = 497; -pub const XC_MGGA_C_R2SCAN: u32 = 498; -pub const XC_MGGA_X_TM: u32 = 540; -pub const XC_MGGA_X_VT84: u32 = 541; -pub const XC_MGGA_X_SA_TPSS: u32 = 542; -pub const XC_MGGA_K_PC07: u32 = 543; -pub const XC_MGGA_C_KCIS: u32 = 562; -pub const XC_MGGA_XC_LP90: u32 = 564; -pub const XC_MGGA_C_B88: u32 = 571; -pub const XC_MGGA_X_GX: u32 = 575; -pub const XC_MGGA_X_PBE_GX: u32 = 576; -pub const XC_MGGA_X_REVSCAN: u32 = 581; -pub const XC_MGGA_C_REVSCAN: u32 = 582; -pub const XC_MGGA_C_SCAN_VV10: u32 = 584; -pub const XC_MGGA_C_REVSCAN_VV10: u32 = 585; -pub const XC_MGGA_X_BR89_EXPLICIT: u32 = 586; -pub const XC_MGGA_X_BR89_EXPLICIT_1: u32 = 602; -pub const XC_MGGA_X_REGTPSS: u32 = 603; -pub const XC_MGGA_X_2D_JS17: u32 = 609; -pub const XC_MGGA_K_L04: u32 = 617; -pub const XC_MGGA_K_L06: u32 = 618; -pub const XC_MGGA_K_RDA: u32 = 621; -pub const XC_MGGA_X_REGTM: u32 = 626; -pub const XC_MGGA_K_GEA2: u32 = 627; -pub const XC_MGGA_K_GEA4: u32 = 628; -pub const XC_MGGA_K_CSK1: u32 = 629; -pub const XC_MGGA_K_CSK4: u32 = 630; -pub const XC_MGGA_K_CSK_LOC1: u32 = 631; -pub const XC_MGGA_K_CSK_LOC4: u32 = 632; -pub const XC_MGGA_K_PC07_OPT: u32 = 634; -pub const XC_MGGA_C_KCISK: u32 = 638; -pub const XC_MGGA_C_R2SCAN01: u32 = 642; -pub const XC_MGGA_C_RMGGAC: u32 = 643; -pub const XC_MGGA_X_MCML: u32 = 644; -pub const XC_MGGA_X_R2SCAN01: u32 = 645; -pub const XC_MGGA_X_RPPSCAN: u32 = 648; -pub const XC_MGGA_C_RPPSCAN: u32 = 649; -pub const XC_MGGA_X_R4SCAN: u32 = 650; -pub const XC_MGGA_X_TLDA: u32 = 685; -pub const XC_MGGA_X_EDMGGA: u32 = 686; -pub const XC_MGGA_X_GDME_NV: u32 = 687; -pub const XC_MGGA_X_RLDA: u32 = 688; -pub const XC_MGGA_X_GDME_0: u32 = 689; -pub const XC_MGGA_X_GDME_KOS: u32 = 690; -pub const XC_MGGA_X_GDME_VT: u32 = 691; -pub const XC_MGGA_X_REVTM: u32 = 693; -pub const XC_MGGA_C_REVTM: u32 = 694; -pub const XC_MGGA_X_MBRXC_BG: u32 = 696; -pub const XC_MGGA_X_MBRXH_BG: u32 = 697; -pub const XC_MGGA_X_HLTA: u32 = 698; -pub const XC_MGGA_C_HLTAPW: u32 = 699; -pub const XC_MGGA_X_SCANL: u32 = 700; -pub const XC_MGGA_X_REVSCANL: u32 = 701; -pub const XC_MGGA_C_SCANL: u32 = 702; -pub const XC_MGGA_C_SCANL_RVV10: u32 = 703; -pub const XC_MGGA_C_SCANL_VV10: u32 = 704; -pub const XC_MGGA_X_TASK: u32 = 707; -pub const XC_MGGA_X_MGGAC: u32 = 711; -pub const XC_MGGA_X_MBR: u32 = 716; -pub const XC_MGGA_X_R2SCANL: u32 = 718; -pub const XC_MGGA_C_R2SCANL: u32 = 719; -pub const XC_MGGA_X_MTASK: u32 = 724; -pub const XC_LDA_X_1D: u32 = 21; -pub const XC_GGA_X_BGCP: u32 = 38; -pub const XC_GGA_C_BGCP: u32 = 39; -pub const XC_GGA_C_BCGP: u32 = 39; -pub const XC_GGA_C_VPBE: u32 = 83; -pub const XC_GGA_XC_LB: u32 = 160; -pub const XC_MGGA_C_CC06: u32 = 229; -pub const XC_GGA_K_ABSR1: u32 = 506; -pub const XC_GGA_K_ABSR2: u32 = 507; -pub const XC_LDA_C_LP_A: u32 = 547; -pub const XC_LDA_C_LP_B: u32 = 548; -pub const XC_MGGA_C_LP90: u32 = 564; -pub const XC_LDA_C_vBH: u32 = 17; -pub const XC_HYB_GGA_XC_B97_1p: u32 = 266; -pub const XC_HYB_GGA_XC_mPW1K: u32 = 405; -pub const XC_HYB_GGA_XC_mPW1PW: u32 = 418; -pub const XC_HYB_GGA_XC_SB98_1a: u32 = 420; -pub const XC_HYB_GGA_XC_SB98_1b: u32 = 421; -pub const XC_HYB_GGA_XC_SB98_1c: u32 = 422; -pub const XC_HYB_GGA_XC_SB98_2a: u32 = 423; -pub const XC_HYB_GGA_XC_SB98_2b: u32 = 424; -pub const XC_HYB_GGA_XC_SB98_2c: u32 = 425; -pub const XC_HYB_GGA_XC_B3LYPs: u32 = 459; -pub const XC_GGA_X_PBEpow: u32 = 539; -pub const XC_GGA_XC_B97: u32 = 167; -pub const XC_GGA_XC_B97_1: u32 = 168; -pub const XC_GGA_XC_B97_2: u32 = 169; -pub const XC_GGA_XC_B97_K: u32 = 171; -pub const XC_GGA_XC_B97_3: u32 = 172; -pub const XC_GGA_XC_SB98_1a: u32 = 176; -pub const XC_GGA_XC_SB98_1b: u32 = 177; -pub const XC_GGA_XC_SB98_1c: u32 = 178; -pub const XC_GGA_XC_SB98_2a: u32 = 179; -pub const XC_GGA_XC_SB98_2b: u32 = 180; -pub const XC_GGA_XC_SB98_2c: u32 = 181; -pub const XC_MGGA_X_M05: u32 = 214; -pub const XC_MGGA_X_M05_2X: u32 = 215; -pub const XC_MGGA_X_M06_HF: u32 = 216; -pub const XC_MGGA_X_M06: u32 = 217; -pub const XC_MGGA_X_M06_2X: u32 = 218; -pub const XC_MGGA_X_M08_HX: u32 = 219; -pub const XC_MGGA_X_M08_SO: u32 = 220; -pub const XC_MGGA_X_M11: u32 = 225; -pub const XC_MGGA_X_MN12_SX: u32 = 228; -pub const XC_GGA_XC_WB97: u32 = 251; -pub const XC_GGA_XC_WB97X: u32 = 252; -pub const XC_GGA_XC_WB97X_V: u32 = 253; -pub const XC_GGA_XC_WB97X_D: u32 = 256; -pub const XC_HYB_MGGA_XC_M08_HX: u32 = 460; -pub const XC_HYB_MGGA_XC_M08_SO: u32 = 461; -pub const XC_HYB_MGGA_XC_M11: u32 = 462; -extern "C" { - pub fn xc_reference() -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_reference_doi() -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_version( - major: *mut ::std::os::raw::c_int, - minor: *mut ::std::os::raw::c_int, - micro: *mut ::std::os::raw::c_int, - ); -} -extern "C" { - pub fn xc_version_string() -> *const ::std::os::raw::c_char; -} -pub type size_t = ::std::os::raw::c_ulong; -pub type wchar_t = ::std::os::raw::c_int; -#[repr(C)] -#[repr(align(16))] -#[derive(Debug, Copy, Clone)] -pub struct max_align_t { - pub __clang_max_align_nonce1: ::std::os::raw::c_longlong, - pub __bindgen_padding_0: u64, - pub __clang_max_align_nonce2: u128, -} -#[test] -fn bindgen_test_layout_max_align_t() { - assert_eq!( - ::std::mem::size_of::(), - 32usize, - concat!("Size of: ", stringify!(max_align_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 16usize, - concat!("Alignment of ", stringify!(max_align_t)) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__clang_max_align_nonce1 as *const _ as usize - }, - 0usize, - concat!( - "Offset of field: ", - stringify!(max_align_t), - "::", - stringify!(__clang_max_align_nonce1) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).__clang_max_align_nonce2 as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(max_align_t), - "::", - stringify!(__clang_max_align_nonce2) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct func_reference_type { - pub ref_: *const ::std::os::raw::c_char, - pub doi: *const ::std::os::raw::c_char, - pub bibtex: *const ::std::os::raw::c_char, -} -#[test] -fn bindgen_test_layout_func_reference_type() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(func_reference_type)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(func_reference_type)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ref_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(func_reference_type), - "::", - stringify!(ref_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).doi as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(func_reference_type), - "::", - stringify!(doi) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).bibtex as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(func_reference_type), - "::", - stringify!(bibtex) - ) - ); -} -extern "C" { - pub fn xc_func_reference_get_ref( - reference: *const func_reference_type, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_func_reference_get_doi( - reference: *const func_reference_type, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_func_reference_get_bibtex( - reference: *const func_reference_type, - ) -> *const ::std::os::raw::c_char; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct func_params_type { - pub n: ::std::os::raw::c_int, - pub names: *mut *const ::std::os::raw::c_char, - pub descriptions: *mut *const ::std::os::raw::c_char, - pub values: *const f64, - pub set: - ::std::option::Option, -} -#[test] -fn bindgen_test_layout_func_params_type() { - assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(func_params_type)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(func_params_type)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).n as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(func_params_type), - "::", - stringify!(n) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).names as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(func_params_type), - "::", - stringify!(names) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).descriptions as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(func_params_type), - "::", - stringify!(descriptions) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).values as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(func_params_type), - "::", - stringify!(values) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).set as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(func_params_type), - "::", - stringify!(set) - ) - ); -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct xc_func_info_type { - pub number: ::std::os::raw::c_int, - pub kind: ::std::os::raw::c_int, - pub name: *const ::std::os::raw::c_char, - pub family: ::std::os::raw::c_int, - pub refs: [*mut func_reference_type; 5usize], - pub flags: ::std::os::raw::c_int, - pub dens_threshold: f64, - pub ext_params: func_params_type, - pub init: ::std::option::Option, - pub end: ::std::option::Option, - pub lda: ::std::option::Option< - unsafe extern "C" fn( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - zk: *mut f64, - vrho: *mut f64, - v2rho2: *mut f64, - v3rho3: *mut f64, - v4rho4: *mut f64, - ), - >, - pub gga: ::std::option::Option< - unsafe extern "C" fn( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rhosigma2: *mut f64, - v3sigma3: *mut f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho2sigma2: *mut f64, - v4rhosigma3: *mut f64, - v4sigma4: *mut f64, - ), - >, - pub mgga: ::std::option::Option< - unsafe extern "C" fn( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl_rho: *const f64, - tau: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rho2lapl: *mut f64, - v3rho2tau: *mut f64, - v3rhosigma2: *mut f64, - v3rhosigmalapl: *mut f64, - v3rhosigmatau: *mut f64, - v3rholapl2: *mut f64, - v3rholapltau: *mut f64, - v3rhotau2: *mut f64, - v3sigma3: *mut f64, - v3sigma2lapl: *mut f64, - v3sigma2tau: *mut f64, - v3sigmalapl2: *mut f64, - v3sigmalapltau: *mut f64, - v3sigmatau2: *mut f64, - v3lapl3: *mut f64, - v3lapl2tau: *mut f64, - v3lapltau2: *mut f64, - v3tau3: *mut f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho3lapl: *mut f64, - v4rho3tau: *mut f64, - v4rho2sigma2: *mut f64, - v4rho2sigmalapl: *mut f64, - v4rho2sigmatau: *mut f64, - v4rho2lapl2: *mut f64, - v4rho2lapltau: *mut f64, - v4rho2tau2: *mut f64, - v4rhosigma3: *mut f64, - v4rhosigma2lapl: *mut f64, - v4rhosigma2tau: *mut f64, - v4rhosigmalapl2: *mut f64, - v4rhosigmalapltau: *mut f64, - v4rhosigmatau2: *mut f64, - v4rholapl3: *mut f64, - v4rholapl2tau: *mut f64, - v4rholapltau2: *mut f64, - v4rhotau3: *mut f64, - v4sigma4: *mut f64, - v4sigma3lapl: *mut f64, - v4sigma3tau: *mut f64, - v4sigma2lapl2: *mut f64, - v4sigma2lapltau: *mut f64, - v4sigma2tau2: *mut f64, - v4sigmalapl3: *mut f64, - v4sigmalapl2tau: *mut f64, - v4sigmalapltau2: *mut f64, - v4sigmatau3: *mut f64, - v4lapl4: *mut f64, - v4lapl3tau: *mut f64, - v4lapl2tau2: *mut f64, - v4lapltau3: *mut f64, - v4tau4: *mut f64, - ), - >, -} -#[test] -fn bindgen_test_layout_xc_func_info_type() { - assert_eq!( - ::std::mem::size_of::(), - 160usize, - concat!("Size of: ", stringify!(xc_func_info_type)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(xc_func_info_type)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).number as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(number) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).kind as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(kind) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).name as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(name) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).family as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(family) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).refs as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(refs) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).flags as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(flags) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).dens_threshold as *const _ as usize - }, - 72usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(dens_threshold) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).ext_params as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(ext_params) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).init as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(init) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).end as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(end) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).lda as *const _ as usize }, - 136usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(lda) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).gga as *const _ as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(gga) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mgga as *const _ as usize }, - 152usize, - concat!( - "Offset of field: ", - stringify!(xc_func_info_type), - "::", - stringify!(mgga) - ) - ); -} -extern "C" { - pub fn xc_func_info_get_number(info: *const xc_func_info_type) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn xc_func_info_get_kind(info: *const xc_func_info_type) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn xc_func_info_get_name(info: *const xc_func_info_type) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_func_info_get_family(info: *const xc_func_info_type) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn xc_func_info_get_flags(info: *const xc_func_info_type) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn xc_func_info_get_references( - info: *const xc_func_info_type, - number: ::std::os::raw::c_int, - ) -> *const func_reference_type; -} -extern "C" { - pub fn xc_func_info_get_n_ext_params(info: *const xc_func_info_type) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn xc_func_info_get_ext_params_name( - p: *const xc_func_info_type, - number: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_func_info_get_ext_params_description( - info: *const xc_func_info_type, - number: ::std::os::raw::c_int, - ) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn xc_func_info_get_ext_params_default_value( - info: *const xc_func_info_type, - number: ::std::os::raw::c_int, - ) -> f64; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct xc_dimensions { - pub rho: ::std::os::raw::c_int, - pub sigma: ::std::os::raw::c_int, - pub lapl: ::std::os::raw::c_int, - pub tau: ::std::os::raw::c_int, - pub zk: ::std::os::raw::c_int, - pub vrho: ::std::os::raw::c_int, - pub vsigma: ::std::os::raw::c_int, - pub vlapl: ::std::os::raw::c_int, - pub vtau: ::std::os::raw::c_int, - pub v2rho2: ::std::os::raw::c_int, - pub v2rhosigma: ::std::os::raw::c_int, - pub v2rholapl: ::std::os::raw::c_int, - pub v2rhotau: ::std::os::raw::c_int, - pub v2sigma2: ::std::os::raw::c_int, - pub v2sigmalapl: ::std::os::raw::c_int, - pub v2sigmatau: ::std::os::raw::c_int, - pub v2lapl2: ::std::os::raw::c_int, - pub v2lapltau: ::std::os::raw::c_int, - pub v2tau2: ::std::os::raw::c_int, - pub v3rho3: ::std::os::raw::c_int, - pub v3rho2sigma: ::std::os::raw::c_int, - pub v3rho2lapl: ::std::os::raw::c_int, - pub v3rho2tau: ::std::os::raw::c_int, - pub v3rhosigma2: ::std::os::raw::c_int, - pub v3rhosigmalapl: ::std::os::raw::c_int, - pub v3rhosigmatau: ::std::os::raw::c_int, - pub v3rholapl2: ::std::os::raw::c_int, - pub v3rholapltau: ::std::os::raw::c_int, - pub v3rhotau2: ::std::os::raw::c_int, - pub v3sigma3: ::std::os::raw::c_int, - pub v3sigma2lapl: ::std::os::raw::c_int, - pub v3sigma2tau: ::std::os::raw::c_int, - pub v3sigmalapl2: ::std::os::raw::c_int, - pub v3sigmalapltau: ::std::os::raw::c_int, - pub v3sigmatau2: ::std::os::raw::c_int, - pub v3lapl3: ::std::os::raw::c_int, - pub v3lapl2tau: ::std::os::raw::c_int, - pub v3lapltau2: ::std::os::raw::c_int, - pub v3tau3: ::std::os::raw::c_int, - pub v4rho4: ::std::os::raw::c_int, - pub v4rho3sigma: ::std::os::raw::c_int, - pub v4rho3lapl: ::std::os::raw::c_int, - pub v4rho3tau: ::std::os::raw::c_int, - pub v4rho2sigma2: ::std::os::raw::c_int, - pub v4rho2sigmalapl: ::std::os::raw::c_int, - pub v4rho2sigmatau: ::std::os::raw::c_int, - pub v4rho2lapl2: ::std::os::raw::c_int, - pub v4rho2lapltau: ::std::os::raw::c_int, - pub v4rho2tau2: ::std::os::raw::c_int, - pub v4rhosigma3: ::std::os::raw::c_int, - pub v4rhosigma2lapl: ::std::os::raw::c_int, - pub v4rhosigma2tau: ::std::os::raw::c_int, - pub v4rhosigmalapl2: ::std::os::raw::c_int, - pub v4rhosigmalapltau: ::std::os::raw::c_int, - pub v4rhosigmatau2: ::std::os::raw::c_int, - pub v4rholapl3: ::std::os::raw::c_int, - pub v4rholapl2tau: ::std::os::raw::c_int, - pub v4rholapltau2: ::std::os::raw::c_int, - pub v4rhotau3: ::std::os::raw::c_int, - pub v4sigma4: ::std::os::raw::c_int, - pub v4sigma3lapl: ::std::os::raw::c_int, - pub v4sigma3tau: ::std::os::raw::c_int, - pub v4sigma2lapl2: ::std::os::raw::c_int, - pub v4sigma2lapltau: ::std::os::raw::c_int, - pub v4sigma2tau2: ::std::os::raw::c_int, - pub v4sigmalapl3: ::std::os::raw::c_int, - pub v4sigmalapl2tau: ::std::os::raw::c_int, - pub v4sigmalapltau2: ::std::os::raw::c_int, - pub v4sigmatau3: ::std::os::raw::c_int, - pub v4lapl4: ::std::os::raw::c_int, - pub v4lapl3tau: ::std::os::raw::c_int, - pub v4lapl2tau2: ::std::os::raw::c_int, - pub v4lapltau3: ::std::os::raw::c_int, - pub v4tau4: ::std::os::raw::c_int, -} -#[test] -fn bindgen_test_layout_xc_dimensions() { - assert_eq!( - ::std::mem::size_of::(), - 296usize, - concat!("Size of: ", stringify!(xc_dimensions)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(xc_dimensions)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).rho as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(rho) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sigma as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(sigma) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).lapl as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(lapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tau as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(tau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).zk as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(zk) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vrho as *const _ as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(vrho) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vsigma as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(vsigma) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vlapl as *const _ as usize }, - 28usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(vlapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).vtau as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(vtau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v2rho2 as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v2rho2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v2rhosigma as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v2rhosigma) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v2rholapl as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v2rholapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v2rhotau as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v2rhotau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v2sigma2 as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v2sigma2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v2sigmalapl as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v2sigmalapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v2sigmatau as *const _ as usize }, - 60usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v2sigmatau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v2lapl2 as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v2lapl2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v2lapltau as *const _ as usize }, - 68usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v2lapltau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v2tau2 as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v2tau2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3rho3 as *const _ as usize }, - 76usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3rho3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3rho2sigma as *const _ as usize }, - 80usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3rho2sigma) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3rho2lapl as *const _ as usize }, - 84usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3rho2lapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3rho2tau as *const _ as usize }, - 88usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3rho2tau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3rhosigma2 as *const _ as usize }, - 92usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3rhosigma2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3rhosigmalapl as *const _ as usize }, - 96usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3rhosigmalapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3rhosigmatau as *const _ as usize }, - 100usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3rhosigmatau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3rholapl2 as *const _ as usize }, - 104usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3rholapl2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3rholapltau as *const _ as usize }, - 108usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3rholapltau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3rhotau2 as *const _ as usize }, - 112usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3rhotau2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3sigma3 as *const _ as usize }, - 116usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3sigma3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3sigma2lapl as *const _ as usize }, - 120usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3sigma2lapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3sigma2tau as *const _ as usize }, - 124usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3sigma2tau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3sigmalapl2 as *const _ as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3sigmalapl2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3sigmalapltau as *const _ as usize }, - 132usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3sigmalapltau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3sigmatau2 as *const _ as usize }, - 136usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3sigmatau2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3lapl3 as *const _ as usize }, - 140usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3lapl3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3lapl2tau as *const _ as usize }, - 144usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3lapl2tau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3lapltau2 as *const _ as usize }, - 148usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3lapltau2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v3tau3 as *const _ as usize }, - 152usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v3tau3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rho4 as *const _ as usize }, - 156usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rho4) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rho3sigma as *const _ as usize }, - 160usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rho3sigma) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rho3lapl as *const _ as usize }, - 164usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rho3lapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rho3tau as *const _ as usize }, - 168usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rho3tau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rho2sigma2 as *const _ as usize }, - 172usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rho2sigma2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rho2sigmalapl as *const _ as usize }, - 176usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rho2sigmalapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rho2sigmatau as *const _ as usize }, - 180usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rho2sigmatau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rho2lapl2 as *const _ as usize }, - 184usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rho2lapl2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rho2lapltau as *const _ as usize }, - 188usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rho2lapltau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rho2tau2 as *const _ as usize }, - 192usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rho2tau2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rhosigma3 as *const _ as usize }, - 196usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rhosigma3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rhosigma2lapl as *const _ as usize }, - 200usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rhosigma2lapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rhosigma2tau as *const _ as usize }, - 204usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rhosigma2tau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rhosigmalapl2 as *const _ as usize }, - 208usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rhosigmalapl2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rhosigmalapltau as *const _ as usize }, - 212usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rhosigmalapltau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rhosigmatau2 as *const _ as usize }, - 216usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rhosigmatau2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rholapl3 as *const _ as usize }, - 220usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rholapl3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rholapl2tau as *const _ as usize }, - 224usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rholapl2tau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rholapltau2 as *const _ as usize }, - 228usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rholapltau2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4rhotau3 as *const _ as usize }, - 232usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4rhotau3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4sigma4 as *const _ as usize }, - 236usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4sigma4) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4sigma3lapl as *const _ as usize }, - 240usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4sigma3lapl) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4sigma3tau as *const _ as usize }, - 244usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4sigma3tau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4sigma2lapl2 as *const _ as usize }, - 248usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4sigma2lapl2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4sigma2lapltau as *const _ as usize }, - 252usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4sigma2lapltau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4sigma2tau2 as *const _ as usize }, - 256usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4sigma2tau2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4sigmalapl3 as *const _ as usize }, - 260usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4sigmalapl3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4sigmalapl2tau as *const _ as usize }, - 264usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4sigmalapl2tau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4sigmalapltau2 as *const _ as usize }, - 268usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4sigmalapltau2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4sigmatau3 as *const _ as usize }, - 272usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4sigmatau3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4lapl4 as *const _ as usize }, - 276usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4lapl4) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4lapl3tau as *const _ as usize }, - 280usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4lapl3tau) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4lapl2tau2 as *const _ as usize }, - 284usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4lapl2tau2) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4lapltau3 as *const _ as usize }, - 288usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4lapltau3) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).v4tau4 as *const _ as usize }, - 292usize, - concat!( - "Offset of field: ", - stringify!(xc_dimensions), - "::", - stringify!(v4tau4) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct xc_func_type { - pub info: *const xc_func_info_type, - pub nspin: ::std::os::raw::c_int, - pub n_func_aux: ::std::os::raw::c_int, - pub func_aux: *mut *mut xc_func_type, - pub mix_coef: *mut f64, - #[doc = "Parameters for range-separated hybrids"] - #[doc = "cam_omega: the range separation constant"] - #[doc = "cam_alpha: fraction of full Hartree-Fock exchange, used both for"] - #[doc = "usual hybrids as well as range-separated ones"] - #[doc = "cam_beta: fraction of short-range only(!) exchange in"] - #[doc = "range-separated hybrids"] - #[doc = ""] - #[doc = "N.B. Different conventions for alpha and beta can be found in"] - #[doc = "literature. In the convention used in libxc, at short range the"] - #[doc = "fraction of exact exchange is cam_alpha+cam_beta, while at long"] - #[doc = "range it is cam_alpha."] - pub cam_omega: f64, - #[doc = "Parameters for range-separated hybrids"] - #[doc = "cam_omega: the range separation constant"] - #[doc = "cam_alpha: fraction of full Hartree-Fock exchange, used both for"] - #[doc = "usual hybrids as well as range-separated ones"] - #[doc = "cam_beta: fraction of short-range only(!) exchange in"] - #[doc = "range-separated hybrids"] - #[doc = ""] - #[doc = "N.B. Different conventions for alpha and beta can be found in"] - #[doc = "literature. In the convention used in libxc, at short range the"] - #[doc = "fraction of exact exchange is cam_alpha+cam_beta, while at long"] - #[doc = "range it is cam_alpha."] - pub cam_alpha: f64, - #[doc = "Parameters for range-separated hybrids"] - #[doc = "cam_omega: the range separation constant"] - #[doc = "cam_alpha: fraction of full Hartree-Fock exchange, used both for"] - #[doc = "usual hybrids as well as range-separated ones"] - #[doc = "cam_beta: fraction of short-range only(!) exchange in"] - #[doc = "range-separated hybrids"] - #[doc = ""] - #[doc = "N.B. Different conventions for alpha and beta can be found in"] - #[doc = "literature. In the convention used in libxc, at short range the"] - #[doc = "fraction of exact exchange is cam_alpha+cam_beta, while at long"] - #[doc = "range it is cam_alpha."] - pub cam_beta: f64, - pub nlc_b: f64, - pub nlc_C: f64, - pub dim: xc_dimensions, - pub params: *mut ::std::os::raw::c_void, - pub dens_threshold: f64, - pub zeta_threshold: f64, - pub sigma_threshold: f64, - pub tau_threshold: f64, -} -#[test] -fn bindgen_test_layout_xc_func_type() { - assert_eq!( - ::std::mem::size_of::(), - 408usize, - concat!("Size of: ", stringify!(xc_func_type)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(xc_func_type)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).info as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(info) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nspin as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(nspin) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).n_func_aux as *const _ as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(n_func_aux) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).func_aux as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(func_aux) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mix_coef as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(mix_coef) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cam_omega as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(cam_omega) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cam_alpha as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(cam_alpha) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).cam_beta as *const _ as usize }, - 48usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(cam_beta) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nlc_b as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(nlc_b) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).nlc_C as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(nlc_C) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dim as *const _ as usize }, - 72usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(dim) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).params as *const _ as usize }, - 368usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(params) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).dens_threshold as *const _ as usize }, - 376usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(dens_threshold) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).zeta_threshold as *const _ as usize }, - 384usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(zeta_threshold) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).sigma_threshold as *const _ as usize }, - 392usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(sigma_threshold) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).tau_threshold as *const _ as usize }, - 400usize, - concat!( - "Offset of field: ", - stringify!(xc_func_type), - "::", - stringify!(tau_threshold) - ) - ); -} -extern "C" { - #[doc = " Get a functional's id number from its name"] - pub fn xc_functional_get_number(name: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " Get a functional's name from its id number"] - pub fn xc_functional_get_name(number: ::std::os::raw::c_int) -> *mut ::std::os::raw::c_char; -} -extern "C" { - #[doc = " Get a functional's family and the number within the family from the id number"] - pub fn xc_family_from_id( - id: ::std::os::raw::c_int, - family: *mut ::std::os::raw::c_int, - number: *mut ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " The number of functionals implemented in this version of libxc"] - pub fn xc_number_of_functionals() -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " The maximum name length of any functional"] - pub fn xc_maximum_name_length() -> ::std::os::raw::c_int; -} -extern "C" { - #[doc = " Returns the available functional number sorted by id"] - pub fn xc_available_functional_numbers(list: *mut ::std::os::raw::c_int); -} -extern "C" { - #[doc = " Returns the available functional number sorted by the functionals'"] - #[doc = "names; this function is a helper for the Python frontend."] - pub fn xc_available_functional_numbers_by_name(list: *mut ::std::os::raw::c_int); -} -extern "C" { - #[doc = " Fills the list with the names of the available functionals,"] - #[doc = "ordered by name. The list array should be [Nfuncs][maxlen+1]."] - pub fn xc_available_functional_names(list: *mut *mut ::std::os::raw::c_char); -} - -#[link(name="xc",kind="static")] -extern "C" { - #[doc = " Dynamically allocates a libxc functional; which will also need to be initialized."] - pub fn xc_func_alloc() -> *mut xc_func_type; - #[doc = " Initializes a functional by id with nspin spin channels"] - pub fn xc_func_init( - p: *mut xc_func_type, - functional: ::std::os::raw::c_int, - nspin: ::std::os::raw::c_int, - ) -> ::std::os::raw::c_int; - #[doc = " Destructor for an initialized functional"] - pub fn xc_func_end(p: *mut xc_func_type); -} -extern "C" { - #[doc = " Frees a dynamically allocated functional"] - pub fn xc_func_free(p: *mut xc_func_type); -} -extern "C" { - #[doc = " Get information on a functional"] - pub fn xc_func_get_info(p: *const xc_func_type) -> *const xc_func_info_type; -} -extern "C" { - #[doc = " Sets the density threshold for a functional"] - pub fn xc_func_set_dens_threshold(p: *mut xc_func_type, t_dens: f64); -} -extern "C" { - #[doc = " Sets the spin polarization threshold for a functional"] - pub fn xc_func_set_zeta_threshold(p: *mut xc_func_type, t_zeta: f64); -} -extern "C" { - #[doc = " Sets the reduced gradient threshold for a functional"] - pub fn xc_func_set_sigma_threshold(p: *mut xc_func_type, t_sigma: f64); -} -extern "C" { - #[doc = " Sets the kinetic energy density threshold for a functional"] - pub fn xc_func_set_tau_threshold(p: *mut xc_func_type, t_tau: f64); -} -extern "C" { - #[doc = " Sets all external parameters for a functional"] - pub fn xc_func_set_ext_params(p: *mut xc_func_type, ext_params: *const f64); -} -extern "C" { - #[doc = " Sets an external parameter by name for a functional"] - pub fn xc_func_set_ext_params_name( - p: *mut xc_func_type, - name: *const ::std::os::raw::c_char, - par: f64, - ); -} -extern "C" { - #[doc = " Evaluate an LDA functional"] - pub fn xc_lda( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - zk: *mut f64, - vrho: *mut f64, - v2rho2: *mut f64, - v3rho3: *mut f64, - v4rho4: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluate a GGA functional"] - pub fn xc_gga( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rhosigma2: *mut f64, - v3sigma3: *mut f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho2sigma2: *mut f64, - v4rhosigma3: *mut f64, - v4sigma4: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluate a meta-GGA functional"] - pub fn xc_mgga( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl_rho: *const f64, - tau: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rho2lapl: *mut f64, - v3rho2tau: *mut f64, - v3rhosigma2: *mut f64, - v3rhosigmalapl: *mut f64, - v3rhosigmatau: *mut f64, - v3rholapl2: *mut f64, - v3rholapltau: *mut f64, - v3rhotau2: *mut f64, - v3sigma3: *mut f64, - v3sigma2lapl: *mut f64, - v3sigma2tau: *mut f64, - v3sigmalapl2: *mut f64, - v3sigmalapltau: *mut f64, - v3sigmatau2: *mut f64, - v3lapl3: *mut f64, - v3lapl2tau: *mut f64, - v3lapltau2: *mut f64, - v3tau3: *mut f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho3lapl: *mut f64, - v4rho3tau: *mut f64, - v4rho2sigma2: *mut f64, - v4rho2sigmalapl: *mut f64, - v4rho2sigmatau: *mut f64, - v4rho2lapl2: *mut f64, - v4rho2lapltau: *mut f64, - v4rho2tau2: *mut f64, - v4rhosigma3: *mut f64, - v4rhosigma2lapl: *mut f64, - v4rhosigma2tau: *mut f64, - v4rhosigmalapl2: *mut f64, - v4rhosigmalapltau: *mut f64, - v4rhosigmatau2: *mut f64, - v4rholapl3: *mut f64, - v4rholapl2tau: *mut f64, - v4rholapltau2: *mut f64, - v4rhotau3: *mut f64, - v4sigma4: *mut f64, - v4sigma3lapl: *mut f64, - v4sigma3tau: *mut f64, - v4sigma2lapl2: *mut f64, - v4sigma2lapltau: *mut f64, - v4sigma2tau2: *mut f64, - v4sigmalapl3: *mut f64, - v4sigmalapl2tau: *mut f64, - v4sigmalapltau2: *mut f64, - v4sigmatau3: *mut f64, - v4lapl4: *mut f64, - v4lapl3tau: *mut f64, - v4lapl2tau2: *mut f64, - v4lapltau3: *mut f64, - v4tau4: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density for an LDA functional"] - pub fn xc_lda_exc(p: *const xc_func_type, np: size_t, rho: *const f64, zk: *mut f64); -} -extern "C" { - #[doc = " Evaluates the energy density for a GGA functional"] - pub fn xc_gga_exc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density for a meta-GGA functional"] - pub fn xc_mgga_exc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - zk: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first derivative for an LDA functional"] - pub fn xc_lda_exc_vxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - zk: *mut f64, - vrho: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first derivative for a GGA functional"] - pub fn xc_gga_exc_vxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first derivative for a meta-GGA functional"] - pub fn xc_mgga_exc_vxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first derivative of the energy density for an LDA functional"] - pub fn xc_lda_vxc(p: *const xc_func_type, np: size_t, rho: *const f64, vrho: *mut f64); -} -extern "C" { - #[doc = " Evaluates the first derivative of the energy density for a GGA functional"] - pub fn xc_gga_vxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first derivative of the energy density for a meta-GGA functional"] - pub fn xc_mgga_vxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first and second derivatives for an LDA functional"] - pub fn xc_lda_exc_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - zk: *mut f64, - vrho: *mut f64, - v2rho2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first and second derivatives for a GGA functional"] - pub fn xc_gga_exc_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first and second derivatives for a meta-GGA functional"] - pub fn xc_mgga_exc_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first and second derivatives for an LDA functional"] - pub fn xc_lda_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - vrho: *mut f64, - v2rho2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first and second derivatives for a GGA functional"] - pub fn xc_gga_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first and second derivatives for a meta-GGA functional"] - pub fn xc_mgga_vxc_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the second derivative for an LDA functional"] - pub fn xc_lda_fxc(p: *const xc_func_type, np: size_t, rho: *const f64, v2rho2: *mut f64); -} -extern "C" { - #[doc = " Evaluates the second derivative for a GGA functional"] - pub fn xc_gga_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the second derivative for a meta-GGA functional"] - pub fn xc_mgga_fxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first, second, and third derivatives for an LDA functional"] - pub fn xc_lda_exc_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - zk: *mut f64, - vrho: *mut f64, - v2rho2: *mut f64, - v3rho3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first, second, and third derivatives for a GGA functional"] - pub fn xc_gga_exc_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rhosigma2: *mut f64, - v3sigma3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the energy density and its first, second, and third derivatives for a meta-GGA functional"] - pub fn xc_mgga_exc_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - zk: *mut f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rho2lapl: *mut f64, - v3rho2tau: *mut f64, - v3rhosigma2: *mut f64, - v3rhosigmalapl: *mut f64, - v3rhosigmatau: *mut f64, - v3rholapl2: *mut f64, - v3rholapltau: *mut f64, - v3rhotau2: *mut f64, - v3sigma3: *mut f64, - v3sigma2lapl: *mut f64, - v3sigma2tau: *mut f64, - v3sigmalapl2: *mut f64, - v3sigmalapltau: *mut f64, - v3sigmatau2: *mut f64, - v3lapl3: *mut f64, - v3lapl2tau: *mut f64, - v3lapltau2: *mut f64, - v3tau3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first, second, and third derivatives for an LDA functional"] - pub fn xc_lda_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - vrho: *mut f64, - v2rho2: *mut f64, - v3rho3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first, second, and third derivatives for a GGA functional"] - pub fn xc_gga_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2sigma2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rhosigma2: *mut f64, - v3sigma3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the first, second, and third derivatives for a meta-GGA functional"] - pub fn xc_mgga_vxc_fxc_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - vrho: *mut f64, - vsigma: *mut f64, - vlapl: *mut f64, - vtau: *mut f64, - v2rho2: *mut f64, - v2rhosigma: *mut f64, - v2rholapl: *mut f64, - v2rhotau: *mut f64, - v2sigma2: *mut f64, - v2sigmalapl: *mut f64, - v2sigmatau: *mut f64, - v2lapl2: *mut f64, - v2lapltau: *mut f64, - v2tau2: *mut f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rho2lapl: *mut f64, - v3rho2tau: *mut f64, - v3rhosigma2: *mut f64, - v3rhosigmalapl: *mut f64, - v3rhosigmatau: *mut f64, - v3rholapl2: *mut f64, - v3rholapltau: *mut f64, - v3rhotau2: *mut f64, - v3sigma3: *mut f64, - v3sigma2lapl: *mut f64, - v3sigma2tau: *mut f64, - v3sigmalapl2: *mut f64, - v3sigmalapltau: *mut f64, - v3sigmatau2: *mut f64, - v3lapl3: *mut f64, - v3lapl2tau: *mut f64, - v3lapltau2: *mut f64, - v3tau3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the third derivative for an LDA functional"] - pub fn xc_lda_kxc(p: *const xc_func_type, np: size_t, rho: *const f64, v3rho3: *mut f64); -} -extern "C" { - #[doc = " Evaluates the third derivative for a GGA functional"] - pub fn xc_gga_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rhosigma2: *mut f64, - v3sigma3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the third derivative for a meta-GGA functional"] - pub fn xc_mgga_kxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - v3rho3: *mut f64, - v3rho2sigma: *mut f64, - v3rho2lapl: *mut f64, - v3rho2tau: *mut f64, - v3rhosigma2: *mut f64, - v3rhosigmalapl: *mut f64, - v3rhosigmatau: *mut f64, - v3rholapl2: *mut f64, - v3rholapltau: *mut f64, - v3rhotau2: *mut f64, - v3sigma3: *mut f64, - v3sigma2lapl: *mut f64, - v3sigma2tau: *mut f64, - v3sigmalapl2: *mut f64, - v3sigmalapltau: *mut f64, - v3sigmatau2: *mut f64, - v3lapl3: *mut f64, - v3lapl2tau: *mut f64, - v3lapltau2: *mut f64, - v3tau3: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the fourth derivative for an LDA functional"] - pub fn xc_lda_lxc(p: *const xc_func_type, np: size_t, rho: *const f64, v4rho4: *mut f64); -} -extern "C" { - #[doc = " Evaluates the fourth derivative for a GGA functional"] - pub fn xc_gga_lxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho2sigma2: *mut f64, - v4rhosigma3: *mut f64, - v4sigma4: *mut f64, - ); -} -extern "C" { - #[doc = " Evaluates the fourth derivative for a meta-GGA functional"] - pub fn xc_mgga_lxc( - p: *const xc_func_type, - np: size_t, - rho: *const f64, - sigma: *const f64, - lapl: *const f64, - tau: *const f64, - v4rho4: *mut f64, - v4rho3sigma: *mut f64, - v4rho3lapl: *mut f64, - v4rho3tau: *mut f64, - v4rho2sigma2: *mut f64, - v4rho2sigmalapl: *mut f64, - v4rho2sigmatau: *mut f64, - v4rho2lapl2: *mut f64, - v4rho2lapltau: *mut f64, - v4rho2tau2: *mut f64, - v4rhosigma3: *mut f64, - v4rhosigma2lapl: *mut f64, - v4rhosigma2tau: *mut f64, - v4rhosigmalapl2: *mut f64, - v4rhosigmalapltau: *mut f64, - v4rhosigmatau2: *mut f64, - v4rholapl3: *mut f64, - v4rholapl2tau: *mut f64, - v4rholapltau2: *mut f64, - v4rhotau3: *mut f64, - v4sigma4: *mut f64, - v4sigma3lapl: *mut f64, - v4sigma3tau: *mut f64, - v4sigma2lapl2: *mut f64, - v4sigma2lapltau: *mut f64, - v4sigma2tau2: *mut f64, - v4sigmalapl3: *mut f64, - v4sigmalapl2tau: *mut f64, - v4sigmalapltau2: *mut f64, - v4sigmatau3: *mut f64, - v4lapl4: *mut f64, - v4lapl3tau: *mut f64, - v4lapl2tau2: *mut f64, - v4lapltau3: *mut f64, - v4tau4: *mut f64, - ); -} -extern "C" { - pub fn xc_gga_ak13_get_asymptotic(homo: f64) -> f64; -} -extern "C" { - pub fn xc_gga_ak13_pars_get_asymptotic(homo: f64, ext_params: *const f64) -> f64; -} -extern "C" { - pub fn xc_hyb_exx_coef(p: *const xc_func_type) -> f64; -} -extern "C" { - pub fn xc_hyb_cam_coef( - p: *const xc_func_type, - omega: *mut f64, - alpha: *mut f64, - beta: *mut f64, - ); -} -extern "C" { - pub fn xc_nlc_coef(p: *const xc_func_type, nlc_b: *mut f64, nlc_C: *mut f64); -} -extern "C" { - pub fn xc_num_aux_funcs(p: *const xc_func_type) -> ::std::os::raw::c_int; -} -extern "C" { - pub fn xc_aux_func_ids(p: *const xc_func_type, ids: *mut ::std::os::raw::c_int); -} -extern "C" { - pub fn xc_aux_func_weights(p: *const xc_func_type, weights: *mut f64); -} diff --git a/src/dft/libxc/mod.rs b/src/dft/libxc/mod.rs index dcc47c1568..fc10e8a682 100644 --- a/src/dft/libxc/mod.rs +++ b/src/dft/libxc/mod.rs @@ -1,1207 +1,362 @@ -#![allow(unused)] -pub mod ffi_xc; -pub mod names_and_values; +use std::collections::HashMap; -use std::convert::TryInto; -use std::os::raw::c_int; -use std::os::raw::c_double; -use std::ffi::CStr; -use std::mem::ManuallyDrop; -use std::slice; +use ::libxc::prelude::*; -use tensors::MatrixFull; - -//use self::ffi_xc::xc_func_info_type; -use crate::dft::libxc::ffi_xc::xc_func_info_type; - -use super::Grids; - -//use self::libxc::xc_func_type; -//use self::libxc::func_params_type; - -//pub(crate) mod ffi_xc; - -#[derive(Clone,Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum LibXCFamily { LDA, GGA, MGGA, HybridGGA, HybridMGGA, - Unknown + Unknown, } -#[derive(Clone,Debug)] +impl LibXCFamily { + fn from_libxc(family: ::libxc::enums::LibXCFamily) -> Self { + match family { + ::libxc::enums::LibXCFamily::LDA | ::libxc::enums::LibXCFamily::HybLDA => LibXCFamily::LDA, + ::libxc::enums::LibXCFamily::GGA => LibXCFamily::GGA, + ::libxc::enums::LibXCFamily::MGGA => LibXCFamily::MGGA, + ::libxc::enums::LibXCFamily::HybGGA => LibXCFamily::HybridGGA, + ::libxc::enums::LibXCFamily::HybMGGA => LibXCFamily::HybridMGGA, + _ => LibXCFamily::Unknown, + } + } +} + +#[derive(Debug)] pub struct XcFuncType { - xc_func_type: *mut ffi_xc::xc_func_type, - pub xc_func_info_type: *const ffi_xc::xc_func_info_type, + inner: LibXCFunctional, pub xc_func_family: LibXCFamily, - spin_channel: usize, } -//pub struct XcFuncInfoType { -// xc_func_info_type: Option<*const ffi_xc::xc_func_info_type>, -// x_func_info_type: Option<*const ffi_xc::xc_func_info_type>, -// c_func_info_type: Option<*const ffi_xc::xc_func_info_type>, -//} impl XcFuncType { - - pub fn xc_version(&self) { - let mut vmajor:c_int = 0; - let mut vminor:c_int = 0; - let mut vmicro:c_int = 0; - unsafe{ffi_xc::xc_version(&mut vmajor, &mut vminor, &mut vmicro)}; - println!("Libxc version: {}.{}.{}", vmajor, vminor, vmicro); - } - pub fn xc_func_init(func_id: usize, spin_channel: usize) -> XcFuncType { - let mut xc_func_type = unsafe{ffi_xc::xc_func_alloc()}; - let init = unsafe{ffi_xc::xc_func_init( - xc_func_type, - func_id as c_int, - spin_channel as c_int)}; - - let xc_func_info_type = unsafe{ffi_xc::xc_func_get_info(xc_func_type)}; - - //let xc_func_info_type = match xc_func_type[0] { - // Some(xc_func_type) => {Some(unsafe{ffi_xc::xc_func_get_info(xc_func_type)})}, - // None => None - //}; - //let x_func_info_type = match xc_func_type[1] { - // Some(xc_func_type) => {Some(unsafe{ffi_xc::xc_func_get_info(xc_func_type)})}, - // None => None - //}; - //let c_func_info_type = match xc_func_type[2] { - // Some(xc_func_type) => {Some(unsafe{ffi_xc::xc_func_get_info(xc_func_type)})}, - // None => None - //}; - //let xc_func_info_type = [xc_func_info_type,x_func_info_type,c_func_info_type]; - - - let xc_func_family = XcFuncType::get_family_enum(xc_func_info_type); - //let xc_func_family = match xc_func_info_type[0] { - // Some(xc_func_info_type) => {Some(XcFuncType::get_family_enum(xc_func_info_type))}, - // None => None - //}; - //let x_func_family = match xc_func_info_type[1] { - // Some(xc_func_info_type) => {Some(XcFuncType::get_family_enum(xc_func_info_type))}, - // None => None - //}; - //let c_func_family = match xc_func_info_type[2] { - // Some(xc_func_info_type) => {Some(XcFuncType::get_family_enum(xc_func_info_type))}, - // None => None - //}; - //let xc_func_family = [xc_func_family, x_func_family,c_func_family]; - + let spin = if spin_channel == 1 { + LibXCSpin::Unpolarized + } else { + LibXCSpin::Polarized + }; + let inner = LibXCFunctional::from_number(func_id as i32, spin); + let xc_func_family = LibXCFamily::from_libxc(inner.family()); XcFuncType { - xc_func_type, - xc_func_info_type, + inner, xc_func_family, - spin_channel } } - //pub fn xc_func_init_fdqc(name: &str, spin_channel: usize) -> XcFuncType { - // let lower_name = name.to_lowercase(); - // let xc_code: (usize, usize,usize) = XcFuncType::xc_code_fdqc(name); - // XcFuncType::xc_func_init(xc_code, spin_channel) - //} + pub fn xc_func_end(&mut self) { + // No-op: Drop handles cleanup automatically + } + pub fn xc_version(&self) { + let (major, minor, micro) = ::libxc::util::libxc_version(); + println!("Libxc version: {}.{}.{}", major, minor, micro); + } - pub fn xc_code_fdqc(name: &str) -> (usize,usize,usize) { - let lower_name = name.to_lowercase(); - // for a list of exchange-correlation functionals - if lower_name.eq(&"hf".to_string()) { - (0,0,0) - } else if lower_name.eq(&"svwn".to_string()) { - (0,1,7) - } else if lower_name.eq(&"svwn-rpa".to_string()) { - (0,1,8) - } else if lower_name.eq(&"pz-lda".to_string()) { - (0,1,9) - } else if lower_name.eq(&"pw-lda".to_string()) { - (0,1,12) - } else if lower_name.eq(&"blyp".to_string()) { - (0,106,131) - } else if lower_name.eq(&"xlyp".to_string()) { - (166,0,0) - } else if lower_name.eq(&"pbe".to_string()) { - (0,101,130) - } else if lower_name.eq(&"xpbe".to_string()) { - (0,123,136) - } else if lower_name.eq(&"scan".to_string()) { - (0,263,267) - } else if lower_name.eq(&"revscan".to_string()) { - (0,581,582) - } else if lower_name.eq(&"r2scan".to_string()) { - (0,497,498) - } else if lower_name.eq(&"tpss".to_string()) { - (0,202,231) - } else if lower_name.eq(&"b3lyp".to_string()) { - (402,0,0) - } else if lower_name.eq(&"x3lyp".to_string()) { - (411,0,0) - } else if lower_name.eq(&"pbe0".to_string()) { - (406,0,0) - } else if lower_name.eq(&"scan0".to_string()) { - (0,264,267) - } else if lower_name.eq(&"tpssh".to_string()) { - (457,0,0) - } - // for a list of exchange functionals - else if lower_name.eq(&"lda_x_slater".to_string()) { - (0,1,0) - } else { - for (name, value) in names_and_values::MAP.iter() { - if name.starts_with("XC_") && format!("xc_{}", lower_name) == name.to_lowercase() { - if name.contains("_XC_") { - return (*value, 0, 0); - } else if name.contains("_C_") { - return (0, 0, *value); - } else if name.contains("_X_") { - return (0, *value, 0); - } - } - } - (0,0,0) - } + pub fn is_rsh(&self) -> bool { + self.inner.is_hyb_cam() } - pub fn code_to_name(code: usize) -> String { - for (name, value) in names_and_values::MAP.iter() { - if *value == code { - return name.to_string(); - } - } - "Unknown_XC".to_string() + pub fn xc_hyb_cam_coef(&self) -> (f64, f64, f64) { + self.inner.cam_coef().unwrap_or((0.0, 0.0, 0.0)) } + pub fn xc_hyb_exx_coeff(&self) -> f64 { + self.inner.hyb_exx_coef().unwrap_or(0.0) + } - pub fn xc_func_end(&mut self) { - unsafe{ffi_xc::xc_func_end(self.xc_func_type)} + pub fn is_nlc(&self) -> bool { + self.inner.flags().contains(LibXCFlags::VV10) } - pub fn get_family_name(&self) -> String { - match self.xc_func_family { - LibXCFamily::LDA => "LDA".to_string(), - LibXCFamily::GGA => "GGA".to_string(), - LibXCFamily::MGGA => "MGGA".to_string(), - LibXCFamily::HybridGGA => "HybridGGA".to_string(), - LibXCFamily::HybridMGGA => "HybridMGGA".to_string(), - LibXCFamily::Unknown => "Unknown DFA".to_string(), - } + pub fn use_laplacian(&self) -> bool { + self.inner.needs_laplacian() } - //pub fn is_dfa(&self) -> bool { - // self.xc_func_type.iter().fold(false, |acc,xc_func_type| { - // match xc_func_type { - // Some(_) => {acc || true}, - // None => {acc || false}, - // } - // }) - //} pub fn use_density_gradient(&self) -> bool { - match self.xc_func_family { - LibXCFamily::LDA => {false}, - _ => {true}, - } + !matches!(self.xc_func_family, LibXCFamily::LDA) } - + pub fn use_kinetic_density(&self) -> bool { - match self.xc_func_family { - LibXCFamily::MGGA => {true}, - LibXCFamily::HybridMGGA => {true}, - _ => {false}, - } + matches!( + self.xc_func_family, + LibXCFamily::MGGA | LibXCFamily::HybridMGGA + ) } pub fn use_exact_exchange(&self) -> bool { - match self.xc_func_family { - LibXCFamily::HybridGGA => {true}, - LibXCFamily::HybridMGGA => {true}, - _ => {false}, - } + matches!( + self.xc_func_family, + LibXCFamily::HybridGGA | LibXCFamily::HybridMGGA + ) } pub fn is_lda(&self) -> bool { - match self.xc_func_family { - LibXCFamily::LDA => true, - _ => false - } + matches!(self.xc_func_family, LibXCFamily::LDA) } pub fn is_gga(&self) -> bool { - match self.xc_func_family { - LibXCFamily::GGA => true, - _ => false - } + matches!(self.xc_func_family, LibXCFamily::GGA) } pub fn is_mgga(&self) -> bool { - match self.xc_func_family { - LibXCFamily::MGGA => true, - _ => false - } + matches!(self.xc_func_family, LibXCFamily::MGGA) } pub fn is_hybrid_gga(&self) -> bool { - match self.xc_func_family { - LibXCFamily::HybridGGA => true, - _ => false - } + matches!(self.xc_func_family, LibXCFamily::HybridGGA) } pub fn is_hybrid_mgga(&self) -> bool { + matches!(self.xc_func_family, LibXCFamily::HybridMGGA) + } + + pub fn get_family_name(&self) -> String { match self.xc_func_family { - LibXCFamily::HybridMGGA => true, - _ => false + LibXCFamily::LDA => "LDA".to_string(), + LibXCFamily::GGA => "GGA".to_string(), + LibXCFamily::MGGA => "MGGA".to_string(), + LibXCFamily::HybridGGA => "HybridGGA".to_string(), + LibXCFamily::HybridMGGA => "HybridMGGA".to_string(), + LibXCFamily::Unknown => "Unknown DFA".to_string(), } } - pub fn is_rsh(&self) -> bool { - unsafe{(*self.xc_func_info_type).flags & (ffi_xc::XC_FLAGS_HYB_CAM as i32) != 0 - } + pub fn get_libxc_family(&self) -> LibXCFamily { + self.xc_func_family.clone() // LibXCFamily derives Clone } - pub fn xc_hyb_cam_coef(&self) -> (f64, f64, f64) { - let mut omega: f64 = 0.0; - let mut alpha: f64 = 0.0; - let mut beta: f64 = 0.0; - unsafe{ffi_xc::xc_hyb_cam_coef(self.xc_func_type, &mut omega, &mut alpha, &mut beta)}; - (omega, alpha, beta) + pub fn get_libxc_references(&self) -> Vec { + self.inner + .references() + .iter() + .map(|r| r.ref_text.clone()) + .collect() } - pub fn xc_hyb_exx_coeff(&self) -> f64 { - unsafe{ffi_xc::xc_hyb_exx_coef(self.xc_func_type)} + pub fn xc_func_info_printout(&self) { + println!("{}", self.inner.describe()); } - pub fn is_nlc(&self) -> bool { - unsafe{(*self.xc_func_info_type).flags & (ffi_xc::XC_FLAGS_VV10 as i32) != 0} + pub fn xc_code_fdqc(name: &str) -> (usize, usize, usize) { + let lower_name = name.to_lowercase(); + if lower_name.eq("hf") { + (0, 0, 0) + } else if lower_name.eq("svwn") { + (0, 1, 7) + } else if lower_name.eq("svwn-rpa") { + (0, 1, 8) + } else if lower_name.eq("pz-lda") { + (0, 1, 9) + } else if lower_name.eq("pw-lda") { + (0, 1, 12) + } else if lower_name.eq("blyp") { + (0, 106, 131) + } else if lower_name.eq("xlyp") { + (166, 0, 0) + } else if lower_name.eq("pbe") { + (0, 101, 130) + } else if lower_name.eq("xpbe") { + (0, 123, 136) + } else if lower_name.eq("scan") { + (0, 263, 267) + } else if lower_name.eq("revscan") { + (0, 581, 582) + } else if lower_name.eq("r2scan") { + (0, 497, 498) + } else if lower_name.eq("tpss") { + (0, 202, 231) + } else if lower_name.eq("b3lyp") { + (402, 0, 0) + } else if lower_name.eq("x3lyp") { + (411, 0, 0) + } else if lower_name.eq("pbe0") { + (406, 0, 0) + } else if lower_name.eq("scan0") { + (0, 264, 267) + } else if lower_name.eq("tpssh") { + (457, 0, 0) + } else if lower_name.eq("lda_x_slater") { + (0, 1, 0) + } else { + for (name, value) in LIBXC_FUNC_MAP.iter() { + if name.starts_with("XC_") && format!("xc_{}", lower_name) == name.to_lowercase() { + if name.contains("_XC_") { + return (*value as usize, 0, 0); + } else if name.contains("_C_") { + return (0, 0, *value as usize); + } else if name.contains("_X_") { + return (0, *value as usize, 0); + } + } + } + (0, 0, 0) + } } - pub fn use_laplacian(&self) -> bool { - unsafe{(*self.xc_func_info_type).flags & (ffi_xc::XC_FLAGS_NEEDS_LAPLACIAN as i32) != 0} + pub fn code_to_name(code: usize) -> String { + ::libxc::util::libxc_functional_get_name(code as i32).unwrap_or_else(|| "Unknown_XC".to_string()) } + // Simple LDA/GGA/MGGA compute wrappers pub fn lda_exc(&self, rho: &[f64]) -> Vec { - let length = rho.len()/&self.spin_channel; - //println!("debug rho length: {}",length); - let mut exc = vec![0.0; length]; - unsafe{ - ffi_xc::xc_lda_exc( - self.xc_func_type, - length as u64, - rho.as_ptr(), - exc.as_mut_ptr()); - } - exc + let np = rho.len() / (self.inner.spin() as usize); + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + let (buf, layout) = self.inner.compute_lda(&input, 0).unwrap(); + buf[layout.get("zk").unwrap()].to_vec() } pub fn gga_exc(&self, rho: &[f64], sigma: &[f64]) -> Vec { - let length = rho.len()/&self.spin_channel; - let mut exc = vec![0.0; length]; - unsafe{ - ffi_xc::xc_gga_exc( - self.xc_func_type, - length as u64, - rho.as_ptr(), - sigma.as_ptr(), - exc.as_mut_ptr(), - ); - } - exc - } - - pub fn mgga_exc(&self, rho: &[f64], sigma: &[f64], lapl: &[f64], tau: &[f64]) -> Vec { - let length = rho.len()/&self.spin_channel; - let mut exc = vec![0.0; length]; - unsafe{ - ffi_xc::xc_mgga_exc( - self.xc_func_type, - length as u64, - rho.as_ptr(), - sigma.as_ptr(), - lapl.as_ptr(), - tau.as_ptr(), - exc.as_mut_ptr(), - ); + let np = rho.len() / (self.inner.spin() as usize); + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + input.insert("sigma".to_string(), sigma); + let (buf, layout) = self.inner.compute_gga(&input, 0).unwrap(); + buf[layout.get("zk").unwrap()].to_vec() + } + + pub fn mgga_exc(&self, rho: &[f64], sigma: &[f64], _lapl: &[f64], tau: &[f64]) -> Vec { + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + input.insert("sigma".to_string(), sigma); + if self.inner.needs_laplacian() { + input.insert("lapl".to_string(), _lapl); } - exc + input.insert("tau".to_string(), tau); + let (buf, layout) = self.inner.compute_mgga(&input, 0).unwrap(); + buf[layout.get("zk").unwrap()].to_vec() } pub fn lda_exc_vxc(&self, rho: &[f64]) -> (Vec, Vec) { - let length = rho.len()/&self.spin_channel; - //println!("debug rho length: {}",length); - let mut exc = vec![0.0; length]; - let mut vrho = vec![0.0; length*&self.spin_channel]; - unsafe{ - ffi_xc::xc_lda_exc_vxc( - self.xc_func_type, - length as u64, - rho.as_ptr(), - exc.as_mut_ptr(), - vrho.as_mut_ptr()); - } - // println!("Debug: In lda_exc_vxc exc: {:?}", &exc); - (exc,vrho) - } - - pub fn gga_exc_vxc(&self, rho: &[f64], sigma: &[f64]) -> (Vec, Vec, Vec) { - let length = rho.len()/&self.spin_channel; - let mut exc = vec![0.0; length]; - let mut vrho = vec![0.0; length*&self.spin_channel]; - let mut vsigma = if self.spin_channel == 1 { - vec![0.0; length] - } else { - vec![0.0; length*3] - }; - unsafe{ - ffi_xc::xc_gga_exc_vxc( - self.xc_func_type, - length as u64, - rho.as_ptr(), - sigma.as_ptr(), - exc.as_mut_ptr(), - vrho.as_mut_ptr(), - vsigma.as_mut_ptr() - ); - } - // println!("Debug: In gga_exc_vxc exc: {:?}", &exc); - (exc,vrho,vsigma) + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + let (buf, layout) = self.inner.compute_lda(&input, 1).unwrap(); + let exc = buf[layout.get("zk").unwrap()].to_vec(); + let vrho = buf[layout.get("vrho").unwrap()].to_vec(); + (exc, vrho) } - pub fn mgga_exc_vxc(&self, rho: &[f64], sigma: &[f64], lapl: &[f64], tau: &[f64]) -> (Vec, Vec, Vec, Vec, Vec) { - let length = rho.len() / &self.spin_channel; - let mut exc = vec![0.0; length]; - let mut vrho = vec![0.0; length * &self.spin_channel]; - let mut vsigma = if self.spin_channel == 1 { - vec![0.0; length] - } else { - vec![0.0; length*3] - }; - let mut vtau = vec![0.0; length * &self.spin_channel]; - let mut vlapl = vec![0.0; length * &self.spin_channel]; - unsafe{ - ffi_xc::xc_mgga_exc_vxc( - self.xc_func_type, - length as u64, - rho.as_ptr(), - sigma.as_ptr(), - lapl.as_ptr(), - tau.as_ptr(), - exc.as_mut_ptr(), - vrho.as_mut_ptr(), - vsigma.as_mut_ptr(), - vlapl.as_mut_ptr(), - vtau.as_mut_ptr() - ); + pub fn gga_exc_vxc(&self, rho: &[f64], sigma: &[f64]) -> (Vec, Vec, Vec) { + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + input.insert("sigma".to_string(), sigma); + let (buf, layout) = self.inner.compute_gga(&input, 1).unwrap(); + let exc = buf[layout.get("zk").unwrap()].to_vec(); + let vrho = buf[layout.get("vrho").unwrap()].to_vec(); + let vsigma = buf[layout.get("vsigma").unwrap()].to_vec(); + (exc, vrho, vsigma) + } + + pub fn mgga_exc_vxc( + &self, + rho: &[f64], + sigma: &[f64], + _lapl: &[f64], + tau: &[f64], + ) -> (Vec, Vec, Vec, Vec, Vec) { + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + input.insert("sigma".to_string(), sigma); + if self.inner.needs_laplacian() { + input.insert("lapl".to_string(), _lapl); } - (exc,vrho,vsigma,vlapl,vtau) + input.insert("tau".to_string(), tau); + let (buf, layout) = self.inner.compute_mgga(&input, 1).unwrap(); + let exc = buf[layout.get("zk").unwrap()].to_vec(); + let vrho = buf[layout.get("vrho").unwrap()].to_vec(); + let vsigma = buf[layout.get("vsigma").unwrap()].to_vec(); + let vlapl = layout + .get("vlapl") + .map(|r| buf[r].to_vec()) + .unwrap_or_default(); + let vtau = buf[layout.get("vtau").unwrap()].to_vec(); + (exc, vrho, vsigma, vlapl, vtau) } - // xc_func_info relevant functions: pub fn get_family_name_std(family_id: u32) -> String { - if family_id == ffi_xc::XC_FAMILY_LDA { - "LDA".to_string() - } else if family_id == ffi_xc::XC_FAMILY_GGA { - "GGA".to_string() - } else if family_id == ffi_xc::XC_FAMILY_MGGA { - "MGGA".to_string() - } else if family_id == ffi_xc::XC_FAMILY_HYB_GGA { - "Hybrid GGA".to_string() - } else if family_id == ffi_xc::XC_FAMILY_HYB_MGGA { - "Hybrid MGGA".to_string() - } else { - "Unknown".to_string() - } - } - - pub fn get_family_id(xc_info: *const xc_func_info_type) -> u32 { - unsafe {ffi_xc::xc_func_info_get_family(xc_info) as u32} - } - pub fn get_family_enum(xc_info: *const xc_func_info_type) -> LibXCFamily { - let family_id = XcFuncType::get_family_id(xc_info); - if family_id == ffi_xc::XC_FAMILY_LDA { - LibXCFamily::LDA - } else if family_id == ffi_xc::XC_FAMILY_GGA { - LibXCFamily::GGA - } else if family_id == ffi_xc::XC_FAMILY_MGGA { - LibXCFamily::MGGA - } else if family_id == ffi_xc::XC_FAMILY_HYB_GGA { - LibXCFamily::HybridGGA - } else if family_id == ffi_xc::XC_FAMILY_HYB_MGGA { - LibXCFamily::HybridMGGA - } else { - LibXCFamily::Unknown + match family_id { + 1 => "LDA".to_string(), + 2 => "GGA".to_string(), + 4 => "MGGA".to_string(), + 32 => "Hybrid GGA".to_string(), + 64 => "Hybrid MGGA".to_string(), + _ => "Unknown".to_string(), } } - pub fn get_libxc_family(&self) -> LibXCFamily { - self.xc_func_family.clone() - } - - pub fn get_libxc_references(&self) -> Vec { - let mut references = Vec::new(); - for i in 0..5 { - unsafe { - let c_ref = ffi_xc::xc_func_info_get_references(self.xc_func_info_type, i); - if c_ref != std::ptr::null() { - let x_ref = { - let c_buf = ffi_xc::xc_func_reference_get_ref(c_ref); - let c_str = CStr::from_ptr(c_buf); - let str_slice = c_str.to_str().unwrap_or_default(); - str_slice.to_owned() - }; - // println!("Reference {}: {}", i, x_ref); - references.push(x_ref); - } else { - break; - } - } - } - references - } - - pub fn printout_family_name_ref(xc_info: *const xc_func_info_type, x_or_c: &str) { - let xc_family = { - let tmp_i: u32 = XcFuncType::get_family_id(xc_info); - XcFuncType::get_family_name_std(tmp_i) - }; - let xc_name = unsafe { - let c_buf = ffi_xc::xc_func_info_get_name(xc_info); - let c_str = CStr::from_ptr(c_buf); - let str_slice = c_str.to_str().unwrap(); - str_slice.to_owned() - }; - println!("The {} functional '{}' belongs to the '{}' family and is defined in the reference(s):",x_or_c,xc_name,xc_family); - (0..5).for_each(|i| unsafe{ - let c_ref = ffi_xc::xc_func_info_get_references(xc_info, i); - if c_ref != std::ptr::null() { - let x_ref = { - let c_buf = ffi_xc::xc_func_reference_get_ref(c_ref); - let c_str = CStr::from_ptr(c_buf); - let str_slice = c_str.to_str().unwrap_or_default(); - str_slice.to_owned() - }; - println!("({}): {}",i,x_ref); - }; - }); - } - pub fn xc_func_info_printout(&self) { - //let x_or_c = ["exchange-correlation","exchange","correlation"]; - //self.xc_func_info_type.iter().zip(x_or_c.iter()).for_each(|(xc_func_info_type,x_or_c)| { - // if let Some(xc_info) = xc_func_info_type { - // XcFuncType::printout_family_name_ref(*xc_info, *x_or_c); - // } - //}); - let functype = "density"; - XcFuncType::printout_family_name_ref(self.xc_func_info_type, functype); + pub fn get_libxc_spin(&self) -> usize { + self.inner.spin() as usize } } +pub fn eval_libxc_func_new( + xc_func: &XcFuncType, + spin: usize, + deriv: usize, + np: usize, + rho: &[f64], + sigma: Option<&[f64]>, + lapl: Option<&[f64]>, + tau: Option<&[f64]>, + exc: &mut [f64], +) { + assert!(deriv <= 3, "Derivative order must be 0, 1, 2 or 3"); -struct SliceSplitter<'a> { - data: &'a mut [f64], - offset: usize, -} - -impl<'a> SliceSplitter<'a> { - fn new(data: &'a mut [f64]) -> Self { - Self { data, offset: 0 } - } - - fn take(&mut self, len:usize) -> &'a mut [f64] { - if len == 0 { - return &mut []; - } - if self.offset + len > self.data.len() { - panic!("SliceSplitter: Attempt to take more elements than available in the slice, buffer overflow!"); + let spin_enum = if spin == 0 { + LibXCSpin::Unpolarized + } else { + LibXCSpin::Polarized + }; + + // Build input map + let mut input: HashMap = HashMap::new(); + input.insert("rho".to_string(), rho); + if let Some(s) = sigma { + input.insert("sigma".to_string(), s); + } + if let Some(l) = lapl { + if xc_func.inner.needs_laplacian() { + input.insert("lapl".to_string(), l); } - let ptr = self.data.as_mut_ptr(); - let slice = unsafe { - slice::from_raw_parts_mut(ptr.add(self.offset), len) - }; - self.offset += len; - slice } - - fn current_offset(&self) -> usize { - self.offset + if let Some(t) = tau { + input.insert("tau".to_string(), t); } -} -fn as_mut_ptr_or_null(slice: &mut [T]) -> *mut T { - if slice.is_empty() { - std::ptr::null_mut() - } else { - slice.as_mut_ptr() - } + // Use compute_xc_with_unsliced_output to write directly into `exc` + xc_func + .inner + .compute_xc_with_unsliced_output(&input, exc, deriv) + .unwrap(); } -pub fn eval_libxc_func_new(xc_func: &XcFuncType, spin: usize, deriv: usize, np: usize, rho: &[f64], sigma: Option<&[f64]>, lapl: Option<&[f64]>, tau: Option<&[f64]>, exc: &mut [f64]) { - assert!(deriv <= 3, "Derivative order must be 0, 1, 2 or 3"); - let mut splitter = SliceSplitter::new(exc); - let zk = splitter.take(np); // exc - - // unsafe {println!("Debug: In eval_libxc_func_new xc_func_type: {:?}", *xc_func.xc_func_type);} - - match xc_func.xc_func_family { - // leave fourth order terms as null pointers, currently not supported - LibXCFamily::LDA => { - let (vrho, v2rho2, v3rho3) = if spin == 1 { - ( - if deriv > 0 { splitter.take(np*2) } else {&mut []}, - if deriv > 1 { splitter.take(np*3) } else {&mut []}, - if deriv > 2 { splitter.take(np*4) } else {&mut []}, - ) - } else { - ( - if deriv > 0 { splitter.take(np) } else {&mut []}, - if deriv > 1 { splitter.take(np) } else {&mut []}, - if deriv > 2 { splitter.take(np) } else {&mut []}, - ) - }; - // println!("debug vrho length: {}", vrho.len()); - unsafe { - ffi_xc::xc_lda( - xc_func.xc_func_type, - np as u64, - rho.as_ptr(), - zk.as_mut_ptr(), - as_mut_ptr_or_null(vrho), - as_mut_ptr_or_null(v2rho2), - as_mut_ptr_or_null(v3rho3), - std::ptr::null_mut(), // v4rho4 - ); - } - }, - - LibXCFamily::GGA | LibXCFamily::HybridGGA => { - let ( - vrho, vsigma, v2rho2, v2rhosigma, v2sigma2, - v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3 - ) = if spin == 1 { - ( - if deriv > 0 { splitter.take(np*2) } else {&mut []}, - if deriv > 0 { splitter.take(np*3) } else {&mut []}, - if deriv > 1 { splitter.take(np*3) } else {&mut []}, // v2rho2 - if deriv > 1 { splitter.take(np*6) } else {&mut []}, // v2rhosigma - if deriv > 1 { splitter.take(np*6) } else {&mut []}, // v2sigma2 - if deriv > 2 { splitter.take(np*4) } else {&mut []}, // v3rho3 - if deriv > 2 { splitter.take(np*9) } else {&mut []}, // v3rho2sigma - if deriv > 2 { splitter.take(np*12) } else {&mut []}, // v3rhosigma2 - if deriv > 2 { splitter.take(np*10) } else {&mut []}, // v3sigma3 - ) - } else { - ( - if deriv > 0 { splitter.take(np) } else {&mut []}, - if deriv > 0 { splitter.take(np) } else {&mut []}, - if deriv > 1 { splitter.take(np) } else {&mut []}, // v2rho2 - if deriv > 1 { splitter.take(np) } else {&mut []}, // v2rhosigma - if deriv > 1 { splitter.take(np) } else {&mut []}, // v2sigma2 - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3rho3 - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3rho2sigma - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3rhosigma2 - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3sigma3 - ) - }; - unsafe { - ffi_xc::xc_gga( - xc_func.xc_func_type, - np as u64, - rho.as_ptr(), - sigma.unwrap().as_ptr(), - zk.as_mut_ptr(), - as_mut_ptr_or_null(vrho), - as_mut_ptr_or_null(vsigma), - as_mut_ptr_or_null(v2rho2), - as_mut_ptr_or_null(v2rhosigma), - as_mut_ptr_or_null(v2sigma2), - as_mut_ptr_or_null(v3rho3), - as_mut_ptr_or_null(v3rho2sigma), - as_mut_ptr_or_null(v3rhosigma2), - as_mut_ptr_or_null(v3sigma3), - std::ptr::null_mut(), // v4rho4 - std::ptr::null_mut(), // v4rho3sigma - std::ptr::null_mut(), // v4rho2sigma2 - std::ptr::null_mut(), // v4rhosigma3 - std::ptr::null_mut(), // v4sigma4 - ); - } - // if deriv > 0 { - // println!("Debug: In libxc_eval_xc exc: {:?}", zk); - // println!("Debug: In libxc_eval_xc vrho: {:?}", vrho); - // println!("Debug: In libxc_eval_xc vsigma: {:?}", vsigma); - // } - }, - // Currently, laplacian is not provided, so we set those quantities to empty - LibXCFamily::MGGA | LibXCFamily::HybridMGGA => { - let (vrho, vsigma, vtau) = if spin == 1 { - ( - if deriv > 0 { splitter.take(np*2) } else {&mut []}, - if deriv > 0 { splitter.take(np*3) } else {&mut []}, - if deriv > 0 { splitter.take(np*2) } else {&mut []}, - - ) - } else { - ( - if deriv > 0 { splitter.take(np) } else {&mut []}, - if deriv > 0 { splitter.take(np) } else {&mut []}, - if deriv > 0 { splitter.take(np) } else {&mut []}, - ) - }; - - - let (v2rho2, v2rhosigma, v2sigma2, v2rhotau, v2sigmatau, v2tau2) = if spin == 1 { - ( - if deriv > 1 { splitter.take(np*3) } else {&mut []}, // v2rho2 - if deriv > 1 { splitter.take(np*6) } else {&mut []}, // v2rhosigma - if deriv > 1 { splitter.take(np*6) } else {&mut []}, // v2sigma2 - if deriv > 1 { splitter.take(np*4) } else {&mut []}, // v2rhotau - if deriv > 1 { splitter.take(np*6) } else {&mut []}, // v2sigmatau - if deriv > 1 { splitter.take(np*3) } else {&mut []}, // v2tau2 - ) - } else { - ( - if deriv > 1 { splitter.take(np) } else {&mut []}, // v2rho2 - if deriv > 1 { splitter.take(np) } else {&mut []}, // v2rhosigma - if deriv > 1 { splitter.take(np) } else {&mut []}, // v2sigma2 - if deriv > 1 { splitter.take(np) } else {&mut []}, // v2rhotau - if deriv > 1 { splitter.take(np) } else {&mut []}, // v2sigmatau - if deriv > 1 { splitter.take(np) } else {&mut []}, // v2tau2 - ) - }; - let ( - v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3, - v3rho2tau, v3rhosigmatau, v3rhotau2, - v3sigma2tau, v3sigmatau2, v3tau3 - ) = if spin == 1 { - ( - if deriv > 2 { splitter.take(np*4) } else {&mut []}, // v3rho3 - if deriv > 2 { splitter.take(np*9) } else {&mut []}, // v3rho2sigma - if deriv > 2 { splitter.take(np*12) } else {&mut []}, // v3rhosigma2 - if deriv > 2 { splitter.take(np*10) } else {&mut []}, // v3sigma3 - if deriv > 2 { splitter.take(np*6) } else {&mut []}, // v3rho2tau - if deriv > 2 { splitter.take(np*12) } else {&mut []}, // v3rhosigmatau - if deriv > 2 { splitter.take(np*6) } else {&mut []}, // v3rhotau2 - if deriv > 2 { splitter.take(np*12) } else {&mut []}, // v3sigma2tau - if deriv > 2 { splitter.take(np*9) } else {&mut []}, // v3sigmatau2 - if deriv > 2 { splitter.take(np*4) } else {&mut []}, // v3tau3 - ) - } else { - ( - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3rho3 - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3rho2sigma - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3rhosigma2 - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3sigma3 - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3rho2tau - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3rhosigmatau - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3rhotau2 - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3sigma2tau - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3sigmatau2 - if deriv > 2 { splitter.take(np) } else {&mut []}, // v3tau3 - ) - }; - unsafe { - ffi_xc::xc_mgga( - xc_func.xc_func_type, - np as u64, - rho.as_ptr(), - sigma.unwrap().as_ptr(), - std::ptr::null(), // laplacian is not provided - tau.unwrap().as_ptr(), - zk.as_mut_ptr(), - as_mut_ptr_or_null(vrho), - as_mut_ptr_or_null(vsigma), - std::ptr::null_mut(), // vlapl - as_mut_ptr_or_null(vtau), - as_mut_ptr_or_null(v2rho2), - as_mut_ptr_or_null(v2rhosigma), - std::ptr::null_mut(), // v2rholapl - as_mut_ptr_or_null(v2rhotau), - as_mut_ptr_or_null(v2sigma2), - std::ptr::null_mut(), // v2sigmalapl - as_mut_ptr_or_null(v2sigmatau), - std::ptr::null_mut(), // v2lapl2 - std::ptr::null_mut(), // v2lapltau - as_mut_ptr_or_null(v2tau2), - as_mut_ptr_or_null(v3rho3), - as_mut_ptr_or_null(v3rho2sigma), - std::ptr::null_mut(), // v3rho2lapl - as_mut_ptr_or_null(v3rho2tau), - as_mut_ptr_or_null(v3rhosigma2), - std::ptr::null_mut(), // v3rhosigmalapl - as_mut_ptr_or_null(v3rhosigmatau), - std::ptr::null_mut(), // v3rholapl2 - std::ptr::null_mut(), // v3rholapltau - as_mut_ptr_or_null(v3rhotau2), - as_mut_ptr_or_null(v3sigma3), - std::ptr::null_mut(), // v3sigma2lapl - as_mut_ptr_or_null(v3sigma2tau), - std::ptr::null_mut(), // v3sigmalapl2 - std::ptr::null_mut(), // v3sigmalapltau - as_mut_ptr_or_null(v3sigmatau2), - std::ptr::null_mut(), // v3lapl3 - std::ptr::null_mut(), // v3lapl2tau - std::ptr::null_mut(), // v3lapltau2 - as_mut_ptr_or_null(v3tau3), - std::ptr::null_mut(), // v4rho4 - std::ptr::null_mut(), // v4rho3sigma - std::ptr::null_mut(), // v4rho3lapl - std::ptr::null_mut(), // v4rho3tau - std::ptr::null_mut(), // v4rho2sigma2 - std::ptr::null_mut(), // v4rho2sigmalapl - std::ptr::null_mut(), // v4rho2sigmatau - std::ptr::null_mut(), // v4rho2lapl2 - std::ptr::null_mut(), // v4rho2lapltau - std::ptr::null_mut(), // v4rho2tau2 - std::ptr::null_mut(), // v4rhosigma3 - std::ptr::null_mut(), // v4rhosigma2lapl - std::ptr::null_mut(), // v4rhosigma2tau - std::ptr::null_mut(), // v4rhosigmalapl2 - std::ptr::null_mut(), // v4rhosigmalapltau - std::ptr::null_mut(), // v4rhosigmatau2 - std::ptr::null_mut(), // v4rholapl3 - std::ptr::null_mut(), // v4rholapl2tau - std::ptr::null_mut(), // v4rholapltau2 - std::ptr::null_mut(), // v4rhotau3 - std::ptr::null_mut(), // v4sigma4 - std::ptr::null_mut(), // v4sigma3lapl - std::ptr::null_mut(), // v4sigma3tau - std::ptr::null_mut(), // v4sigma2lapl2 - std::ptr::null_mut(), // v4sigma2lapltau - std::ptr::null_mut(), // v4sigma2tau2 - std::ptr::null_mut(), // v4sigmalapl3 - std::ptr::null_mut(), // v4sigmalapl2tau - std::ptr::null_mut(), // v4sigmalapltau2 - std::ptr::null_mut(), // v4sigmatau3 - std::ptr::null_mut(), // v4lapl4 - std::ptr::null_mut(), // v4lapl3tau - std::ptr::null_mut(), // v4lapl2tau2 - std::ptr::null_mut(), // v4lapltau3 - std::ptr::null_mut(), // v4tau4 - ); - } - }, - - _ => { - panic!("Unsupported functional family: {:?}", xc_func.xc_func_family); - }, - - } - +pub fn eval_libxc_func( + xc_func: &XcFuncType, + spin: usize, + deriv: usize, + np: usize, + rho: &[f64], + sigma: Option<&[f64]>, + lapl: Option<&[f64]>, + tau: Option<&[f64]>, + exc: &mut [f64], +) { + eval_libxc_func_new(xc_func, spin, deriv, np, rho, sigma, lapl, tau, exc) } +/// Name-to-value map for libxc functional constants, compatible with old `names_and_values::MAP`. +pub mod names_and_values { + use super::*; -pub fn eval_libxc_func(xc_func: &XcFuncType, spin: usize, deriv: usize, np: usize, rho: &[f64], sigma: Option<&[f64]>, lapl: Option<&[f64]>, tau: Option<&[f64]>, exc: &mut [f64]) { - /* - Help function to evaluate xc tensor (currently up to 3rd derivative order) for a given libxc functional type. - Args: - xc_func: &XcFuncType - libxc functional type - spin: usize - number of spin (0 for unpolarized, 1 for polarized) - deriv: usize - derivative order (0 for 0th, 1 for 1st, 2 for 2nd, 3 for 3rd) - np: usize - number of grid points - rho: &[f64] - density array, size of (spin+1)*np - sigma: Option<&[f64]> - density gradient array, size of np for spin=0, 3*np for spin=1 (optional, for GGA and higher) - lapl: Option<&[f64]> - laplacian array, size of (spin+1)*np (optional, for MGGA, currently not used) - tau: Option<&[f64]> - kinetic energy density array, size of (spin+1)*np (optional, for MGGA) - exc: &mut [f64] - output vector for exchange-correlation tensor, size of (nvar + 1)*np, 1 for xc energy density (deriv = 0), nvar refers to number of density derivartives variables depends on functional type and derviative order - */ - assert!(deriv <= 3, "Derivative order must be 0, 1, 2 or 3"); - - // xc derivative variables - // 1st order - let mut vrho: Option<&[f64]> = None; - let mut vsigma: Option<&[f64]> = None; - let mut vlapl: Option<&[f64]> = None; - let mut vtau: Option<&[f64]> = None; - // 2nd order - let mut v2rho2: Option<&[f64]> = None; - let mut v2rhosigma: Option<&[f64]> = None; - let mut v2sigma2: Option<&[f64]> = None; - let mut v2lapl2: Option<&[f64]> = None; - let mut v2tau2: Option<&[f64]> = None; - let mut v2rholapl: Option<&[f64]> = None; - let mut v2rhotau: Option<&[f64]> = None; - let mut v2sigmalapl: Option<&[f64]> = None; - let mut v2sigmatau: Option<&[f64]> = None; - let mut v2lapltau: Option<&[f64]> = None; - // 3rd order - let mut v3rho3: Option<&[f64]> = None; - let mut v3rho2sigma: Option<&[f64]> = None; - let mut v3rhosigma2: Option<&[f64]> = None; - let mut v3sigma3: Option<&[f64]> = None; - let mut v3rho2lapl: Option<&[f64]> = None; - let mut v3rho2tau: Option<&[f64]> = None; - let mut v3rhosigmalapl: Option<&[f64]> = None; - let mut v3rhosigmatau: Option<&[f64]> = None; - let mut v3rholapl2: Option<&[f64]> = None; - let mut v3rholapltau: Option<&[f64]> = None; - let mut v3rhotau2: Option<&[f64]> = None; - let mut v3sigma2lapl: Option<&[f64]> = None; - let mut v3sigma2tau: Option<&[f64]> = None; - let mut v3sigmalapl2: Option<&[f64]> = None; - let mut v3sigmalapltau: Option<&[f64]> = None; - let mut v3sigmatau2: Option<&[f64]> = None; - let mut v3lapl3: Option<&[f64]> = None; - let mut v3lapl2tau: Option<&[f64]> = None; - let mut v3lapltau2: Option<&[f64]> = None; - let mut v3tau3: Option<&[f64]> = None; - // 4th order - let mut v4rho4: Option<&[f64]> = None; - let mut v4rho3sigma: Option<&[f64]> = None; - let mut v4rho3lapl: Option<&[f64]> = None; - let mut v4rho3tau: Option<&[f64]> = None; - let mut v4rho2sigma2: Option<&[f64]> = None; - let mut v4rho2sigmalapl: Option<&[f64]> = None; - let mut v4rho2sigmatau: Option<&[f64]> = None; - let mut v4rho2lapl2: Option<&[f64]> = None; - let mut v4rho2lapltau: Option<&[f64]> = None; - let mut v4rho2tau2: Option<&[f64]> = None; - let mut v4rhosigma3: Option<&[f64]> = None; - let mut v4rhosigma2lapl: Option<&[f64]> = None; - let mut v4rhosigma2tau: Option<&[f64]> = None; - let mut v4rhosigmalapl2: Option<&[f64]> = None; - let mut v4rhosigmalapltau: Option<&[f64]> = None; - let mut v4rhosigmatau2: Option<&[f64]> = None; - let mut v4rholapl3: Option<&[f64]> = None; - let mut v4rholapl2tau: Option<&[f64]> = None; - let mut v4rholapltau2: Option<&[f64]> = None; - let mut v4rhotau3: Option<&[f64]> = None; - let mut v4sigma4: Option<&[f64]> = None; - let mut v4sigma3lapl: Option<&[f64]> = None; - let mut v4sigma3tau: Option<&[f64]> = None; - let mut v4sigma2lapl2: Option<&[f64]> = None; - let mut v4sigma2lapltau: Option<&[f64]> = None; - let mut v4sigma2tau2: Option<&[f64]> = None; - let mut v4sigmalapl3: Option<&[f64]> = None; - let mut v4sigmalapl2tau: Option<&[f64]> = None; - let mut v4sigmalapltau2: Option<&[f64]> = None; - let mut v4sigmatau3: Option<&[f64]> = None; - let mut v4lapl4: Option<&[f64]> = None; - let mut v4lapl3tau: Option<&[f64]> = None; - let mut v4lapl2tau2: Option<&[f64]> = None; - let mut v4lapltau3: Option<&[f64]> = None; - let mut v4tau4: Option<&[f64]> = None; - - - // println!("Debug: In eval_libxc_func, rho: {:?}", rho); - // if let Some(sigma) = sigma { - // println!("Debug: In eval_libxc_func, sigma: {:?}", sigma); - // } - - match xc_func.xc_func_family { - LibXCFamily::LDA => { - if spin == 1 { - if deriv > 0 { - vrho = Some(&exc[np..np*3]); - } - if deriv > 1 { - v2rho2 = Some(&exc[np*3..np*6]); - } - if deriv > 2 { - v3rho3 = Some(&exc[np*6..np*9]); - } - } else { - if deriv > 0 { - vrho = Some(&exc[np..np*2]); - } - if deriv > 1 { - v2rho2 = Some(&exc[np*2..np*3]); - } - if deriv > 2 { - v3rho3 = Some(&exc[np*3..np*4]); - } - } - unsafe { - ffi_xc::xc_lda( - xc_func.xc_func_type, - np as u64, - rho.as_ptr(), - exc.as_ptr() as *mut _, - vrho.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2rho2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rho3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho4.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - ); - } - // if deriv > 0 { - // println!("Debug: In libxc_eval_xc exc: {:?}", exc); - // println!("Debug: In libxc_eval_xc vrho: {:?}", vrho);; - // } - // if let Some(vrho) = vrho { - // println!("In eval_xc_func: vrho: {:?}", vrho); - // } - }, - - LibXCFamily::GGA | LibXCFamily::HybridGGA => { - if spin == 1 { - if deriv > 0 { - vrho = Some(&exc[np..np*3]); - vsigma = Some(&exc[np*3..np*6]); - } - if deriv > 1 { - v2rho2 = Some(&exc[np*6..np*9]); - v2rhosigma = Some(&exc[np*9..np*15]); - v2sigma2 = Some(&exc[np*15..np*21]); - } - if deriv > 2 { - v3rho3 = Some(&exc[np*21..np*25]); - v3rho2sigma = Some(&exc[np*25..np*34]); - v3rhosigma2 = Some(&exc[np*34..np*46]); - v3sigma3 = Some(&exc[np*34..np*44]); - } - } else { - if deriv > 0 { - vrho = Some(&exc[np..np*2]); - vsigma = Some(&exc[np*2..np*3]); - } - if deriv > 1 { - v2rho2 = Some(&exc[np*3..np*4]); - v2rhosigma = Some(&exc[np*4..np*5]); - v2sigma2 = Some(&exc[np*5..np*6]); - } - if deriv > 2 { - v3rho3 = Some(&exc[np*6..np*7]); - v3rho2sigma = Some(&exc[np*7..np*8]); - v3rhosigma2 = Some(&exc[np*8..np*9]); - v3sigma3 = Some(&exc[np*9..np*10]); - } - } - unsafe { - ffi_xc::xc_gga( - xc_func.xc_func_type, - np as u64, - rho.as_ptr(), - sigma.unwrap().as_ptr(), - exc.as_ptr() as *mut _, - vrho.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - vsigma.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2rho2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2rhosigma.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2sigma2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rho3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rho2sigma.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rhosigma2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3sigma3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho4.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho3sigma.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho2sigma2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rhosigma3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigma4.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - ); - } - // if deriv > 0 { - // println!("Debug: In libxc_eval_xc exc: {:?}", exc); - // println!("Debug: In libxc_eval_xc vrho: {:?}", vrho); - // println!("Debug: In libxc_eval_xc vsigma: {:?}", vsigma); - // } - }, - - LibXCFamily::MGGA | LibXCFamily::HybridMGGA => { - if spin == 1 { - if deriv > 0 { - vrho = Some(&exc[np..np*3]); - vsigma = Some(&exc[np*3..np*6]); - vtau = Some(&exc[np*9..np*11]); - } - if deriv > 1 { - v2rho2 = Some(&exc[np*11..np*14]); - v2rhosigma = Some(&exc[np*14..np*20]); - v2sigma2 = Some(&exc[np*20..np*26]); - v2rhotau = Some(&exc[np*26..np*30]); - v2sigmatau = Some(&exc[np*30..np*36]); - v2tau2 = Some(&exc[np*36..np*39]); - } - if deriv > 2 { - v3rho3 = Some(&exc[np*39..np*43]); - v3rho2sigma = Some(&exc[np*43..np*52]); - v3rhosigma2 = Some(&exc[np*52..np*64]); - v3sigma3 = Some(&exc[np*64..np*74]); - v3rho2tau = Some(&exc[np*74..np*80]); - v3rhosigmatau = Some(&exc[np*80..np*92]); - v3rhotau2 = Some(&exc[np*92..np*98]); - v3sigma2tau = Some(&exc[np*98..np*110]); - v3sigmatau2 = Some(&exc[np*110..np*119]); - v3tau3 = Some(&exc[np*119..np*123]); - } - } else { - if deriv > 0 { - vrho = Some(&exc[np..np*2]); - vsigma = Some(&exc[np*2..np*3]); - vtau = Some(&exc[np*3..np*4]); - } - if deriv > 1 { - v2rho2 = Some(&exc[np*4..np*5]); - v2rhosigma = Some(&exc[np*5..np*6]); - v2sigma2 = Some(&exc[np*6..np*7]); - v2rhotau = Some(&exc[np*7..np*8]); - v2sigmatau = Some(&exc[np*8..np*9]); - v2tau2 = Some(&exc[np*9..np*10]); - } - if deriv > 2 { - v3rho3 = Some(&exc[np*10..np*11]); - v3rho2sigma = Some(&exc[np*11..np*12]); - v3rhosigma2 = Some(&exc[np*12..np*13]); - v3sigma3 = Some(&exc[np*13..np*14]); - v3rho2tau = Some(&exc[np*14..np*15]); - v3rhosigmatau = Some(&exc[np*15..np*16]); - v3rhotau2 = Some(&exc[np*16..np*17]); - v3sigma2tau = Some(&exc[np*17..np*18]); - v3sigmatau2 = Some(&exc[np*18..np*19]); - v3tau3 = Some(&exc[np*19..np*20]); - } - } - unsafe { - ffi_xc::xc_mgga( - xc_func.xc_func_type, - np as u64, - rho.as_ptr(), - sigma.unwrap().as_ptr(), - std::ptr::null(), // laplacian is not used currently - tau.unwrap().as_ptr(), - exc.as_ptr() as *mut _, - vrho.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - vsigma.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - vlapl.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - vtau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2rho2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2rhosigma.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2rholapl.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2rhotau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2sigma2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2sigmalapl.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2sigmatau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2lapl2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2lapltau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v2tau2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rho3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rho2sigma.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rho2lapl.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rho2tau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rhosigma2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rhosigmalapl.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rhosigmatau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rholapl2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rholapltau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3rhotau2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3sigma3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3sigma2lapl.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3sigma2tau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3sigmalapl2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3sigmalapltau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3sigmatau2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3lapl3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3lapl2tau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3lapltau2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v3tau3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho4.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho3sigma.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho3lapl.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho3tau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho2sigma2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho2sigmalapl.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho2sigmatau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho2lapl2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho2lapltau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rho2tau2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rhosigma3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rhosigma2lapl.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rhosigma2tau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rhosigmalapl2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rhosigmalapltau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rhosigmatau2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rholapl3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rholapl2tau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rholapltau2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4rhotau3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigma4.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigma3lapl.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigma3tau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigma2lapl2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigma2lapltau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigma2tau2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigmalapl3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigmalapl2tau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigmalapltau2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4sigmatau3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4lapl4.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4lapl3tau.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4lapl2tau2.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4lapltau3.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _, - v4tau4.map_or(std::ptr::null(), |v| v.as_ptr()) as *mut _ - ); - } - }, - - _ => { - panic!("Unsupported functional family: {:?}", xc_func.xc_func_family); - }, - + lazy_static::lazy_static! { + pub static ref MAP: Vec<(String, usize)> = { + LIBXC_FUNC_MAP + .iter() + .map(|(name, value)| (format!("XC_{}", name), *value as usize)) + .collect() + }; } } - - -#[test] -fn test_libxc() { - let rho:Vec = vec![0.1,0.2,0.3,0.4,0.5,0.6,0.8]; - let sigma:Vec = vec![0.2,0.3,0.4,0.5,0.6,0.7]; - //let mut exc:Vec = vec![0.0,0.0,0.0,0.0,0.0]; - //let mut vrho:Vec = vec![0.0,0.0,0.0,0.0,0.0]; - let func_id: usize = ffi_xc::XC_GGA_X_XPBE as usize; - let spin_channel: usize = 1; - - let mut my_xc = XcFuncType::xc_func_init(1,spin_channel); - //let mut my_xc = XcFuncType::xc_func_init_fdqc(&"pw-lda",spin_channel); - - my_xc.xc_version(); - - my_xc.xc_func_info_printout(); - - let (exc, vrho) = my_xc.lda_exc_vxc(&rho); - - println!("{:?}", exc); - println!("{:?}", vrho); - - //let xc_info = my_xc.xc_func_get_info(); - - //let xc_name = unsafe { - // let c_buf = ffi_xc::xc_func_info_get_name(xc_info); - // let c_str = CStr::from_ptr(c_buf); - // let str_slice = c_str.to_str().unwrap(); - // str_slice.to_owned() - //}; - //println!("{}",xc_name); - - - //let xc_name = unsafe{String::from_raw_parts(xc_name, 10, 10)}; - - - - //println!("{:?}",my_xc.); - - //let (exc,vrho) = my_xc.xc_exc_vxc(&rho, &sigma).unwrap(); - - //println!("{:?}", exc.data); - //println!("{:?}", vrho.data); - - - //let mut p_xc_func_type = unsafe{ffi_xc::xc_func_alloc()}; - - //let init = unsafe{ffi_xc::xc_func_init(p_xc_func_type,func_id, ffi_xc::XC_UNPOLARIZED as c_int)}; - - //unsafe{ - // let c_exc = (exc.as_mut_ptr(),exc.len(),exc.capacity()); - // let c_vrho = (vrho.as_mut_ptr(),vrho.len(),vrho.capacity()); - // ffi_xc::xc_lda_exc_vxc(p_xc_func_type,5,rho.as_ptr(),c_exc.0,c_vrho.0); - // exc = Vec::from_raw_parts(c_exc.0,c_exc.1,c_exc.2); - // vrho = Vec::from_raw_parts(c_vrho.0,c_vrho.1,c_vrho.2); - //}; - //println!("{:?}", exc); - //println!("{:?}", vrho); - - //unsafe{ffi_xc::xc_func_end(p_xc_func_type)}; - - my_xc.xc_func_end() -} - diff --git a/src/dft/libxc_itrf.rs b/src/dft/libxc_itrf.rs index a72e4b16ca..730d5917d2 100644 --- a/src/dft/libxc_itrf.rs +++ b/src/dft/libxc_itrf.rs @@ -187,7 +187,7 @@ fn eval_xc1( .for_each( |(func_id, xc_param)| { - let mut xc_func = XcFuncType::xc_func_init(*func_id, spin+1); + let xc_func = XcFuncType::xc_func_init(*func_id, spin+1); let cur_xc_type = match xc_func.get_libxc_family() { LibXCFamily::LDA => XCType::LDA, LibXCFamily::GGA => XCType::GGA, @@ -199,7 +199,6 @@ fn eval_xc1( let mut outbuf = vec![0.0; np * n_components]; eval_libxc_func_new(&xc_func, spin, deriv, np, rho, sigma, lapl, tau, &mut outbuf); merge_xc(&mut output, &outbuf, *xc_param, cur_xc_type, spin, deriv, out_nvar, np); - xc_func.xc_func_end(); } ); diff --git a/src/dft/mod.rs b/src/dft/mod.rs index c55b5963a2..20319b4be3 100644 --- a/src/dft/mod.rs +++ b/src/dft/mod.rs @@ -32,7 +32,6 @@ use std::collections::HashMap; use std::fs::File; use std::io::Read; use std::ops::Range; -use std::os::raw::c_int; use std::sync::mpsc::channel; use serde::{Deserialize, Serialize}; @@ -40,6 +39,7 @@ use serde::{Deserialize, Serialize}; use libxc::{XcFuncType}; //use std::intrinsics::expf64; use crate::dft::libxc::names_and_values::MAP as libxc_names_values; +use crate::dft::libxc::LibXCFamily; use rest_tensors::matrix_blas_lapack::{omp_get_num_threads_wrapper, omp_set_num_threads_wrapper}; @@ -81,27 +81,27 @@ pub struct DFA4REST { } impl DFAFamily { - pub fn to_libxc_family(&self) -> libxc::LibXCFamily { + pub fn to_libxc_family(&self) -> LibXCFamily { match self { - DFAFamily::LDA => libxc::LibXCFamily::LDA, - DFAFamily::GGA => libxc::LibXCFamily::GGA, - DFAFamily::MGGA => libxc::LibXCFamily::MGGA, - DFAFamily::HybridGGA => libxc::LibXCFamily::HybridGGA, - DFAFamily::HybridMGGA => libxc::LibXCFamily::HybridMGGA, - DFAFamily::PT2 => libxc::LibXCFamily::HybridGGA, - DFAFamily::SBGE2 => libxc::LibXCFamily::HybridGGA, - DFAFamily::SCSRPA => libxc::LibXCFamily::HybridGGA, - DFAFamily::RPA => libxc::LibXCFamily::GGA, - _ => libxc::LibXCFamily::Unknown, + DFAFamily::LDA => LibXCFamily::LDA, + DFAFamily::GGA => LibXCFamily::GGA, + DFAFamily::MGGA => LibXCFamily::MGGA, + DFAFamily::HybridGGA => LibXCFamily::HybridGGA, + DFAFamily::HybridMGGA => LibXCFamily::HybridMGGA, + DFAFamily::PT2 => LibXCFamily::HybridGGA, + DFAFamily::SBGE2 => LibXCFamily::HybridGGA, + DFAFamily::SCSRPA => LibXCFamily::HybridGGA, + DFAFamily::RPA => LibXCFamily::GGA, + _ => LibXCFamily::Unknown, } } - pub fn from_libxc_family(family: &libxc::LibXCFamily) -> DFAFamily { + pub fn from_libxc_family(family: &LibXCFamily) -> DFAFamily { match family { - libxc::LibXCFamily::LDA => DFAFamily::LDA, - libxc::LibXCFamily::GGA => DFAFamily::GGA, - libxc::LibXCFamily::MGGA => DFAFamily::MGGA, - libxc::LibXCFamily::HybridGGA => DFAFamily::HybridGGA, - libxc::LibXCFamily::HybridMGGA => DFAFamily::HybridMGGA, + LibXCFamily::LDA => DFAFamily::LDA, + LibXCFamily::GGA => DFAFamily::GGA, + LibXCFamily::MGGA => DFAFamily::MGGA, + LibXCFamily::HybridGGA => DFAFamily::HybridGGA, + LibXCFamily::HybridMGGA => DFAFamily::HybridMGGA, _ => DFAFamily::Unknown, } } @@ -125,11 +125,8 @@ impl DFAFamily { impl DFA4REST { pub fn xc_version(&self) { - let mut vmajor:c_int = 0; - let mut vminor:c_int = 0; - let mut vmicro:c_int = 0; - unsafe{libxc::ffi_xc::xc_version(&mut vmajor, &mut vminor, &mut vmicro)}; - println!("Libxc version used in REST: {}.{}.{}", vmajor, vminor, vmicro); + let (major, minor, micro) = ::libxc::util::libxc_version(); + println!("Libxc version used in REST: {}.{}.{}", major, minor, micro); } @@ -410,7 +407,6 @@ impl DFA4REST { false => func.xc_hyb_exx_coeff(), true => { let (omega, alpha, beta) = func.xc_hyb_cam_coef(); - // for RSH, we consider the hybrid coeff as alpha + beta (matches pyscf) alpha + beta } }; @@ -431,7 +427,6 @@ impl DFA4REST { let func = XcFuncType::xc_func_init(*xc_func, spin_channel); if func.is_rsh() { let (omega, alpha, beta) = func.xc_hyb_cam_coef(); - // only if alpha and beta are both close to zero, we consider it as not range-separated (pure zero). if alpha.abs() < 1e-10 && beta.abs() < 1e-10 { continue; } @@ -1341,7 +1336,7 @@ impl DFA4REST { self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); match xc_func.xc_func_family { - libxc::LibXCFamily::LDA => { + LibXCFamily::LDA => { if spin_channel==1 { let (tmp_exc,tmp_vrho) = xc_func.lda_exc_vxc(rho.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); @@ -1358,7 +1353,7 @@ impl DFA4REST { vrho.par_self_scaled_add(&tmp_vrho.transpose_and_drop(),*xc_para); } }, - libxc::LibXCFamily::GGA | libxc::LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybridGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho, tmp_vsigma) = xc_func.gga_exc_vxc(rho.data_ref().unwrap(),sigma.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); @@ -1597,7 +1592,7 @@ impl DFA4REST { self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); match xc_func.xc_func_family { - libxc::LibXCFamily::LDA => { + LibXCFamily::LDA => { if spin_channel==1 { let (tmp_exc,tmp_vrho) = xc_func.lda_exc_vxc(loc_rho.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); @@ -1614,7 +1609,7 @@ impl DFA4REST { loc_vrho.self_scaled_add(&tmp_vrho.transpose_and_drop(),*xc_para); } }, - libxc::LibXCFamily::GGA | libxc::LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybridGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho, tmp_vsigma) = xc_func.gga_exc_vxc(loc_rho.data_ref().unwrap(),loc_sigma.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); @@ -1633,7 +1628,7 @@ impl DFA4REST { loc_vsigma.self_scaled_add(&tmp_vsigma.transpose_and_drop(), *xc_para); } }, - libxc::LibXCFamily::MGGA | libxc::LibXCFamily::HybridMGGA => { + LibXCFamily::MGGA | LibXCFamily::HybridMGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho,tmp_vsigma,tmp_valpl,tmp_vtau) = xc_func.mgga_exc_vxc( @@ -1932,7 +1927,7 @@ impl DFA4REST { self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); match xc_func.xc_func_family { - libxc::LibXCFamily::LDA => { + LibXCFamily::LDA => { if spin_channel==1 { let (tmp_exc,tmp_vrho) = xc_func.lda_exc_vxc(loc_rho.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); @@ -1949,7 +1944,7 @@ impl DFA4REST { loc_vrho.self_scaled_add(&tmp_vrho.transpose_and_drop(),*xc_para); } }, - libxc::LibXCFamily::GGA | libxc::LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybridGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho, tmp_vsigma) = xc_func.gga_exc_vxc(loc_rho.data_ref().unwrap(),loc_sigma.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); @@ -1968,7 +1963,7 @@ impl DFA4REST { loc_vsigma.self_scaled_add(&tmp_vsigma.transpose_and_drop(), *xc_para); } }, - libxc::LibXCFamily::MGGA | libxc::LibXCFamily::HybridMGGA => { + LibXCFamily::MGGA | LibXCFamily::HybridMGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho,tmp_vsigma,tmp_valpl,tmp_vtau) = xc_func.mgga_exc_vxc( @@ -2489,7 +2484,7 @@ impl DFA4REST { self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); match xc_func.xc_func_family { - libxc::LibXCFamily::LDA => { + LibXCFamily::LDA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { xc_func.lda_exc(rho.data_ref().unwrap()) @@ -2499,7 +2494,7 @@ impl DFA4REST { ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - libxc::LibXCFamily::GGA | libxc::LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybridGGA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { xc_func.gga_exc(rho.data_ref().unwrap(),sigma.data_ref().unwrap()) @@ -2509,7 +2504,7 @@ impl DFA4REST { ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - libxc::LibXCFamily::MGGA | libxc::LibXCFamily::HybridMGGA => { + LibXCFamily::MGGA | LibXCFamily::HybridMGGA => { let tmp_exc = MatrixFull::from_vec( [num_grids, 1], if spin_channel==1 { @@ -2528,7 +2523,7 @@ impl DFA4REST { dfa_compnt.iter().zip(dfa_paramr.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); match xc_func.xc_func_family { - libxc::LibXCFamily::LDA => { + LibXCFamily::LDA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { xc_func.lda_exc(rho.data_ref().unwrap()) @@ -2538,7 +2533,7 @@ impl DFA4REST { ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - libxc::LibXCFamily::GGA | libxc::LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybridGGA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { xc_func.gga_exc(rho.data_ref().unwrap(),sigma.data_ref().unwrap()) @@ -2587,7 +2582,7 @@ impl DFA4REST { let xc_func = self.init_libxc(xc_code); let num_grids = rho.size()[0]; let tmp_exc = match xc_func.xc_func_family { - libxc::LibXCFamily::LDA => { + LibXCFamily::LDA => { MatrixFull::from_vec([num_grids,1], if spin_channel==1 { xc_func.lda_exc(rho.data_ref().unwrap()) @@ -2597,7 +2592,7 @@ impl DFA4REST { ).unwrap() //exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - libxc::LibXCFamily::GGA | libxc::LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybridGGA => { //println!("debug, {:?}, {:?}, {:?}", xc_code, xc_func, sigma.data.len()); MatrixFull::from_vec([num_grids,1], if spin_channel==1 { diff --git a/src/dft/parse_xc/dispersion.rs b/src/dft/parse_xc/dispersion.rs index 83993f878d..93c14b7b0c 100644 --- a/src/dft/parse_xc/dispersion.rs +++ b/src/dft/parse_xc/dispersion.rs @@ -65,10 +65,8 @@ impl DFAComponent { pub fn is_nlc(&self) -> bool { match self.component_type { ComponentType::Libxc => { - let mut xcfunc = XcFuncType::xc_func_init(self.id, 1); - let is_nlc = xcfunc.is_nlc(); - xcfunc.xc_func_end(); - is_nlc + let xcfunc = XcFuncType::xc_func_init(self.id, 1); + xcfunc.is_nlc() }, _ => false, } diff --git a/src/dft/parse_xc/parse.rs b/src/dft/parse_xc/parse.rs index 64a7362500..f1c4090779 100644 --- a/src/dft/parse_xc/parse.rs +++ b/src/dft/parse_xc/parse.rs @@ -187,7 +187,7 @@ impl DFAComponent { if self.component_type == ComponentType::HF { return self.factor; } else if self.component_type == ComponentType::Libxc { - let mut xcfunc = XcFuncType::xc_func_init(self.id, spin_channel); + let xcfunc = XcFuncType::xc_func_init(self.id, spin_channel); let hybrid_coef = match xcfunc.is_rsh() { false => xcfunc.get_hybrid(), true => { @@ -196,7 +196,6 @@ impl DFAComponent { }, }; let hyb = self.factor * hybrid_coef; - xcfunc.xc_func_end(); return hyb; } else { return 0.0; @@ -206,10 +205,8 @@ impl DFAComponent { pub fn is_rsh(&self) -> bool { match self.component_type { ComponentType::Libxc => { - let mut xcfunc = XcFuncType::xc_func_init(self.id, 1); - let is_rsh = xcfunc.is_rsh(); - xcfunc.xc_func_end(); - is_rsh + let xcfunc = XcFuncType::xc_func_init(self.id, 1); + xcfunc.is_rsh() }, _ => false, } @@ -218,10 +215,8 @@ impl DFAComponent { pub fn use_laplacian(&self) -> bool { match self.component_type { ComponentType::Libxc => { - let mut xcfunc = XcFuncType::xc_func_init(self.id, 1); - let use_laplacian = xcfunc.use_laplacian(); - xcfunc.xc_func_end(); - use_laplacian + let xcfunc = XcFuncType::xc_func_init(self.id, 1); + xcfunc.use_laplacian() }, _ => false, } @@ -229,10 +224,8 @@ impl DFAComponent { pub fn get_reference(&self) -> Vec { if self.component_type == ComponentType::Libxc && self.id != 0 { - let mut xcfunc = XcFuncType::xc_func_init(self.id, 1); - let reference = xcfunc.get_libxc_references(); - xcfunc.xc_func_end(); - return reference; + let xcfunc = XcFuncType::xc_func_init(self.id, 1); + return xcfunc.get_libxc_references(); } else { return Vec::new(); } @@ -551,7 +544,7 @@ impl DFAdef { if let Some(components) = &self.xc_scf { for comp in components.iter() { if comp.is_rsh() { - let mut xcfunc = XcFuncType::xc_func_init(comp.id, spin_channel); + let xcfunc = XcFuncType::xc_func_init(comp.id, spin_channel); let (omega, alpha, beta) = xcfunc.xc_hyb_cam_coef(); // only if alpha and beta are both close to zero, we consider it as not range-separated (pure zero). if alpha.abs() < 1e-10 && beta.abs() < 1e-10 { @@ -560,7 +553,6 @@ impl DFAdef { if result.is_some() { panic!("Multiple RSH functionals are specified in the DFA components for SCF. Currently this is not supported."); } - xcfunc.xc_func_end(); result = Some((omega, alpha, beta)); } } diff --git a/src/dft/parse_xc/xc_helper.rs b/src/dft/parse_xc/xc_helper.rs index 634b90f63e..e7fd94674a 100644 --- a/src/dft/parse_xc/xc_helper.rs +++ b/src/dft/parse_xc/xc_helper.rs @@ -1,7 +1,5 @@ -use crate::dft::libxc; use lazy_static::lazy_static; use std::collections::HashMap; -use std::ffi; use serde_json; use crate::dft::DFAFamily; @@ -247,30 +245,19 @@ pub fn get_name_with_dash() -> HashMap { } pub fn get_name(id: usize) -> String { - let name = unsafe{ - let c_str = ffi::CStr::from_ptr(libxc::ffi_xc::xc_functional_get_name(id as i32)); - c_str.to_str().unwrap().to_owned() - }; + let name = ::libxc::util::libxc_functional_get_name(id as i32) + .unwrap_or_default(); name.to_uppercase() } pub fn get_available_functionals() -> HashMap { - let n = unsafe{libxc::ffi_xc::xc_number_of_functionals()}; - // println!("Number of functionals in libxc: {}", n); - let mut ids:Vec = vec![0; n as usize]; - unsafe{ - libxc::ffi_xc::xc_available_functional_numbers(ids.as_mut_ptr()); - } - // println!("{:?}", ids); + let ids = ::libxc::util::libxc_available_functional_numbers(); let mut available_functionals = HashMap::new(); for id in ids { - let name = unsafe{ - let c_str = ffi::CStr::from_ptr(libxc::ffi_xc::xc_functional_get_name(id)); - c_str.to_str().unwrap().to_owned() - }; + let name = ::libxc::util::libxc_functional_get_name(id) + .unwrap_or_default(); available_functionals.insert(name.to_uppercase(), id as usize); } - // println!("Available functionals: {:?}", available_functionals); available_functionals } -- Gitee From 92588abf60c5f0761d5db3385349f55bf55b78be Mon Sep 17 00:00:00 2001 From: ajz34 Date: Sat, 16 May 2026 08:50:21 +0800 Subject: [PATCH 03/10] Remove libxc wrapper module, use external crate directly via libxc_helper.rs Eliminates the `dft/libxc/` wrapper module (XcFuncType, FFI bindings, name maps) in favor of using the external `libxc` crate directly. REST-specific logic (xc_code_fdqc, LibXCFamily compat enum, compute helpers) is moved to a minimal `libxc_helper.rs` with free functions taking `&LibXCFunctional`. Co-Authored-By: Claude Opus 4.7 Co-Authored-By: glm-5 --- src/dft/libxc/mod.rs | 362 --------------------------------- src/dft/libxc_helper.rs | 345 +++++++++++++++++++++++++++++++ src/dft/libxc_itrf.rs | 8 +- src/dft/mod.rs | 254 +++++++---------------- src/dft/parse_xc/dispersion.rs | 6 +- src/dft/parse_xc/parse.rs | 43 ++-- 6 files changed, 445 insertions(+), 573 deletions(-) delete mode 100644 src/dft/libxc/mod.rs create mode 100644 src/dft/libxc_helper.rs diff --git a/src/dft/libxc/mod.rs b/src/dft/libxc/mod.rs deleted file mode 100644 index fc10e8a682..0000000000 --- a/src/dft/libxc/mod.rs +++ /dev/null @@ -1,362 +0,0 @@ -use std::collections::HashMap; - -use ::libxc::prelude::*; - -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum LibXCFamily { - LDA, - GGA, - MGGA, - HybridGGA, - HybridMGGA, - Unknown, -} - -impl LibXCFamily { - fn from_libxc(family: ::libxc::enums::LibXCFamily) -> Self { - match family { - ::libxc::enums::LibXCFamily::LDA | ::libxc::enums::LibXCFamily::HybLDA => LibXCFamily::LDA, - ::libxc::enums::LibXCFamily::GGA => LibXCFamily::GGA, - ::libxc::enums::LibXCFamily::MGGA => LibXCFamily::MGGA, - ::libxc::enums::LibXCFamily::HybGGA => LibXCFamily::HybridGGA, - ::libxc::enums::LibXCFamily::HybMGGA => LibXCFamily::HybridMGGA, - _ => LibXCFamily::Unknown, - } - } -} - -#[derive(Debug)] -pub struct XcFuncType { - inner: LibXCFunctional, - pub xc_func_family: LibXCFamily, -} - -impl XcFuncType { - pub fn xc_func_init(func_id: usize, spin_channel: usize) -> XcFuncType { - let spin = if spin_channel == 1 { - LibXCSpin::Unpolarized - } else { - LibXCSpin::Polarized - }; - let inner = LibXCFunctional::from_number(func_id as i32, spin); - let xc_func_family = LibXCFamily::from_libxc(inner.family()); - XcFuncType { - inner, - xc_func_family, - } - } - - pub fn xc_func_end(&mut self) { - // No-op: Drop handles cleanup automatically - } - - pub fn xc_version(&self) { - let (major, minor, micro) = ::libxc::util::libxc_version(); - println!("Libxc version: {}.{}.{}", major, minor, micro); - } - - pub fn is_rsh(&self) -> bool { - self.inner.is_hyb_cam() - } - - pub fn xc_hyb_cam_coef(&self) -> (f64, f64, f64) { - self.inner.cam_coef().unwrap_or((0.0, 0.0, 0.0)) - } - - pub fn xc_hyb_exx_coeff(&self) -> f64 { - self.inner.hyb_exx_coef().unwrap_or(0.0) - } - - pub fn is_nlc(&self) -> bool { - self.inner.flags().contains(LibXCFlags::VV10) - } - - pub fn use_laplacian(&self) -> bool { - self.inner.needs_laplacian() - } - - pub fn use_density_gradient(&self) -> bool { - !matches!(self.xc_func_family, LibXCFamily::LDA) - } - - pub fn use_kinetic_density(&self) -> bool { - matches!( - self.xc_func_family, - LibXCFamily::MGGA | LibXCFamily::HybridMGGA - ) - } - - pub fn use_exact_exchange(&self) -> bool { - matches!( - self.xc_func_family, - LibXCFamily::HybridGGA | LibXCFamily::HybridMGGA - ) - } - - pub fn is_lda(&self) -> bool { - matches!(self.xc_func_family, LibXCFamily::LDA) - } - - pub fn is_gga(&self) -> bool { - matches!(self.xc_func_family, LibXCFamily::GGA) - } - - pub fn is_mgga(&self) -> bool { - matches!(self.xc_func_family, LibXCFamily::MGGA) - } - - pub fn is_hybrid_gga(&self) -> bool { - matches!(self.xc_func_family, LibXCFamily::HybridGGA) - } - - pub fn is_hybrid_mgga(&self) -> bool { - matches!(self.xc_func_family, LibXCFamily::HybridMGGA) - } - - pub fn get_family_name(&self) -> String { - match self.xc_func_family { - LibXCFamily::LDA => "LDA".to_string(), - LibXCFamily::GGA => "GGA".to_string(), - LibXCFamily::MGGA => "MGGA".to_string(), - LibXCFamily::HybridGGA => "HybridGGA".to_string(), - LibXCFamily::HybridMGGA => "HybridMGGA".to_string(), - LibXCFamily::Unknown => "Unknown DFA".to_string(), - } - } - - pub fn get_libxc_family(&self) -> LibXCFamily { - self.xc_func_family.clone() // LibXCFamily derives Clone - } - - pub fn get_libxc_references(&self) -> Vec { - self.inner - .references() - .iter() - .map(|r| r.ref_text.clone()) - .collect() - } - - pub fn xc_func_info_printout(&self) { - println!("{}", self.inner.describe()); - } - - pub fn xc_code_fdqc(name: &str) -> (usize, usize, usize) { - let lower_name = name.to_lowercase(); - if lower_name.eq("hf") { - (0, 0, 0) - } else if lower_name.eq("svwn") { - (0, 1, 7) - } else if lower_name.eq("svwn-rpa") { - (0, 1, 8) - } else if lower_name.eq("pz-lda") { - (0, 1, 9) - } else if lower_name.eq("pw-lda") { - (0, 1, 12) - } else if lower_name.eq("blyp") { - (0, 106, 131) - } else if lower_name.eq("xlyp") { - (166, 0, 0) - } else if lower_name.eq("pbe") { - (0, 101, 130) - } else if lower_name.eq("xpbe") { - (0, 123, 136) - } else if lower_name.eq("scan") { - (0, 263, 267) - } else if lower_name.eq("revscan") { - (0, 581, 582) - } else if lower_name.eq("r2scan") { - (0, 497, 498) - } else if lower_name.eq("tpss") { - (0, 202, 231) - } else if lower_name.eq("b3lyp") { - (402, 0, 0) - } else if lower_name.eq("x3lyp") { - (411, 0, 0) - } else if lower_name.eq("pbe0") { - (406, 0, 0) - } else if lower_name.eq("scan0") { - (0, 264, 267) - } else if lower_name.eq("tpssh") { - (457, 0, 0) - } else if lower_name.eq("lda_x_slater") { - (0, 1, 0) - } else { - for (name, value) in LIBXC_FUNC_MAP.iter() { - if name.starts_with("XC_") && format!("xc_{}", lower_name) == name.to_lowercase() { - if name.contains("_XC_") { - return (*value as usize, 0, 0); - } else if name.contains("_C_") { - return (0, 0, *value as usize); - } else if name.contains("_X_") { - return (0, *value as usize, 0); - } - } - } - (0, 0, 0) - } - } - - pub fn code_to_name(code: usize) -> String { - ::libxc::util::libxc_functional_get_name(code as i32).unwrap_or_else(|| "Unknown_XC".to_string()) - } - - // Simple LDA/GGA/MGGA compute wrappers - pub fn lda_exc(&self, rho: &[f64]) -> Vec { - let np = rho.len() / (self.inner.spin() as usize); - let mut input = HashMap::new(); - input.insert("rho".to_string(), rho); - let (buf, layout) = self.inner.compute_lda(&input, 0).unwrap(); - buf[layout.get("zk").unwrap()].to_vec() - } - - pub fn gga_exc(&self, rho: &[f64], sigma: &[f64]) -> Vec { - let np = rho.len() / (self.inner.spin() as usize); - let mut input = HashMap::new(); - input.insert("rho".to_string(), rho); - input.insert("sigma".to_string(), sigma); - let (buf, layout) = self.inner.compute_gga(&input, 0).unwrap(); - buf[layout.get("zk").unwrap()].to_vec() - } - - pub fn mgga_exc(&self, rho: &[f64], sigma: &[f64], _lapl: &[f64], tau: &[f64]) -> Vec { - let mut input = HashMap::new(); - input.insert("rho".to_string(), rho); - input.insert("sigma".to_string(), sigma); - if self.inner.needs_laplacian() { - input.insert("lapl".to_string(), _lapl); - } - input.insert("tau".to_string(), tau); - let (buf, layout) = self.inner.compute_mgga(&input, 0).unwrap(); - buf[layout.get("zk").unwrap()].to_vec() - } - - pub fn lda_exc_vxc(&self, rho: &[f64]) -> (Vec, Vec) { - let mut input = HashMap::new(); - input.insert("rho".to_string(), rho); - let (buf, layout) = self.inner.compute_lda(&input, 1).unwrap(); - let exc = buf[layout.get("zk").unwrap()].to_vec(); - let vrho = buf[layout.get("vrho").unwrap()].to_vec(); - (exc, vrho) - } - - pub fn gga_exc_vxc(&self, rho: &[f64], sigma: &[f64]) -> (Vec, Vec, Vec) { - let mut input = HashMap::new(); - input.insert("rho".to_string(), rho); - input.insert("sigma".to_string(), sigma); - let (buf, layout) = self.inner.compute_gga(&input, 1).unwrap(); - let exc = buf[layout.get("zk").unwrap()].to_vec(); - let vrho = buf[layout.get("vrho").unwrap()].to_vec(); - let vsigma = buf[layout.get("vsigma").unwrap()].to_vec(); - (exc, vrho, vsigma) - } - - pub fn mgga_exc_vxc( - &self, - rho: &[f64], - sigma: &[f64], - _lapl: &[f64], - tau: &[f64], - ) -> (Vec, Vec, Vec, Vec, Vec) { - let mut input = HashMap::new(); - input.insert("rho".to_string(), rho); - input.insert("sigma".to_string(), sigma); - if self.inner.needs_laplacian() { - input.insert("lapl".to_string(), _lapl); - } - input.insert("tau".to_string(), tau); - let (buf, layout) = self.inner.compute_mgga(&input, 1).unwrap(); - let exc = buf[layout.get("zk").unwrap()].to_vec(); - let vrho = buf[layout.get("vrho").unwrap()].to_vec(); - let vsigma = buf[layout.get("vsigma").unwrap()].to_vec(); - let vlapl = layout - .get("vlapl") - .map(|r| buf[r].to_vec()) - .unwrap_or_default(); - let vtau = buf[layout.get("vtau").unwrap()].to_vec(); - (exc, vrho, vsigma, vlapl, vtau) - } - - pub fn get_family_name_std(family_id: u32) -> String { - match family_id { - 1 => "LDA".to_string(), - 2 => "GGA".to_string(), - 4 => "MGGA".to_string(), - 32 => "Hybrid GGA".to_string(), - 64 => "Hybrid MGGA".to_string(), - _ => "Unknown".to_string(), - } - } - - pub fn get_libxc_spin(&self) -> usize { - self.inner.spin() as usize - } -} - -pub fn eval_libxc_func_new( - xc_func: &XcFuncType, - spin: usize, - deriv: usize, - np: usize, - rho: &[f64], - sigma: Option<&[f64]>, - lapl: Option<&[f64]>, - tau: Option<&[f64]>, - exc: &mut [f64], -) { - assert!(deriv <= 3, "Derivative order must be 0, 1, 2 or 3"); - - let spin_enum = if spin == 0 { - LibXCSpin::Unpolarized - } else { - LibXCSpin::Polarized - }; - - // Build input map - let mut input: HashMap = HashMap::new(); - input.insert("rho".to_string(), rho); - if let Some(s) = sigma { - input.insert("sigma".to_string(), s); - } - if let Some(l) = lapl { - if xc_func.inner.needs_laplacian() { - input.insert("lapl".to_string(), l); - } - } - if let Some(t) = tau { - input.insert("tau".to_string(), t); - } - - // Use compute_xc_with_unsliced_output to write directly into `exc` - xc_func - .inner - .compute_xc_with_unsliced_output(&input, exc, deriv) - .unwrap(); -} - -pub fn eval_libxc_func( - xc_func: &XcFuncType, - spin: usize, - deriv: usize, - np: usize, - rho: &[f64], - sigma: Option<&[f64]>, - lapl: Option<&[f64]>, - tau: Option<&[f64]>, - exc: &mut [f64], -) { - eval_libxc_func_new(xc_func, spin, deriv, np, rho, sigma, lapl, tau, exc) -} - -/// Name-to-value map for libxc functional constants, compatible with old `names_and_values::MAP`. -pub mod names_and_values { - use super::*; - - lazy_static::lazy_static! { - pub static ref MAP: Vec<(String, usize)> = { - LIBXC_FUNC_MAP - .iter() - .map(|(name, value)| (format!("XC_{}", name), *value as usize)) - .collect() - }; - } -} diff --git a/src/dft/libxc_helper.rs b/src/dft/libxc_helper.rs new file mode 100644 index 0000000000..f82c72432c --- /dev/null +++ b/src/dft/libxc_helper.rs @@ -0,0 +1,345 @@ +use ::libxc::prelude::*; +use std::collections::HashMap; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum LibXCFamily { + LDA, + GGA, + MGGA, + HybridGGA, + HybridMGGA, + Unknown, +} + +impl LibXCFamily { + pub fn from_libxc(family: ::libxc::enums::LibXCFamily) -> Self { + match family { + ::libxc::enums::LibXCFamily::LDA | ::libxc::enums::LibXCFamily::HybLDA => LibXCFamily::LDA, + ::libxc::enums::LibXCFamily::GGA => LibXCFamily::GGA, + ::libxc::enums::LibXCFamily::MGGA => LibXCFamily::MGGA, + ::libxc::enums::LibXCFamily::HybGGA => LibXCFamily::HybridGGA, + ::libxc::enums::LibXCFamily::HybMGGA => LibXCFamily::HybridMGGA, + _ => LibXCFamily::Unknown, + } + } + + pub fn get_name(&self) -> &'static str { + match self { + LibXCFamily::LDA => "LDA", + LibXCFamily::GGA => "GGA", + LibXCFamily::MGGA => "MGGA", + LibXCFamily::HybridGGA => "HybridGGA", + LibXCFamily::HybridMGGA => "HybridMGGA", + LibXCFamily::Unknown => "Unknown DFA", + } + } +} + +pub fn get_libxc_family(func: &LibXCFunctional) -> LibXCFamily { + LibXCFamily::from_libxc(func.family()) +} + +pub fn use_density_gradient(func: &LibXCFunctional) -> bool { + !matches!(get_libxc_family(func), LibXCFamily::LDA) +} + +pub fn use_kinetic_density(func: &LibXCFunctional) -> bool { + matches!( + get_libxc_family(func), + LibXCFamily::MGGA | LibXCFamily::HybridMGGA + ) +} + +pub fn xc_code_fdqc(name: &str) -> [usize; 3] { + let lower_name = name.to_lowercase(); + if lower_name == "hf" { + [0, 0, 0] + } else if lower_name == "svwn" { + [0, 1, 7] + } else if lower_name == "svwn-rpa" { + [0, 1, 8] + } else if lower_name == "pz-lda" { + [0, 1, 9] + } else if lower_name == "pw-lda" { + [0, 1, 12] + } else if lower_name == "blyp" { + [0, 106, 131] + } else if lower_name == "xlyp" { + [166, 0, 0] + } else if lower_name == "pbe" { + [0, 101, 130] + } else if lower_name == "xpbe" { + [0, 123, 136] + } else if lower_name == "scan" { + [0, 263, 267] + } else if lower_name == "revscan" { + [0, 581, 582] + } else if lower_name == "m06-l" { + [0, 203, 233] + } else if lower_name == "mn15-l" { + [0, 260, 261] + } else if lower_name == "r2scan" { + [0, 497, 498] + } else if lower_name == "tpss" { + [0, 202, 231] + } else if lower_name == "b3lyp" { + [402, 0, 0] + } else if lower_name == "x3lyp" { + [411, 0, 0] + } else if lower_name == "pbe0" { + [406, 0, 0] + } else if lower_name == "scan0" { + [0, 264, 267] + } else if lower_name == "tpssh" { + [457, 0, 0] + } else if lower_name == "m05-2x" || lower_name == "m052x" { + [0, 439, 238] + } else if lower_name == "m05" { + [0, 438, 237] + } else if lower_name == "m06" { + [0, 449, 235] + } else if lower_name == "m06-2x" || lower_name == "m062x" { + [0, 450, 236] + } else if lower_name == "mn15" { + [0, 268, 269] + } else if lower_name == "wb97x" { + [464, 0, 0] + } else if lower_name == "cam-b3lyp" || lower_name == "camb3lyp" { + [433, 0, 0] + } else if lower_name == "lc-blyp" || lower_name == "lcblyp" { + [400, 0, 0] + } else if lower_name == "lc-wpbe" || lower_name == "lcwpbe" { + [478, 0, 0] + } else if lower_name == "hse06" || lower_name == "hse" { + [428, 0, 0] + } else if lower_name == "hse03" { + [427, 0, 0] + } else if lower_name == "lda_x_slater" { + [0, 1, 0] + } else { + for (name, value) in LIBXC_FUNC_MAP.iter() { + let prefixed = format!("XC_{}", name); + if prefixed.starts_with("XC_") + && format!("xc_{}", lower_name) == prefixed.to_lowercase() + { + if name.contains("_XC_") { + return [*value as usize, 0, 0]; + } else if name.contains("_C_") { + return [0, 0, *value as usize]; + } else if name.contains("_X_") { + return [0, *value as usize, 0]; + } + } + } + panic!( + "Unknown XC method is specified: {}. You can try using `xc_parser = \"parse_xc\"` and see if works in the ctrl.in input configuration.", + &name + ); + } +} + +pub fn xc_code_to_name(code: usize) -> String { + ::libxc::util::libxc_functional_get_name(code as i32).unwrap_or_else(|| "Unknown_XC".to_string()) +} + +pub fn xc_func_init(func_id: usize, spin_channel: usize) -> LibXCFunctional { + let spin = if spin_channel == 1 { + LibXCSpin::Unpolarized + } else { + LibXCSpin::Polarized + }; + LibXCFunctional::from_number(func_id as i32, spin) +} + +pub fn lda_exc_vxc(func: &LibXCFunctional, rho: &[f64]) -> (Vec, Vec) { + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + let (buf, layout) = func.compute_lda(&input, 1).unwrap(); + let exc = buf[layout.get("zk").unwrap()].to_vec(); + let vrho = buf[layout.get("vrho").unwrap()].to_vec(); + (exc, vrho) +} + +pub fn gga_exc_vxc(func: &LibXCFunctional, rho: &[f64], sigma: &[f64]) -> (Vec, Vec, Vec) { + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + input.insert("sigma".to_string(), sigma); + let (buf, layout) = func.compute_gga(&input, 1).unwrap(); + let exc = buf[layout.get("zk").unwrap()].to_vec(); + let vrho = buf[layout.get("vrho").unwrap()].to_vec(); + let vsigma = buf[layout.get("vsigma").unwrap()].to_vec(); + (exc, vrho, vsigma) +} + +pub fn mgga_exc_vxc( + func: &LibXCFunctional, + rho: &[f64], + sigma: &[f64], + lapl: &[f64], + tau: &[f64], +) -> (Vec, Vec, Vec, Vec, Vec) { + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + input.insert("sigma".to_string(), sigma); + if func.needs_laplacian() { + input.insert("lapl".to_string(), lapl); + } + input.insert("tau".to_string(), tau); + let (buf, layout) = func.compute_mgga(&input, 1).unwrap(); + let exc = buf[layout.get("zk").unwrap()].to_vec(); + let vrho = buf[layout.get("vrho").unwrap()].to_vec(); + let vsigma = buf[layout.get("vsigma").unwrap()].to_vec(); + let vlapl = layout + .get("vlapl") + .map(|r| buf[r].to_vec()) + .unwrap_or_default(); + let vtau = buf[layout.get("vtau").unwrap()].to_vec(); + (exc, vrho, vsigma, vlapl, vtau) +} + +pub fn lda_exc(func: &LibXCFunctional, rho: &[f64]) -> Vec { + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + let (buf, layout) = func.compute_lda(&input, 0).unwrap(); + buf[layout.get("zk").unwrap()].to_vec() +} + +pub fn gga_exc(func: &LibXCFunctional, rho: &[f64], sigma: &[f64]) -> Vec { + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + input.insert("sigma".to_string(), sigma); + let (buf, layout) = func.compute_gga(&input, 0).unwrap(); + buf[layout.get("zk").unwrap()].to_vec() +} + +pub fn mgga_exc(func: &LibXCFunctional, rho: &[f64], sigma: &[f64], lapl: &[f64], tau: &[f64]) -> Vec { + let mut input = HashMap::new(); + input.insert("rho".to_string(), rho); + input.insert("sigma".to_string(), sigma); + if func.needs_laplacian() { + input.insert("lapl".to_string(), lapl); + } + input.insert("tau".to_string(), tau); + let (buf, layout) = func.compute_mgga(&input, 0).unwrap(); + buf[layout.get("zk").unwrap()].to_vec() +} + +pub fn eval_libxc_func_new( + xc_func: &LibXCFunctional, + spin: usize, + deriv: usize, + np: usize, + rho: &[f64], + sigma: Option<&[f64]>, + lapl: Option<&[f64]>, + tau: Option<&[f64]>, + exc: &mut [f64], +) { + assert!(deriv <= 3, "Derivative order must be 0, 1, 2 or 3"); + let _ = (spin, np); + + let mut input: HashMap = HashMap::new(); + input.insert("rho".to_string(), rho); + if let Some(s) = sigma { + input.insert("sigma".to_string(), s); + } + if let Some(l) = lapl { + if xc_func.needs_laplacian() { + input.insert("lapl".to_string(), l); + } + } + if let Some(t) = tau { + input.insert("tau".to_string(), t); + } + + xc_func + .compute_xc_with_unsliced_output(&input, exc, deriv) + .unwrap(); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_compat_family_lda() { + let func = xc_func_init(1, 1); + assert_eq!(get_libxc_family(&func), LibXCFamily::LDA); + } + + #[test] + fn test_compat_family_gga() { + let func = xc_func_init(101, 1); + assert_eq!(get_libxc_family(&func), LibXCFamily::GGA); + } + + #[test] + fn test_compat_family_mgga() { + let func = xc_func_init(263, 1); + assert_eq!(get_libxc_family(&func), LibXCFamily::MGGA); + } + + #[test] + fn test_compat_family_hyb_gga() { + let func = xc_func_init(402, 1); + assert_eq!(get_libxc_family(&func), LibXCFamily::HybridGGA); + } + + #[test] + fn test_compat_family_hyb_mgga() { + let func = xc_func_init(457, 1); + assert_eq!(get_libxc_family(&func), LibXCFamily::HybridMGGA); + } + + #[test] + fn test_xc_code_fdqc_pbe() { + let code = xc_code_fdqc("pbe"); + assert_eq!(code, [0, 101, 130]); + } + + #[test] + fn test_xc_code_fdqc_b3lyp() { + let code = xc_code_fdqc("b3lyp"); + assert_eq!(code, [402, 0, 0]); + } + + #[test] + fn test_code_to_name() { + let name = xc_code_to_name(1); + assert!(!name.is_empty()); + } + + #[test] + fn test_use_density_gradient() { + let lda = xc_func_init(1, 1); + assert!(!use_density_gradient(&lda)); + let gga = xc_func_init(101, 1); + assert!(use_density_gradient(&gga)); + } + + #[test] + fn test_is_hyb_cam() { + let cam = xc_func_init(433, 1); + assert!(cam.is_hyb_cam()); + let hyb = xc_func_init(402, 1); + assert!(!hyb.is_hyb_cam()); + } + + #[test] + fn test_needs_laplacian() { + let func = xc_func_init(263, 1); + assert!(!func.needs_laplacian()); + } + + #[test] + fn test_flags_vv10() { + let func = xc_func_init(263, 1); + assert!(!func.flags().contains(LibXCFlags::VV10)); + } + + #[test] + fn test_xc_code_fdqc_libxc_lookup() { + let code = xc_code_fdqc("gga_x_pbe"); + assert_eq!(code[1], 101); + } +} diff --git a/src/dft/libxc_itrf.rs b/src/dft/libxc_itrf.rs index 730d5917d2..887b69932d 100644 --- a/src/dft/libxc_itrf.rs +++ b/src/dft/libxc_itrf.rs @@ -5,7 +5,7 @@ xc functional interface to Libxc for REST use core::panic; use rayon::prelude::*; use rstsr::prelude::*; -use crate::dft::libxc::{XcFuncType, LibXCFamily, eval_libxc_func_new}; +use crate::dft::libxc_helper::{LibXCFamily, get_libxc_family, xc_func_init, eval_libxc_func_new}; use crate::dft::xc_deriv::{XCType, xc_indices_transform, transform_xc_inner, count_combinations}; @@ -187,14 +187,14 @@ fn eval_xc1( .for_each( |(func_id, xc_param)| { - let xc_func = XcFuncType::xc_func_init(*func_id, spin+1); - let cur_xc_type = match xc_func.get_libxc_family() { + let xc_func = xc_func_init(*func_id, spin+1); + let cur_xc_type = match get_libxc_family(&xc_func) { LibXCFamily::LDA => XCType::LDA, LibXCFamily::GGA => XCType::GGA, LibXCFamily::MGGA => XCType::MGGA, LibXCFamily::HybridGGA => XCType::GGA, // Hybrid GGA is treated as GGA LibXCFamily::HybridMGGA => XCType::MGGA, // Hybrid MGGA is treated as MGGA - _ => panic!("Unresolved xc family: {:?}", xc_func.get_libxc_family()), + _ => panic!("Unresolved xc family: {:?}", get_libxc_family(&xc_func)), }; let mut outbuf = vec![0.0; np * n_components]; eval_libxc_func_new(&xc_func, spin, deriv, np, rho, sigma, lapl, tau, &mut outbuf); diff --git a/src/dft/mod.rs b/src/dft/mod.rs index 20319b4be3..dc65f68966 100644 --- a/src/dft/mod.rs +++ b/src/dft/mod.rs @@ -1,5 +1,5 @@ #![warn(unused_imports)] -mod libxc; +pub mod libxc_helper; pub mod gen_grids; pub mod deep_learning; pub mod libxc_itrf; @@ -35,11 +35,8 @@ use std::ops::Range; use std::sync::mpsc::channel; use serde::{Deserialize, Serialize}; -//extern crate rest_libxc as libxc; -use libxc::{XcFuncType}; -//use std::intrinsics::expf64; -use crate::dft::libxc::names_and_values::MAP as libxc_names_values; -use crate::dft::libxc::LibXCFamily; +use ::libxc::functional::LibXCFunctional; +use crate::dft::libxc_helper::{LibXCFamily, get_libxc_family, use_density_gradient, use_kinetic_density, xc_code_fdqc, xc_code_to_name, xc_func_init, lda_exc_vxc, gga_exc_vxc, mgga_exc_vxc, lda_exc, gga_exc, mgga_exc}; use rest_tensors::matrix_blas_lapack::{omp_get_num_threads_wrapper, omp_set_num_threads_wrapper}; @@ -262,7 +259,7 @@ impl DFA4REST { if print_level> 0 { println!("the scf functional for '{}' contains", &name); &dfa.dfa_compnt_scf.iter().for_each(|xc_func| { - dfa.init_libxc(xc_func).xc_func_info_printout() + println!("{}", dfa.init_libxc(xc_func).describe()) }); if let (Some(dfatype),Some(dfacomp)) = (&dfa.dfa_family_pos, &dfa.dfa_compnt_pos) { @@ -273,7 +270,7 @@ impl DFA4REST { //} println!("the post-scf functional '{}' is employed, which contains", &name); dfacomp.into_iter().for_each(|xc_func| { - dfa.init_libxc(xc_func).xc_func_info_printout() + println!("{}", dfa.init_libxc(xc_func).describe()) }) }; } @@ -285,7 +282,7 @@ impl DFA4REST { println!("the functional of '{}' contains", &name); dfa.dfa_compnt_scf.iter().for_each(|xc_func| { let tmp_dfa = dfa.init_libxc(xc_func); - tmp_dfa.xc_func_info_printout(); + println!("{}", tmp_dfa.describe()); }); }; dfa @@ -294,128 +291,33 @@ impl DFA4REST { } pub fn libxc_code_fdqc(name: &str) -> [usize;3] { - let lower_name = name.to_lowercase(); - //println!("Debug: {:?}", &lower_name); - // for a list of exchange-correlation functionals - if lower_name.eq(&"hf".to_string()) { - [0,0,0] - } else if lower_name.eq(&"svwn".to_string()) { - [0,1,7] - } else if lower_name.eq(&"svwn-rpa".to_string()) { - [0,1,8] - } else if lower_name.eq(&"pz-lda".to_string()) { - [0,1,9] - } else if lower_name.eq(&"pw-lda".to_string()) { - [0,1,12] - } else if lower_name.eq(&"blyp".to_string()) { - [0,106,131] - } else if lower_name.eq(&"xlyp".to_string()) { - [166,0,0] - } else if lower_name.eq(&"pbe".to_string()) { - [0,101,130] - } else if lower_name.eq(&"xpbe".to_string()) { - [0,123,136] - } else if lower_name.eq(&"scan".to_string()) { - [0,263,267] - } else if lower_name.eq(&"revscan".to_string()) { - [0,581,582] - } else if lower_name.eq(&"m06-l".to_string()) { - [0,203,233] - } else if lower_name.eq(&"mn15-l".to_string()) { - [0,260,261] - } else if lower_name.eq(&"r2scan".to_string()) { - [0,497,498] - } else if lower_name.eq(&"tpss".to_string()) { - [0,202,231] - } else if lower_name.eq(&"b3lyp".to_string()) { - [402,0,0] - } else if lower_name.eq(&"x3lyp".to_string()) { - [411,0,0] - } else if lower_name.eq(&"pbe0".to_string()) { - [406,0,0] - } else if lower_name.eq(&"scan0".to_string()) { - [0,264,267] - } else if lower_name.eq(&"tpssh".to_string()) { - [457,0,0] - } else if lower_name.eq(&"m05-2x".to_string()) || lower_name.eq(&"m052x".to_string()) { - [0,439,238] - } else if lower_name.eq(&"m05".to_string()) { - [0,438,237] - } else if lower_name.eq(&"m06".to_string()) { - [0,449,235] - } else if lower_name.eq(&"m06-2x".to_string()) || lower_name.eq(&"m062x".to_string()) { - [0,450,236] - } else if lower_name.eq(&"mn15".to_string()) { - [0,268,269] - } else if lower_name.eq(&"wb97x".to_string()) { - [464,0,0] - } else if lower_name.eq(&"cam-b3lyp".to_string()) || lower_name.eq(&"camb3lyp".to_string()) { - [433,0,0] - } else if lower_name.eq(&"lc-blyp".to_string()) || lower_name.eq(&"lcblyp".to_string()) { - [400,0,0] - } else if lower_name.eq(&"lc-wpbe".to_string()) || lower_name.eq(&"lcwpbe".to_string()) { - [478,0,0] - } else if lower_name.eq(&"hse06".to_string()) || lower_name.eq(&"hse".to_string()) { - [428,0,0] - } else if lower_name.eq(&"hse03".to_string()) { - [427,0,0] - } else if lower_name.eq(&"lda_x_slater".to_string()) { - [0,1,0] - } else { - for (name, value) in libxc_names_values.iter() { - if name.starts_with("XC_") && format!("xc_{}", lower_name) == name.to_lowercase() { - if name.contains("_XC_") { - return [*value, 0, 0]; - } else if name.contains("_C_") { - return [0, 0, *value]; - } else if name.contains("_X_") { - return [0, *value, 0]; - } - } - } - panic!("Unknown XC method is specified: {}. You can try using `xc_parser = \"parse_xc\"` and see if works in the ctrl.in input configuration.", &name); - } + xc_code_fdqc(name) } - //pub fn xc_func_init_fdqc(name: &str, spin_channel: usize) -> Vec { - // let lower_name = name.to_lowercase(); - // let xc_code = DFA4REST::libxc_code_fdqc(name); - // let mut xc_list: Vec = vec![]; - // xc_code.iter().for_each(|x| { - // if *x!=0 { - // xc_list.push(XcFuncType::xc_func_init(*x, spin_channel)); - // } - // }); - // xc_list - //} - pub fn xc_func_init_fdqc(name: &str, spin_channel: usize) -> Vec { let xc_code = DFA4REST::libxc_code_fdqc(name); xc_code.iter().filter(|x| **x!=0).map(|x| *x).collect::>() } - pub fn init_libxc(&self, xc_code: &usize) -> XcFuncType { - XcFuncType::xc_func_init(*xc_code, self.spin_channel) + pub fn init_libxc(&self, xc_code: &usize) -> LibXCFunctional { + xc_func_init(*xc_code, self.spin_channel) } pub fn get_hybrid_libxc(dfa_compnt_scf: &Vec,spin_channel:usize) -> f64 { let mut hybrid_coeff = None; for xc_func in dfa_compnt_scf { - let func = XcFuncType::xc_func_init(*xc_func, spin_channel); - if func.use_exact_exchange() { - let hyb_exx_coeff = match func.is_rsh() { - false => func.xc_hyb_exx_coeff(), - true => { - let (omega, alpha, beta) = func.xc_hyb_cam_coef(); - alpha + beta - } - }; - if hyb_exx_coeff.abs() > 1e-10 { - if hybrid_coeff.is_some() { - panic!("Multiple hybrid functionals are specified in the DFA components for SCF. Currently this is not supported."); - } - hybrid_coeff = Some(hyb_exx_coeff); + let func = xc_func_init(*xc_func, spin_channel); + let hyb_exx_coeff = if let Some((_omega, alpha, beta)) = func.cam_coef() { + alpha + beta // for RSH, return alpha + beta (matches pyscf) + } else { + // for non-RSH, return hybrid coefficient; if not available, return 0.0 + func.hyb_exx_coef().unwrap_or(0.0) + }; + if hyb_exx_coeff.abs() > 1e-10 { + if hybrid_coeff.is_some() { + panic!("Multiple hybrid functionals are specified in the DFA components for SCF. Currently this is not supported."); } + hybrid_coeff = Some(hyb_exx_coeff); } } hybrid_coeff.unwrap_or(0.0) @@ -424,9 +326,9 @@ impl DFA4REST { pub fn get_rsh_libxc(dfa_compnt_scf: &Vec, spin_channel: usize) -> Option<(f64, f64, f64)> { let mut result = None; for xc_func in dfa_compnt_scf { - let func = XcFuncType::xc_func_init(*xc_func, spin_channel); - if func.is_rsh() { - let (omega, alpha, beta) = func.xc_hyb_cam_coef(); + let func = xc_func_init(*xc_func, spin_channel); + if func.is_hyb_cam() { + let (omega, alpha, beta) = func.cam_coef().unwrap_or((0.0, 0.0, 0.0)); if alpha.abs() < 1e-10 && beta.abs() < 1e-10 { continue; } @@ -1278,11 +1180,11 @@ impl DFA4REST { pub fn use_density_gradient(&self) -> bool { let mut is_flag = self.dfa_compnt_scf.iter().fold(false, |acc, xc_func| { - acc || self.init_libxc(xc_func).use_density_gradient() + acc || use_density_gradient(&self.init_libxc(xc_func)) }); if let Some(dfa_compnt_pos) = &self.dfa_compnt_pos { is_flag = is_flag || dfa_compnt_pos.iter().fold(false, |acc, xc_func| { - acc || self.init_libxc(xc_func).use_density_gradient() + acc || use_density_gradient(&self.init_libxc(xc_func)) }); } is_flag @@ -1290,11 +1192,11 @@ impl DFA4REST { pub fn use_kinetic_density(&self) -> bool { let mut is_flag = self.dfa_compnt_scf.iter().fold(false, |acc, xc_func| { - acc || self.init_libxc(xc_func).use_kinetic_density() + acc || use_kinetic_density(&self.init_libxc(xc_func)) }); if let Some(dfa_compnt_pos) = &self.dfa_compnt_pos { is_flag = is_flag || dfa_compnt_pos.iter().fold(false, |acc, xc_func| { - acc || self.init_libxc(xc_func).use_kinetic_density() + acc || use_kinetic_density(&self.init_libxc(xc_func)) }); } is_flag @@ -1335,17 +1237,17 @@ impl DFA4REST { self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); - match xc_func.xc_func_family { + match get_libxc_family(&xc_func) { LibXCFamily::LDA => { if spin_channel==1 { - let (tmp_exc,tmp_vrho) = xc_func.lda_exc_vxc(rho.data_ref().unwrap()); + let (tmp_exc,tmp_vrho) = lda_exc_vxc(&xc_func,rho.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); let tmp_vrho = MatrixFull::from_vec([num_grids,1],tmp_vrho).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); vrho.par_self_scaled_add(&tmp_vrho,*xc_para); } else { - let (tmp_exc,tmp_vrho) = xc_func.lda_exc_vxc(rho.transpose().data_ref().unwrap()); + let (tmp_exc,tmp_vrho) = lda_exc_vxc(&xc_func,rho.transpose().data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); //let tmp_vrho = MatrixFull::from_vec([num_grids,spin_channel],tmp_vrho).unwrap(); let tmp_vrho = MatrixFull::from_vec([2,num_grids],tmp_vrho).unwrap(); @@ -1355,7 +1257,7 @@ impl DFA4REST { }, LibXCFamily::GGA | LibXCFamily::HybridGGA => { if spin_channel==1 { - let (tmp_exc,tmp_vrho, tmp_vsigma) = xc_func.gga_exc_vxc(rho.data_ref().unwrap(),sigma.data_ref().unwrap()); + let (tmp_exc,tmp_vrho, tmp_vsigma) = gga_exc_vxc(&xc_func,rho.data_ref().unwrap(),sigma.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); let tmp_vrho = MatrixFull::from_vec([num_grids,1],tmp_vrho).unwrap(); let tmp_vsigma= MatrixFull::from_vec([num_grids,1],tmp_vsigma).unwrap(); @@ -1363,7 +1265,7 @@ impl DFA4REST { vrho.par_self_scaled_add(&tmp_vrho,*xc_para); vsigma.par_self_scaled_add(&tmp_vsigma, *xc_para); } else { - let (tmp_exc,tmp_vrho, tmp_vsigma) = xc_func.gga_exc_vxc(rho.transpose().data_ref().unwrap(),sigma.transpose().data_ref().unwrap()); + let (tmp_exc,tmp_vrho, tmp_vsigma) = gga_exc_vxc(&xc_func,rho.transpose().data_ref().unwrap(),sigma.transpose().data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); let tmp_vrho = MatrixFull::from_vec([2,num_grids],tmp_vrho).unwrap(); let tmp_vsigma= MatrixFull::from_vec([3,num_grids],tmp_vsigma).unwrap(); @@ -1372,7 +1274,7 @@ impl DFA4REST { vsigma.par_self_scaled_add(&tmp_vsigma.transpose_and_drop(), *xc_para); } }, - _ => {println!("{} is not yet implemented", xc_func.get_family_name())} + _ => {println!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} } }); @@ -1591,17 +1493,17 @@ impl DFA4REST { self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); - match xc_func.xc_func_family { + match get_libxc_family(&xc_func) { LibXCFamily::LDA => { if spin_channel==1 { - let (tmp_exc,tmp_vrho) = xc_func.lda_exc_vxc(loc_rho.data_ref().unwrap()); + let (tmp_exc,tmp_vrho) = lda_exc_vxc(&xc_func,loc_rho.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); let tmp_vrho = MatrixFull::from_vec([num_grids,1],tmp_vrho).unwrap(); loc_exc.self_scaled_add(&tmp_exc,*xc_para); loc_vrho.self_scaled_add(&tmp_vrho,*xc_para); } else { - let (tmp_exc,tmp_vrho) = xc_func.lda_exc_vxc(loc_rho.transpose().data_ref().unwrap()); + let (tmp_exc,tmp_vrho) = lda_exc_vxc(&xc_func,loc_rho.transpose().data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); //let tmp_vrho = MatrixFull::from_vec([num_grids,spin_channel],tmp_vrho).unwrap(); let tmp_vrho = MatrixFull::from_vec([2,num_grids],tmp_vrho).unwrap(); @@ -1611,7 +1513,7 @@ impl DFA4REST { }, LibXCFamily::GGA | LibXCFamily::HybridGGA => { if spin_channel==1 { - let (tmp_exc,tmp_vrho, tmp_vsigma) = xc_func.gga_exc_vxc(loc_rho.data_ref().unwrap(),loc_sigma.data_ref().unwrap()); + let (tmp_exc,tmp_vrho, tmp_vsigma) = gga_exc_vxc(&xc_func,loc_rho.data_ref().unwrap(),loc_sigma.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); let tmp_vrho = MatrixFull::from_vec([num_grids,1],tmp_vrho).unwrap(); let tmp_vsigma= MatrixFull::from_vec([num_grids,1],tmp_vsigma).unwrap(); @@ -1619,7 +1521,7 @@ impl DFA4REST { loc_vrho.self_scaled_add(&tmp_vrho,*xc_para); loc_vsigma.self_scaled_add(&tmp_vsigma, *xc_para); } else { - let (tmp_exc,tmp_vrho, tmp_vsigma) = xc_func.gga_exc_vxc(loc_rho.transpose().data_ref().unwrap(),loc_sigma.transpose().data_ref().unwrap()); + let (tmp_exc,tmp_vrho, tmp_vsigma) = gga_exc_vxc(&xc_func,loc_rho.transpose().data_ref().unwrap(),loc_sigma.transpose().data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); let tmp_vrho = MatrixFull::from_vec([2,num_grids],tmp_vrho).unwrap(); let tmp_vsigma= MatrixFull::from_vec([3,num_grids],tmp_vsigma).unwrap(); @@ -1631,7 +1533,7 @@ impl DFA4REST { LibXCFamily::MGGA | LibXCFamily::HybridMGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho,tmp_vsigma,tmp_valpl,tmp_vtau) - = xc_func.mgga_exc_vxc( + = mgga_exc_vxc(&xc_func, loc_rho.data_ref().unwrap(), loc_sigma.data_ref().unwrap(), loc_lapl.data_ref().unwrap(), @@ -1648,7 +1550,7 @@ impl DFA4REST { loc_vtau.self_scaled_add(&tmp_vtau, *xc_para); } else { let (tmp_exc,tmp_vrho,tmp_vsigma,tmp_valpl,tmp_vtau) - = xc_func.mgga_exc_vxc( + = mgga_exc_vxc(&xc_func, loc_rho.transpose().data_ref().unwrap(), loc_sigma.transpose().data_ref().unwrap(), loc_lapl.transpose().data_ref().unwrap(), @@ -1665,7 +1567,7 @@ impl DFA4REST { loc_vtau.self_scaled_add(&tmp_vtau.transpose_and_drop(), *xc_para); } }, - _ => {println!("{} is not yet implemented", xc_func.get_family_name())} + _ => {println!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} } }); @@ -1926,17 +1828,17 @@ impl DFA4REST { self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); - match xc_func.xc_func_family { + match get_libxc_family(&xc_func) { LibXCFamily::LDA => { if spin_channel==1 { - let (tmp_exc,tmp_vrho) = xc_func.lda_exc_vxc(loc_rho.data_ref().unwrap()); + let (tmp_exc,tmp_vrho) = lda_exc_vxc(&xc_func,loc_rho.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); let tmp_vrho = MatrixFull::from_vec([num_grids,1],tmp_vrho).unwrap(); loc_exc.self_scaled_add(&tmp_exc,*xc_para); loc_vrho.self_scaled_add(&tmp_vrho,*xc_para); } else { - let (tmp_exc,tmp_vrho) = xc_func.lda_exc_vxc(loc_rho.transpose().data_ref().unwrap()); + let (tmp_exc,tmp_vrho) = lda_exc_vxc(&xc_func,loc_rho.transpose().data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); //let tmp_vrho = MatrixFull::from_vec([num_grids,spin_channel],tmp_vrho).unwrap(); let tmp_vrho = MatrixFull::from_vec([2,num_grids],tmp_vrho).unwrap(); @@ -1946,7 +1848,7 @@ impl DFA4REST { }, LibXCFamily::GGA | LibXCFamily::HybridGGA => { if spin_channel==1 { - let (tmp_exc,tmp_vrho, tmp_vsigma) = xc_func.gga_exc_vxc(loc_rho.data_ref().unwrap(),loc_sigma.data_ref().unwrap()); + let (tmp_exc,tmp_vrho, tmp_vsigma) = gga_exc_vxc(&xc_func,loc_rho.data_ref().unwrap(),loc_sigma.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); let tmp_vrho = MatrixFull::from_vec([num_grids,1],tmp_vrho).unwrap(); let tmp_vsigma= MatrixFull::from_vec([num_grids,1],tmp_vsigma).unwrap(); @@ -1954,7 +1856,7 @@ impl DFA4REST { loc_vrho.self_scaled_add(&tmp_vrho,*xc_para); loc_vsigma.self_scaled_add(&tmp_vsigma, *xc_para); } else { - let (tmp_exc,tmp_vrho, tmp_vsigma) = xc_func.gga_exc_vxc(loc_rho.transpose().data_ref().unwrap(),loc_sigma.transpose().data_ref().unwrap()); + let (tmp_exc,tmp_vrho, tmp_vsigma) = gga_exc_vxc(&xc_func,loc_rho.transpose().data_ref().unwrap(),loc_sigma.transpose().data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); let tmp_vrho = MatrixFull::from_vec([2,num_grids],tmp_vrho).unwrap(); let tmp_vsigma= MatrixFull::from_vec([3,num_grids],tmp_vsigma).unwrap(); @@ -1966,7 +1868,7 @@ impl DFA4REST { LibXCFamily::MGGA | LibXCFamily::HybridMGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho,tmp_vsigma,tmp_valpl,tmp_vtau) - = xc_func.mgga_exc_vxc( + = mgga_exc_vxc(&xc_func, loc_rho.data_ref().unwrap(), loc_sigma.data_ref().unwrap(), loc_lapl.data_ref().unwrap(), @@ -1983,7 +1885,7 @@ impl DFA4REST { loc_vtau.self_scaled_add(&tmp_vtau, *xc_para); } else { let (tmp_exc,tmp_vrho,tmp_vsigma,tmp_valpl,tmp_vtau) - = xc_func.mgga_exc_vxc( + = mgga_exc_vxc(&xc_func, loc_rho.transpose().data_ref().unwrap(), loc_sigma.transpose().data_ref().unwrap(), loc_lapl.transpose().data_ref().unwrap(), @@ -2000,7 +1902,7 @@ impl DFA4REST { loc_vtau.self_scaled_add(&tmp_vtau.transpose_and_drop(), *xc_para); } }, - _ => {println!("{} is not yet implemented", xc_func.get_family_name())} + _ => {println!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} } }); @@ -2201,7 +2103,7 @@ impl DFA4REST { let code = DFA4REST::xc_func_init_fdqc(x,spin_channel); let x_flag = code.iter().fold(false, |flag, xc_code| { let xc_func = self.init_libxc(xc_code); - flag || xc_func.is_gga()|| xc_func.is_hybrid_gga() + flag || use_density_gradient(&xc_func) }); flag || x_flag }); @@ -2290,10 +2192,10 @@ impl DFA4REST { self.dfa_compnt_scf.iter().enumerate().for_each(|(i_xc, xc)| { //if spin_channel == 1 { - str_lines[0].push_str(&format!("{:>20} ", &XcFuncType::code_to_name(*xc))); + str_lines[0].push_str(&format!("{:>20} ", &xc_code_to_name(*xc))); //} else { - // str_lines[0].push_str(&format!("{:>20}_alpha ", &XcFuncType::code_to_name(*xc))); - // str_lines[0].push_str(&format!("{:>20}_beta ", &XcFuncType::code_to_name(*xc))); + // str_lines[0].push_str(&format!("{:>20}_alpha ", &code_to_name(*xc))); + // str_lines[0].push_str(&format!("{:>20}_beta ", &code_to_name(*xc))); //} }); @@ -2414,7 +2316,7 @@ impl DFA4REST { //let (rho,rhop) = grids.prepare_tabulated_density(dm, spin_channel); let use_density_gradient = xc_code_list.iter().fold(false,|flag, xc_code| { let xc_func = self.init_libxc(xc_code); - flag || xc_func.is_gga() || xc_func.is_hybrid_gga() + flag || use_density_gradient(&xc_func) }); let sigma = if use_density_gradient { prepare_tabulated_sigma_rayon(&rhop, spin_channel) @@ -2483,13 +2385,13 @@ impl DFA4REST { //}; self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); - match xc_func.xc_func_family { + match get_libxc_family(&xc_func) { LibXCFamily::LDA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { - xc_func.lda_exc(rho.data_ref().unwrap()) + lda_exc(&xc_func,rho.data_ref().unwrap()) } else { - xc_func.lda_exc(rho.transpose().data_ref().unwrap()) + lda_exc(&xc_func,rho.transpose().data_ref().unwrap()) } ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); @@ -2497,9 +2399,9 @@ impl DFA4REST { LibXCFamily::GGA | LibXCFamily::HybridGGA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { - xc_func.gga_exc(rho.data_ref().unwrap(),sigma.data_ref().unwrap()) + gga_exc(&xc_func,rho.data_ref().unwrap(),sigma.data_ref().unwrap()) } else { - xc_func.gga_exc(rho.transpose().data_ref().unwrap(),sigma.transpose().data_ref().unwrap()) + gga_exc(&xc_func,rho.transpose().data_ref().unwrap(),sigma.transpose().data_ref().unwrap()) } ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); @@ -2508,27 +2410,27 @@ impl DFA4REST { let tmp_exc = MatrixFull::from_vec( [num_grids, 1], if spin_channel==1 { - xc_func.mgga_exc(rho.data_ref().unwrap(),sigma.data_ref().unwrap(), lapl.data_ref().unwrap(), tau.data_ref().unwrap()) + mgga_exc(&xc_func,rho.data_ref().unwrap(),sigma.data_ref().unwrap(), lapl.data_ref().unwrap(), tau.data_ref().unwrap()) } else { - xc_func.mgga_exc(rho.transpose().data_ref().unwrap(),sigma.transpose().data_ref().unwrap(), lapl.transpose().data_ref().unwrap(), tau.transpose().data_ref().unwrap()) + mgga_exc(&xc_func,rho.transpose().data_ref().unwrap(),sigma.transpose().data_ref().unwrap(), lapl.transpose().data_ref().unwrap(), tau.transpose().data_ref().unwrap()) } ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - _ => {println!("{} is not yet implemented", xc_func.get_family_name())} + _ => {println!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} } }); } else if iop==1 { // for the post-SCF energy calculation if let (Some(dfa_paramr),Some(dfa_compnt)) = (&self.dfa_paramr_pos, &self.dfa_compnt_pos) { dfa_compnt.iter().zip(dfa_paramr.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); - match xc_func.xc_func_family { + match get_libxc_family(&xc_func) { LibXCFamily::LDA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { - xc_func.lda_exc(rho.data_ref().unwrap()) + lda_exc(&xc_func,rho.data_ref().unwrap()) } else { - xc_func.lda_exc(rho.transpose().data_ref().unwrap()) + lda_exc(&xc_func,rho.transpose().data_ref().unwrap()) } ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); @@ -2536,14 +2438,14 @@ impl DFA4REST { LibXCFamily::GGA | LibXCFamily::HybridGGA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { - xc_func.gga_exc(rho.data_ref().unwrap(),sigma.data_ref().unwrap()) + gga_exc(&xc_func,rho.data_ref().unwrap(),sigma.data_ref().unwrap()) } else { - xc_func.gga_exc(rho.transpose().data_ref().unwrap(),sigma.transpose().data_ref().unwrap()) + gga_exc(&xc_func,rho.transpose().data_ref().unwrap(),sigma.transpose().data_ref().unwrap()) } ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - _ => {println!("{} is not yet implemented", xc_func.get_family_name())} + _ => {println!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} } }); } @@ -2581,13 +2483,13 @@ impl DFA4REST { pub fn xc_exc_code(&self, xc_code: &usize, rho: &MatrixFull, sigma:&MatrixFull, spin_channel: usize) -> MatrixFull { let xc_func = self.init_libxc(xc_code); let num_grids = rho.size()[0]; - let tmp_exc = match xc_func.xc_func_family { + let tmp_exc = match get_libxc_family(&xc_func) { LibXCFamily::LDA => { MatrixFull::from_vec([num_grids,1], if spin_channel==1 { - xc_func.lda_exc(rho.data_ref().unwrap()) + lda_exc(&xc_func,rho.data_ref().unwrap()) } else { - xc_func.lda_exc(rho.transpose().data_ref().unwrap()) + lda_exc(&xc_func,rho.transpose().data_ref().unwrap()) } ).unwrap() //exc.par_self_scaled_add(&tmp_exc,*xc_para); @@ -2596,14 +2498,14 @@ impl DFA4REST { //println!("debug, {:?}, {:?}, {:?}", xc_code, xc_func, sigma.data.len()); MatrixFull::from_vec([num_grids,1], if spin_channel==1 { - xc_func.gga_exc(rho.data_ref().unwrap(),sigma.data_ref().unwrap()) + gga_exc(&xc_func,rho.data_ref().unwrap(),sigma.data_ref().unwrap()) } else { - xc_func.gga_exc(rho.transpose().data_ref().unwrap(),sigma.transpose().data_ref().unwrap()) + gga_exc(&xc_func,rho.transpose().data_ref().unwrap(),sigma.transpose().data_ref().unwrap()) } ).unwrap() //exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - _ => {panic!("{} is not yet implemented", xc_func.get_family_name())} + _ => {panic!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} }; tmp_exc } @@ -4066,7 +3968,7 @@ fn test_libxc() { //new_vec.par_iter().for_each(|c| {println!("{:16.8e}",c)}); let xc_func = my_xc.init_libxc(xc_func); - let (tmp_exc, tmp_vrho) = xc_func.lda_exc_vxc(&rho); + let (tmp_exc, tmp_vrho) = lda_exc_vxc(&xc_func,&rho); //let tmp_exc_2 = tmp_exc.clone(); //println!("WARNNING:: unsolved rayon par_iter problem. It should be relevant to be the fact that tmp_exc is prepared by libxc via ffi"); //println!("tmp_vec_2 copied from tmp_exc: {:?},{},{}", &tmp_exc_2, tmp_exc_2.len(),tmp_exc_2.capacity()); @@ -4171,9 +4073,9 @@ fn test_rsh_cam_coeff_raw() { ]; for (libxc_id, exp_omega, exp_alpha, exp_beta, exp_hyb) in &ref_data { - let func = XcFuncType::xc_func_init(*libxc_id, 1); - assert!(func.is_rsh(), "ID {} should be RSH/CAM", libxc_id); - let (omega, alpha, beta) = func.xc_hyb_cam_coef(); + let func = xc_func_init(*libxc_id, 1); + assert!(func.is_hyb_cam(), "ID {} should be RSH/CAM", libxc_id); + let (omega, alpha, beta) = func.cam_coef().unwrap_or((0.0, 0.0, 0.0)); let hyb = alpha + beta; assert!((omega - exp_omega).abs() < 1e-3, "ID {}: omega mismatch: got {} expected {}", libxc_id, omega, exp_omega); assert!((alpha - exp_alpha).abs() < 1e-3, "ID {}: alpha mismatch: got {} expected {}", libxc_id, alpha, exp_alpha); diff --git a/src/dft/parse_xc/dispersion.rs b/src/dft/parse_xc/dispersion.rs index 93c14b7b0c..bdb0e266d5 100644 --- a/src/dft/parse_xc/dispersion.rs +++ b/src/dft/parse_xc/dispersion.rs @@ -3,7 +3,6 @@ use serde_json::Value; // use crate::dft::parse_xc::xc_helper::ALIAS_WITH_DISP; use std::collections::HashMap; use lazy_static::lazy_static; -use crate::dft::libxc::XcFuncType; lazy_static! { pub static ref ALIAS_WITH_DISP: HashMap<&'static str, &'static str> = HashMap::from([ @@ -65,8 +64,9 @@ impl DFAComponent { pub fn is_nlc(&self) -> bool { match self.component_type { ComponentType::Libxc => { - let xcfunc = XcFuncType::xc_func_init(self.id, 1); - xcfunc.is_nlc() + use libxc::prelude::*; + let xcfunc = LibXCFunctional::from_number(self.id as i32, LibXCSpin::Unpolarized); + xcfunc.flags().contains(LibXCFlags::VV10) }, _ => false, } diff --git a/src/dft/parse_xc/parse.rs b/src/dft/parse_xc/parse.rs index f1c4090779..1f6cd7a50a 100644 --- a/src/dft/parse_xc/parse.rs +++ b/src/dft/parse_xc/parse.rs @@ -3,7 +3,7 @@ use core::{panic}; use regex; use std::collections::HashMap; use lazy_static::lazy_static; -use crate::dft::libxc::{LibXCFamily, XcFuncType}; +use crate::dft::libxc_helper::xc_func_init; use crate::dft::parse_xc::xc_helper::{ALIAS, AVAIL_FUNC, CODES, ComponentType, MULTISTEP, MULTISTEP_ALIAS, MULTISTEP_NAME_WITH_DASH, @@ -187,13 +187,12 @@ impl DFAComponent { if self.component_type == ComponentType::HF { return self.factor; } else if self.component_type == ComponentType::Libxc { - let xcfunc = XcFuncType::xc_func_init(self.id, spin_channel); - let hybrid_coef = match xcfunc.is_rsh() { - false => xcfunc.get_hybrid(), - true => { - let (omega, alpha, beta) = xcfunc.xc_hyb_cam_coef(); - alpha + beta // for RSH, return alpha + beta (matches pyscf) - }, + let xcfunc = xc_func_init(self.id, spin_channel); + let hybrid_coef = if let Some((_omega, alpha, beta)) = xcfunc.cam_coef() { + alpha + beta // for RSH, return alpha + beta (matches pyscf) + } else { + // for non-RSH, return hybrid coefficient; if not available, return 0.0 + xcfunc.hyb_exx_coef().unwrap_or(0.0) }; let hyb = self.factor * hybrid_coef; return hyb; @@ -205,8 +204,8 @@ impl DFAComponent { pub fn is_rsh(&self) -> bool { match self.component_type { ComponentType::Libxc => { - let xcfunc = XcFuncType::xc_func_init(self.id, 1); - xcfunc.is_rsh() + let xcfunc = xc_func_init(self.id, 1); + xcfunc.is_hyb_cam() }, _ => false, } @@ -215,8 +214,8 @@ impl DFAComponent { pub fn use_laplacian(&self) -> bool { match self.component_type { ComponentType::Libxc => { - let xcfunc = XcFuncType::xc_func_init(self.id, 1); - xcfunc.use_laplacian() + let xcfunc = xc_func_init(self.id, 1); + xcfunc.needs_laplacian() }, _ => false, } @@ -224,8 +223,8 @@ impl DFAComponent { pub fn get_reference(&self) -> Vec { if self.component_type == ComponentType::Libxc && self.id != 0 { - let xcfunc = XcFuncType::xc_func_init(self.id, 1); - return xcfunc.get_libxc_references(); + let xcfunc = xc_func_init(self.id, 1); + return xcfunc.references().iter().map(|r| r.ref_text.clone()).collect(); } else { return Vec::new(); } @@ -335,19 +334,7 @@ impl DFAComponent { _ => panic!("Error: only PT2 and SCSRPA components can be checked for normalization, but got {}", self.component_type.as_str()), } } - -} -impl XcFuncType { - pub fn get_hybrid(&self) -> f64 { - match self.xc_func_family { - LibXCFamily::HybridGGA | LibXCFamily::HybridMGGA => { - let hyb = self.xc_hyb_exx_coeff(); - hyb - }, - _ => 0.0, - } - } } trait Addable { @@ -544,8 +531,8 @@ impl DFAdef { if let Some(components) = &self.xc_scf { for comp in components.iter() { if comp.is_rsh() { - let xcfunc = XcFuncType::xc_func_init(comp.id, spin_channel); - let (omega, alpha, beta) = xcfunc.xc_hyb_cam_coef(); + let xcfunc = xc_func_init(comp.id, spin_channel); + let (omega, alpha, beta) = xcfunc.cam_coef().unwrap_or((0.0, 0.0, 0.0)); // only if alpha and beta are both close to zero, we consider it as not range-separated (pure zero). if alpha.abs() < 1e-10 && beta.abs() < 1e-10 { continue; -- Gitee From af34defe80d90a1ab9708f861c1edd7effaa20d9 Mon Sep 17 00:00:00 2001 From: ajz34 Date: Sat, 16 May 2026 09:01:41 +0800 Subject: [PATCH 04/10] now bare libxc denotes the crate instead of module --- src/dft/libxc_helper.rs | 16 ++++++++-------- src/dft/mod.rs | 4 ++-- src/dft/parse_xc/xc_helper.rs | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/dft/libxc_helper.rs b/src/dft/libxc_helper.rs index f82c72432c..5a13e2000b 100644 --- a/src/dft/libxc_helper.rs +++ b/src/dft/libxc_helper.rs @@ -1,4 +1,4 @@ -use ::libxc::prelude::*; +use libxc::prelude::*; use std::collections::HashMap; #[derive(Clone, Debug, PartialEq, Eq)] @@ -12,13 +12,13 @@ pub enum LibXCFamily { } impl LibXCFamily { - pub fn from_libxc(family: ::libxc::enums::LibXCFamily) -> Self { + pub fn from_libxc(family: libxc::enums::LibXCFamily) -> Self { match family { - ::libxc::enums::LibXCFamily::LDA | ::libxc::enums::LibXCFamily::HybLDA => LibXCFamily::LDA, - ::libxc::enums::LibXCFamily::GGA => LibXCFamily::GGA, - ::libxc::enums::LibXCFamily::MGGA => LibXCFamily::MGGA, - ::libxc::enums::LibXCFamily::HybGGA => LibXCFamily::HybridGGA, - ::libxc::enums::LibXCFamily::HybMGGA => LibXCFamily::HybridMGGA, + libxc::enums::LibXCFamily::LDA | libxc::enums::LibXCFamily::HybLDA => LibXCFamily::LDA, + libxc::enums::LibXCFamily::GGA => LibXCFamily::GGA, + libxc::enums::LibXCFamily::MGGA => LibXCFamily::MGGA, + libxc::enums::LibXCFamily::HybGGA => LibXCFamily::HybridGGA, + libxc::enums::LibXCFamily::HybMGGA => LibXCFamily::HybridMGGA, _ => LibXCFamily::Unknown, } } @@ -139,7 +139,7 @@ pub fn xc_code_fdqc(name: &str) -> [usize; 3] { } pub fn xc_code_to_name(code: usize) -> String { - ::libxc::util::libxc_functional_get_name(code as i32).unwrap_or_else(|| "Unknown_XC".to_string()) + libxc::util::libxc_functional_get_name(code as i32).unwrap_or_else(|| "Unknown_XC".to_string()) } pub fn xc_func_init(func_id: usize, spin_channel: usize) -> LibXCFunctional { diff --git a/src/dft/mod.rs b/src/dft/mod.rs index dc65f68966..b907accfc6 100644 --- a/src/dft/mod.rs +++ b/src/dft/mod.rs @@ -35,7 +35,7 @@ use std::ops::Range; use std::sync::mpsc::channel; use serde::{Deserialize, Serialize}; -use ::libxc::functional::LibXCFunctional; +use libxc::functional::LibXCFunctional; use crate::dft::libxc_helper::{LibXCFamily, get_libxc_family, use_density_gradient, use_kinetic_density, xc_code_fdqc, xc_code_to_name, xc_func_init, lda_exc_vxc, gga_exc_vxc, mgga_exc_vxc, lda_exc, gga_exc, mgga_exc}; use rest_tensors::matrix_blas_lapack::{omp_get_num_threads_wrapper, omp_set_num_threads_wrapper}; @@ -122,7 +122,7 @@ impl DFAFamily { impl DFA4REST { pub fn xc_version(&self) { - let (major, minor, micro) = ::libxc::util::libxc_version(); + let (major, minor, micro) = libxc::util::libxc_version(); println!("Libxc version used in REST: {}.{}.{}", major, minor, micro); } diff --git a/src/dft/parse_xc/xc_helper.rs b/src/dft/parse_xc/xc_helper.rs index e7fd94674a..3df6f3896c 100644 --- a/src/dft/parse_xc/xc_helper.rs +++ b/src/dft/parse_xc/xc_helper.rs @@ -245,16 +245,16 @@ pub fn get_name_with_dash() -> HashMap { } pub fn get_name(id: usize) -> String { - let name = ::libxc::util::libxc_functional_get_name(id as i32) + let name = libxc::util::libxc_functional_get_name(id as i32) .unwrap_or_default(); name.to_uppercase() } pub fn get_available_functionals() -> HashMap { - let ids = ::libxc::util::libxc_available_functional_numbers(); + let ids = libxc::util::libxc_available_functional_numbers(); let mut available_functionals = HashMap::new(); for id in ids { - let name = ::libxc::util::libxc_functional_get_name(id) + let name = libxc::util::libxc_functional_get_name(id) .unwrap_or_default(); available_functionals.insert(name.to_uppercase(), id as usize); } -- Gitee From 98df3edbe350352a6936fadcb6b89fb97eb962bf Mon Sep 17 00:00:00 2001 From: ajz34 Date: Sat, 16 May 2026 09:27:38 +0800 Subject: [PATCH 05/10] changed all LibXCFamily to external crate libxc --- src/dft/libxc_helper.rs | 87 ------------------------------------ src/dft/libxc_itrf.rs | 11 ++--- src/dft/mod.rs | 99 ++++++++++++++++++++--------------------- 3 files changed, 54 insertions(+), 143 deletions(-) diff --git a/src/dft/libxc_helper.rs b/src/dft/libxc_helper.rs index 5a13e2000b..c6a14975e0 100644 --- a/src/dft/libxc_helper.rs +++ b/src/dft/libxc_helper.rs @@ -1,55 +1,6 @@ use libxc::prelude::*; use std::collections::HashMap; -#[derive(Clone, Debug, PartialEq, Eq)] -pub enum LibXCFamily { - LDA, - GGA, - MGGA, - HybridGGA, - HybridMGGA, - Unknown, -} - -impl LibXCFamily { - pub fn from_libxc(family: libxc::enums::LibXCFamily) -> Self { - match family { - libxc::enums::LibXCFamily::LDA | libxc::enums::LibXCFamily::HybLDA => LibXCFamily::LDA, - libxc::enums::LibXCFamily::GGA => LibXCFamily::GGA, - libxc::enums::LibXCFamily::MGGA => LibXCFamily::MGGA, - libxc::enums::LibXCFamily::HybGGA => LibXCFamily::HybridGGA, - libxc::enums::LibXCFamily::HybMGGA => LibXCFamily::HybridMGGA, - _ => LibXCFamily::Unknown, - } - } - - pub fn get_name(&self) -> &'static str { - match self { - LibXCFamily::LDA => "LDA", - LibXCFamily::GGA => "GGA", - LibXCFamily::MGGA => "MGGA", - LibXCFamily::HybridGGA => "HybridGGA", - LibXCFamily::HybridMGGA => "HybridMGGA", - LibXCFamily::Unknown => "Unknown DFA", - } - } -} - -pub fn get_libxc_family(func: &LibXCFunctional) -> LibXCFamily { - LibXCFamily::from_libxc(func.family()) -} - -pub fn use_density_gradient(func: &LibXCFunctional) -> bool { - !matches!(get_libxc_family(func), LibXCFamily::LDA) -} - -pub fn use_kinetic_density(func: &LibXCFunctional) -> bool { - matches!( - get_libxc_family(func), - LibXCFamily::MGGA | LibXCFamily::HybridMGGA - ) -} - pub fn xc_code_fdqc(name: &str) -> [usize; 3] { let lower_name = name.to_lowercase(); if lower_name == "hf" { @@ -261,36 +212,6 @@ pub fn eval_libxc_func_new( mod tests { use super::*; - #[test] - fn test_compat_family_lda() { - let func = xc_func_init(1, 1); - assert_eq!(get_libxc_family(&func), LibXCFamily::LDA); - } - - #[test] - fn test_compat_family_gga() { - let func = xc_func_init(101, 1); - assert_eq!(get_libxc_family(&func), LibXCFamily::GGA); - } - - #[test] - fn test_compat_family_mgga() { - let func = xc_func_init(263, 1); - assert_eq!(get_libxc_family(&func), LibXCFamily::MGGA); - } - - #[test] - fn test_compat_family_hyb_gga() { - let func = xc_func_init(402, 1); - assert_eq!(get_libxc_family(&func), LibXCFamily::HybridGGA); - } - - #[test] - fn test_compat_family_hyb_mgga() { - let func = xc_func_init(457, 1); - assert_eq!(get_libxc_family(&func), LibXCFamily::HybridMGGA); - } - #[test] fn test_xc_code_fdqc_pbe() { let code = xc_code_fdqc("pbe"); @@ -309,14 +230,6 @@ mod tests { assert!(!name.is_empty()); } - #[test] - fn test_use_density_gradient() { - let lda = xc_func_init(1, 1); - assert!(!use_density_gradient(&lda)); - let gga = xc_func_init(101, 1); - assert!(use_density_gradient(&gga)); - } - #[test] fn test_is_hyb_cam() { let cam = xc_func_init(433, 1); diff --git a/src/dft/libxc_itrf.rs b/src/dft/libxc_itrf.rs index 887b69932d..6e5f4e5655 100644 --- a/src/dft/libxc_itrf.rs +++ b/src/dft/libxc_itrf.rs @@ -5,7 +5,8 @@ xc functional interface to Libxc for REST use core::panic; use rayon::prelude::*; use rstsr::prelude::*; -use crate::dft::libxc_helper::{LibXCFamily, get_libxc_family, xc_func_init, eval_libxc_func_new}; +use libxc::prelude::*; +use crate::dft::libxc_helper::{xc_func_init, eval_libxc_func_new}; use crate::dft::xc_deriv::{XCType, xc_indices_transform, transform_xc_inner, count_combinations}; @@ -188,13 +189,13 @@ fn eval_xc1( |(func_id, xc_param)| { let xc_func = xc_func_init(*func_id, spin+1); - let cur_xc_type = match get_libxc_family(&xc_func) { + let cur_xc_type = match xc_func.family() { LibXCFamily::LDA => XCType::LDA, LibXCFamily::GGA => XCType::GGA, LibXCFamily::MGGA => XCType::MGGA, - LibXCFamily::HybridGGA => XCType::GGA, // Hybrid GGA is treated as GGA - LibXCFamily::HybridMGGA => XCType::MGGA, // Hybrid MGGA is treated as MGGA - _ => panic!("Unresolved xc family: {:?}", get_libxc_family(&xc_func)), + LibXCFamily::HybGGA => XCType::GGA, // Hybrid GGA is treated as GGA + LibXCFamily::HybMGGA => XCType::MGGA, // Hybrid MGGA is treated as MGGA + xc_family => panic!("Unresolved xc family: {xc_family:?}"), }; let mut outbuf = vec![0.0; np * n_components]; eval_libxc_func_new(&xc_func, spin, deriv, np, rho, sigma, lapl, tau, &mut outbuf); diff --git a/src/dft/mod.rs b/src/dft/mod.rs index b907accfc6..aef80785e2 100644 --- a/src/dft/mod.rs +++ b/src/dft/mod.rs @@ -35,8 +35,8 @@ use std::ops::Range; use std::sync::mpsc::channel; use serde::{Deserialize, Serialize}; -use libxc::functional::LibXCFunctional; -use crate::dft::libxc_helper::{LibXCFamily, get_libxc_family, use_density_gradient, use_kinetic_density, xc_code_fdqc, xc_code_to_name, xc_func_init, lda_exc_vxc, gga_exc_vxc, mgga_exc_vxc, lda_exc, gga_exc, mgga_exc}; +use libxc::prelude::*; +use crate::dft::libxc_helper::{xc_code_fdqc, xc_code_to_name, xc_func_init, lda_exc_vxc, gga_exc_vxc, mgga_exc_vxc, lda_exc, gga_exc, mgga_exc}; use rest_tensors::matrix_blas_lapack::{omp_get_num_threads_wrapper, omp_set_num_threads_wrapper}; @@ -83,13 +83,13 @@ impl DFAFamily { DFAFamily::LDA => LibXCFamily::LDA, DFAFamily::GGA => LibXCFamily::GGA, DFAFamily::MGGA => LibXCFamily::MGGA, - DFAFamily::HybridGGA => LibXCFamily::HybridGGA, - DFAFamily::HybridMGGA => LibXCFamily::HybridMGGA, - DFAFamily::PT2 => LibXCFamily::HybridGGA, - DFAFamily::SBGE2 => LibXCFamily::HybridGGA, - DFAFamily::SCSRPA => LibXCFamily::HybridGGA, + DFAFamily::HybridGGA => LibXCFamily::HybGGA, + DFAFamily::HybridMGGA => LibXCFamily::HybMGGA, + DFAFamily::PT2 => LibXCFamily::HybGGA, + DFAFamily::SBGE2 => LibXCFamily::HybGGA, + DFAFamily::SCSRPA => LibXCFamily::HybGGA, DFAFamily::RPA => LibXCFamily::GGA, - _ => LibXCFamily::Unknown, + DFAFamily::Unknown => panic!("Unknown DFA family cannot be converted to a specific libxc family"), } } pub fn from_libxc_family(family: &LibXCFamily) -> DFAFamily { @@ -97,8 +97,8 @@ impl DFAFamily { LibXCFamily::LDA => DFAFamily::LDA, LibXCFamily::GGA => DFAFamily::GGA, LibXCFamily::MGGA => DFAFamily::MGGA, - LibXCFamily::HybridGGA => DFAFamily::HybridGGA, - LibXCFamily::HybridMGGA => DFAFamily::HybridMGGA, + LibXCFamily::HybGGA => DFAFamily::HybridGGA, + LibXCFamily::HybMGGA => DFAFamily::HybridMGGA, _ => DFAFamily::Unknown, } } @@ -1179,27 +1179,24 @@ impl DFA4REST { pub fn use_density_gradient(&self) -> bool { - let mut is_flag = self.dfa_compnt_scf.iter().fold(false, |acc, xc_func| { - acc || use_density_gradient(&self.init_libxc(xc_func)) - }); - if let Some(dfa_compnt_pos) = &self.dfa_compnt_pos { - is_flag = is_flag || dfa_compnt_pos.iter().fold(false, |acc, xc_func| { - acc || use_density_gradient(&self.init_libxc(xc_func)) - }); - } - is_flag + self + .dfa_compnt_pos + .iter() + .flatten() + .chain(self.dfa_compnt_scf.iter()) + .any(|xc_func_id| { + // Only LDA and HybLDA do not need density gradient + !matches!(self.init_libxc(xc_func_id).family(), libxc::enums::LibXCFamily::LDA | libxc::enums::LibXCFamily::HybLDA) + }) } pub fn use_kinetic_density(&self) -> bool { - let mut is_flag = self.dfa_compnt_scf.iter().fold(false, |acc, xc_func| { - acc || use_kinetic_density(&self.init_libxc(xc_func)) - }); - if let Some(dfa_compnt_pos) = &self.dfa_compnt_pos { - is_flag = is_flag || dfa_compnt_pos.iter().fold(false, |acc, xc_func| { - acc || use_kinetic_density(&self.init_libxc(xc_func)) - }); - } - is_flag + self + .dfa_compnt_pos + .iter() + .flatten() + .chain(self.dfa_compnt_scf.iter()) + .any(|xc_func_id| self.init_libxc(xc_func_id).needs_tau()) } pub fn xc_exc_vxc(&self, grids: &Grids, spin_channel: usize, dm: &Vec>, mo: &[MatrixFull;2], occ: &[Vec;2], print_level:usize) -> (Vec, Vec>) { @@ -1237,7 +1234,7 @@ impl DFA4REST { self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); - match get_libxc_family(&xc_func) { + match xc_func.family() { LibXCFamily::LDA => { if spin_channel==1 { let (tmp_exc,tmp_vrho) = lda_exc_vxc(&xc_func,rho.data_ref().unwrap()); @@ -1255,7 +1252,7 @@ impl DFA4REST { vrho.par_self_scaled_add(&tmp_vrho.transpose_and_drop(),*xc_para); } }, - LibXCFamily::GGA | LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho, tmp_vsigma) = gga_exc_vxc(&xc_func,rho.data_ref().unwrap(),sigma.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); @@ -1274,7 +1271,7 @@ impl DFA4REST { vsigma.par_self_scaled_add(&tmp_vsigma.transpose_and_drop(), *xc_para); } }, - _ => {println!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} + xc_family => panic!("{xc_family:?} is not yet implemented") } }); @@ -1493,7 +1490,7 @@ impl DFA4REST { self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); - match get_libxc_family(&xc_func) { + match xc_func.family() { LibXCFamily::LDA => { if spin_channel==1 { let (tmp_exc,tmp_vrho) = lda_exc_vxc(&xc_func,loc_rho.data_ref().unwrap()); @@ -1511,7 +1508,7 @@ impl DFA4REST { loc_vrho.self_scaled_add(&tmp_vrho.transpose_and_drop(),*xc_para); } }, - LibXCFamily::GGA | LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho, tmp_vsigma) = gga_exc_vxc(&xc_func,loc_rho.data_ref().unwrap(),loc_sigma.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); @@ -1530,7 +1527,7 @@ impl DFA4REST { loc_vsigma.self_scaled_add(&tmp_vsigma.transpose_and_drop(), *xc_para); } }, - LibXCFamily::MGGA | LibXCFamily::HybridMGGA => { + LibXCFamily::MGGA | LibXCFamily::HybMGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho,tmp_vsigma,tmp_valpl,tmp_vtau) = mgga_exc_vxc(&xc_func, @@ -1567,7 +1564,7 @@ impl DFA4REST { loc_vtau.self_scaled_add(&tmp_vtau.transpose_and_drop(), *xc_para); } }, - _ => {println!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} + xc_family => panic!("{xc_family:?} is not yet implemented"), } }); @@ -1828,7 +1825,7 @@ impl DFA4REST { self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); - match get_libxc_family(&xc_func) { + match xc_func.family() { LibXCFamily::LDA => { if spin_channel==1 { let (tmp_exc,tmp_vrho) = lda_exc_vxc(&xc_func,loc_rho.data_ref().unwrap()); @@ -1846,7 +1843,7 @@ impl DFA4REST { loc_vrho.self_scaled_add(&tmp_vrho.transpose_and_drop(),*xc_para); } }, - LibXCFamily::GGA | LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho, tmp_vsigma) = gga_exc_vxc(&xc_func,loc_rho.data_ref().unwrap(),loc_sigma.data_ref().unwrap()); let tmp_exc = MatrixFull::from_vec([num_grids,1],tmp_exc).unwrap(); @@ -1865,7 +1862,7 @@ impl DFA4REST { loc_vsigma.self_scaled_add(&tmp_vsigma.transpose_and_drop(), *xc_para); } }, - LibXCFamily::MGGA | LibXCFamily::HybridMGGA => { + LibXCFamily::MGGA | LibXCFamily::HybMGGA => { if spin_channel==1 { let (tmp_exc,tmp_vrho,tmp_vsigma,tmp_valpl,tmp_vtau) = mgga_exc_vxc(&xc_func, @@ -1902,7 +1899,7 @@ impl DFA4REST { loc_vtau.self_scaled_add(&tmp_vtau.transpose_and_drop(), *xc_para); } }, - _ => {println!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} + xc_family => panic!("{xc_family:?} is not yet implemented"), } }); @@ -2103,7 +2100,7 @@ impl DFA4REST { let code = DFA4REST::xc_func_init_fdqc(x,spin_channel); let x_flag = code.iter().fold(false, |flag, xc_code| { let xc_func = self.init_libxc(xc_code); - flag || use_density_gradient(&xc_func) + flag || !matches!(xc_func.family(), LibXCFamily::LDA | LibXCFamily::HybLDA) }); flag || x_flag }); @@ -2316,7 +2313,7 @@ impl DFA4REST { //let (rho,rhop) = grids.prepare_tabulated_density(dm, spin_channel); let use_density_gradient = xc_code_list.iter().fold(false,|flag, xc_code| { let xc_func = self.init_libxc(xc_code); - flag || use_density_gradient(&xc_func) + flag || !matches!(xc_func.family(), LibXCFamily::LDA | LibXCFamily::HybLDA) }); let sigma = if use_density_gradient { prepare_tabulated_sigma_rayon(&rhop, spin_channel) @@ -2385,7 +2382,7 @@ impl DFA4REST { //}; self.dfa_compnt_scf.iter().zip(self.dfa_paramr_scf.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); - match get_libxc_family(&xc_func) { + match xc_func.family() { LibXCFamily::LDA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { @@ -2396,7 +2393,7 @@ impl DFA4REST { ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - LibXCFamily::GGA | LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybGGA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { gga_exc(&xc_func,rho.data_ref().unwrap(),sigma.data_ref().unwrap()) @@ -2406,7 +2403,7 @@ impl DFA4REST { ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - LibXCFamily::MGGA | LibXCFamily::HybridMGGA => { + LibXCFamily::MGGA | LibXCFamily::HybMGGA => { let tmp_exc = MatrixFull::from_vec( [num_grids, 1], if spin_channel==1 { @@ -2417,14 +2414,14 @@ impl DFA4REST { ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - _ => {println!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} + xc_family => panic!("{xc_family:?} is not yet implemented"), } }); } else if iop==1 { // for the post-SCF energy calculation if let (Some(dfa_paramr),Some(dfa_compnt)) = (&self.dfa_paramr_pos, &self.dfa_compnt_pos) { dfa_compnt.iter().zip(dfa_paramr.iter()).for_each(|(xc_func,xc_para)| { let xc_func = self.init_libxc(xc_func); - match get_libxc_family(&xc_func) { + match xc_func.family() { LibXCFamily::LDA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { @@ -2435,7 +2432,7 @@ impl DFA4REST { ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - LibXCFamily::GGA | LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybGGA => { let tmp_exc = MatrixFull::from_vec([num_grids,1], if spin_channel==1 { gga_exc(&xc_func,rho.data_ref().unwrap(),sigma.data_ref().unwrap()) @@ -2445,7 +2442,7 @@ impl DFA4REST { ).unwrap(); exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - _ => {println!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} + xc_family => panic!("{xc_family:?} is not yet implemented") } }); } @@ -2483,7 +2480,7 @@ impl DFA4REST { pub fn xc_exc_code(&self, xc_code: &usize, rho: &MatrixFull, sigma:&MatrixFull, spin_channel: usize) -> MatrixFull { let xc_func = self.init_libxc(xc_code); let num_grids = rho.size()[0]; - let tmp_exc = match get_libxc_family(&xc_func) { + let tmp_exc = match xc_func.family() { LibXCFamily::LDA => { MatrixFull::from_vec([num_grids,1], if spin_channel==1 { @@ -2494,7 +2491,7 @@ impl DFA4REST { ).unwrap() //exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - LibXCFamily::GGA | LibXCFamily::HybridGGA => { + LibXCFamily::GGA | LibXCFamily::HybGGA => { //println!("debug, {:?}, {:?}, {:?}", xc_code, xc_func, sigma.data.len()); MatrixFull::from_vec([num_grids,1], if spin_channel==1 { @@ -2505,7 +2502,7 @@ impl DFA4REST { ).unwrap() //exc.par_self_scaled_add(&tmp_exc,*xc_para); }, - _ => {panic!("{} is not yet implemented", get_libxc_family(&xc_func).get_name())} + xc_family => panic!("{xc_family:?} is not yet implemented"), }; tmp_exc } -- Gitee From df8ec31ef22f0e00feb224190dd2a8e4d734f3a8 Mon Sep 17 00:00:00 2001 From: ajz34 Date: Sat, 16 May 2026 09:34:39 +0800 Subject: [PATCH 06/10] removed xc_code_to_name and minor refactor --- src/dft/libxc_helper.rs | 14 +++++--------- src/dft/mod.rs | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/dft/libxc_helper.rs b/src/dft/libxc_helper.rs index c6a14975e0..5db522c5f5 100644 --- a/src/dft/libxc_helper.rs +++ b/src/dft/libxc_helper.rs @@ -184,7 +184,7 @@ pub fn eval_libxc_func_new( sigma: Option<&[f64]>, lapl: Option<&[f64]>, tau: Option<&[f64]>, - exc: &mut [f64], + outbuf: &mut [f64], ) { assert!(deriv <= 3, "Derivative order must be 0, 1, 2 or 3"); let _ = (spin, np); @@ -200,11 +200,13 @@ pub fn eval_libxc_func_new( } } if let Some(t) = tau { - input.insert("tau".to_string(), t); + if xc_func.needs_tau() { + input.insert("tau".to_string(), t); + } } xc_func - .compute_xc_with_unsliced_output(&input, exc, deriv) + .compute_xc_with_unsliced_output(&input, outbuf, deriv) .unwrap(); } @@ -224,12 +226,6 @@ mod tests { assert_eq!(code, [402, 0, 0]); } - #[test] - fn test_code_to_name() { - let name = xc_code_to_name(1); - assert!(!name.is_empty()); - } - #[test] fn test_is_hyb_cam() { let cam = xc_func_init(433, 1); diff --git a/src/dft/mod.rs b/src/dft/mod.rs index aef80785e2..ed702c577b 100644 --- a/src/dft/mod.rs +++ b/src/dft/mod.rs @@ -36,7 +36,7 @@ use std::sync::mpsc::channel; use serde::{Deserialize, Serialize}; use libxc::prelude::*; -use crate::dft::libxc_helper::{xc_code_fdqc, xc_code_to_name, xc_func_init, lda_exc_vxc, gga_exc_vxc, mgga_exc_vxc, lda_exc, gga_exc, mgga_exc}; +use crate::dft::libxc_helper::{xc_code_fdqc, xc_func_init, lda_exc_vxc, gga_exc_vxc, mgga_exc_vxc, lda_exc, gga_exc, mgga_exc}; use rest_tensors::matrix_blas_lapack::{omp_get_num_threads_wrapper, omp_set_num_threads_wrapper}; @@ -2189,7 +2189,7 @@ impl DFA4REST { self.dfa_compnt_scf.iter().enumerate().for_each(|(i_xc, xc)| { //if spin_channel == 1 { - str_lines[0].push_str(&format!("{:>20} ", &xc_code_to_name(*xc))); + str_lines[0].push_str(&format!("{:>20} ", libxc::util::libxc_functional_get_name(*xc as i32).unwrap_or_else(|| "Unknown_XC".to_string()))); //} else { // str_lines[0].push_str(&format!("{:>20}_alpha ", &code_to_name(*xc))); // str_lines[0].push_str(&format!("{:>20}_beta ", &code_to_name(*xc))); -- Gitee From ba4b831508c6b7eab7ab6ef28e011fa63179073f Mon Sep 17 00:00:00 2001 From: ajz34 Date: Sat, 16 May 2026 09:35:11 +0800 Subject: [PATCH 07/10] cargo fmt --- src/dft/libxc_helper.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/dft/libxc_helper.rs b/src/dft/libxc_helper.rs index 5db522c5f5..edb7b80ce7 100644 --- a/src/dft/libxc_helper.rs +++ b/src/dft/libxc_helper.rs @@ -70,9 +70,7 @@ pub fn xc_code_fdqc(name: &str) -> [usize; 3] { } else { for (name, value) in LIBXC_FUNC_MAP.iter() { let prefixed = format!("XC_{}", name); - if prefixed.starts_with("XC_") - && format!("xc_{}", lower_name) == prefixed.to_lowercase() - { + if prefixed.starts_with("XC_") && format!("xc_{}", lower_name) == prefixed.to_lowercase() { if name.contains("_XC_") { return [*value as usize, 0, 0]; } else if name.contains("_C_") { @@ -94,11 +92,7 @@ pub fn xc_code_to_name(code: usize) -> String { } pub fn xc_func_init(func_id: usize, spin_channel: usize) -> LibXCFunctional { - let spin = if spin_channel == 1 { - LibXCSpin::Unpolarized - } else { - LibXCSpin::Polarized - }; + let spin = if spin_channel == 1 { LibXCSpin::Unpolarized } else { LibXCSpin::Polarized }; LibXCFunctional::from_number(func_id as i32, spin) } @@ -140,10 +134,7 @@ pub fn mgga_exc_vxc( let exc = buf[layout.get("zk").unwrap()].to_vec(); let vrho = buf[layout.get("vrho").unwrap()].to_vec(); let vsigma = buf[layout.get("vsigma").unwrap()].to_vec(); - let vlapl = layout - .get("vlapl") - .map(|r| buf[r].to_vec()) - .unwrap_or_default(); + let vlapl = layout.get("vlapl").map(|r| buf[r].to_vec()).unwrap_or_default(); let vtau = buf[layout.get("vtau").unwrap()].to_vec(); (exc, vrho, vsigma, vlapl, vtau) } @@ -205,9 +196,7 @@ pub fn eval_libxc_func_new( } } - xc_func - .compute_xc_with_unsliced_output(&input, outbuf, deriv) - .unwrap(); + xc_func.compute_xc_with_unsliced_output(&input, outbuf, deriv).unwrap(); } #[cfg(test)] -- Gitee From 5f312d2fec82212069e7c3403038485d1b3a2d45 Mon Sep 17 00:00:00 2001 From: ajz34 Date: Sat, 16 May 2026 10:29:01 +0800 Subject: [PATCH 08/10] cleanup and necessary docstring --- src/dft/libxc_helper.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dft/libxc_helper.rs b/src/dft/libxc_helper.rs index edb7b80ce7..79c2b6a89a 100644 --- a/src/dft/libxc_helper.rs +++ b/src/dft/libxc_helper.rs @@ -87,10 +87,13 @@ pub fn xc_code_fdqc(name: &str) -> [usize; 3] { } } -pub fn xc_code_to_name(code: usize) -> String { - libxc::util::libxc_functional_get_name(code as i32).unwrap_or_else(|| "Unknown_XC".to_string()) -} - +/// Initialize a LibXC functional based on the given function ID and spin channel. +/// +/// - 1 for unpolarized (spin-unpolarized) calculations +/// - 2 for polarized (spin-polarized) calculations +/// +/// This number may different to PySCF convention, but should be consistent with REST and Libxc conventions. +/// Number of spin channels means for rho/tau/lapl, how many spin components are there. pub fn xc_func_init(func_id: usize, spin_channel: usize) -> LibXCFunctional { let spin = if spin_channel == 1 { LibXCSpin::Unpolarized } else { LibXCSpin::Polarized }; LibXCFunctional::from_number(func_id as i32, spin) -- Gitee From f1cbc1ec57ac600ffa5ffd7c2d6f4e898ceb24dc Mon Sep 17 00:00:00 2001 From: ajz34 Date: Sat, 16 May 2026 10:38:24 +0800 Subject: [PATCH 09/10] remove some build dependencies --- Cargo.toml | 4 +--- build.rs | 12 ++++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c22faeec32..063757b7c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,9 +67,7 @@ approx = "0.5" assert_float_eq = "1" [build-dependencies] -autocxx-build = "0.26.0" -miette = { version = "5", features = ["fancy"]} -dunce = "1.0.0" +dunce = "1.0" [dependencies.pyo3] version = "0.24.2" diff --git a/build.rs b/build.rs index 851bbed26b..d962bc115b 100644 --- a/build.rs +++ b/build.rs @@ -2,7 +2,7 @@ extern crate dunce; use std::env; use std::path::PathBuf; -fn main() -> miette::Result<()> { +fn main() { // conditionally link to the libraries based on the features #[cfg(feature = "intel-mkl")] { @@ -13,9 +13,9 @@ fn main() -> miette::Result<()> { println!("cargo:rustc-link-search={}/lib",&blas_dir.display()); } - // AJZ34: After dftd3/4 v0.2, by default we support dynamic loading. - // libs-dftd3.so, libdftd4.so are not necessarily linked at compile time. - // User should specify those libraries if dftd3/4 computation requested (by conda or LD_LIBRARY_PATH). + // AJZ34: After dftd3/4 v0.2, libxc v0.1, by default we support dynamic loading. + // libs-dftd3.so, libdftd4.so, libxc.so are not necessarily linked at compile time. + // User should specify those libraries if dftd3/4/libxc computation requested (by conda or LD_LIBRARY_PATH). // // #[cfg(feature = "dftd3")] // println!("cargo:rustc-link-lib=s-dftd3"); @@ -39,8 +39,4 @@ fn main() -> miette::Result<()> { println!("cargo:rustc-link-search={}",env::join_paths(&[path]).unwrap().to_str().unwrap()) }); //println!("cargo:rustc-link-arg=-Wl,--no-as-needed,-lgomp"); - - - Ok(()) - } -- Gitee From 11029fe9e30d3df0f47d7f26ab48e4629585bac2 Mon Sep 17 00:00:00 2001 From: ajz34 Date: Sat, 16 May 2026 10:49:30 +0800 Subject: [PATCH 10/10] remove unnecessary libxc-ffi crate import --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 063757b7c3..62b4df3b10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,6 @@ derive_builder = { version = "0.20" } dftd3 = { version = "0.2", optional = true } dftd4 = { version = "0.2", optional = true } libxc = { version = "0.1", features = ["api-v7_0", "dynamic_loading"] } -libxc-ffi = { version = "0.1" } geometric-pyo3 = { version = "0.1.1", optional = true } approx = "0.5" -- Gitee