4 个版本
0.1.3 | 2021 年 9 月 1 日 |
---|---|
0.1.2 | 2021 年 9 月 1 日 |
0.1.1 | 2021 年 8 月 31 日 |
0.1.0 | 2021 年 8 月 31 日 |
#3 在 #atm
26KB
436 行
rust-libcint
为 libcint (C) 提供包装器
lib.rs
:
rust-libcint
该 rust-libcint
包提供对 libcint (C) 的包装器。
为了使用此包,libcint 应该安装,并以库文件 libcint.so
存储在用户可访问的路径。
请访问 https://github.com/sunqm/libcint 了解关于安装和使用 libcint 的更多详细信息
CINTR2CDATA
结构体收集了使用 libcint
所需的所有数据。然后,将 libcint
提供的各种类型的分析高斯型轨道(GTO)积分作为定义在 CINTR2CDATA
结构体上的方法进行包装。
目前,只有四种积分可供使用,包括:1)单电子动能积分,2)单电子核吸引力积分,3)单电子重叠积分和4)双电子排斥积分,这些积分既可以用于球面GTO,也可以用于笛卡尔GTO。其他类型的积分在当前版本中尚未准备好。
示例
//=============================================================================
// Prepare `atm`, `bas` and `env` with the same data structures of those used by `libcint`.
// Refer to <https://github.com/sunqm/libcint/blob/master/doc/program_ref.pdf>
// for the details of these data structures.
//=============================================================================
use rust_libcint::{CINTR2CDATA,CintType};
let mut atm: Vec<Vec<i32>> = vec![];
atm.push(vec![2,0,0,0,0,0]);
atm.push(vec![4,3,0,0,0,0]);
let mut natm = atm.len() as i32;
let mut bas: Vec<Vec<i32>> = vec![];
bas.push(vec![0,1,1,1,1,6,7,0]);
bas.push(vec![0,2,1,1,1,8,9,0]);
let mut nbas = bas.len() as i32;
let mut env: Vec<f64> = vec![0.0,0.0,0.0,0.7,0.0,0.0,1.0,1.0,0.5,1.0];
let mut cint_data = CINTR2CDATA::new();
// Transfer `atm`, `bas`, and `env` to the raw pointers,
// and organize them by the `CINTR2CDATA` structure.
cint_data.initial_r2c(&atm,natm,&bas,nbas,env);
//=============================================================================
//The 2-electron repulsive integrals (ERIs) for spheric Gaussian-type orbitals
//=============================================================================
// The GTO functions considered here are shperic.
// For Cartesian GTOs, replace `CintType::Spheric` by
// `CintType::Cartesian` on the following line:
cint_data.set_cint_type(CintType::Spheric);
cint_data.cint2e_optimizer_rust();
let buf = cint_data.cint_ijkl(0,1,1,0);
let mut v1:f64=0.0;
&buf.into_iter().for_each(|i| {v1 += i.abs()});
println!("The reference data for cint2e ERIs: 0.5745411555937561; v1: {:18.16}; ",v1);
//=============================================================================
//The one-electron overlap integrals for spheric Gaussian-type orbitals
//=============================================================================
cint_data.cint_del_optimizer_rust();
// The GTO functions considered here are shperic
cint_data.set_cint_type(CintType::Spheric);
cint_data.cint1e_ovlp_optimizer_rust();
let buf = cint_data.cint_ijovlp(0,1);
let mut v1:f64=0.0;
&buf.into_iter().for_each(|i| {v1 += i.abs()});
println!("The reference data for cint1e_ovlp: 0.7096366827378776; v1: {:18.16}; ",v1);
//=============================================================================
//The one-electron kinetic integrals for Cartesian Gaussian-type orbitals
//=============================================================================
cint_data.cint_del_optimizer_rust();
// The GTO functions considered here are Cartesian
cint_data.set_cint_type(CintType::Cartesian);
cint_data.cint1e_kin_optimizer_rust();
let buf = cint_data.cint_ijkin(0,1);
let mut v1:f64=0.0;
&buf.into_iter().for_each(|i| {v1 += i.abs()});
println!("The reference data for cint1e_kin : 1.5780816190296618; v1: {:18.16}; ",v1);
//=============================================================================
//The one-electron nuclear attraction integrals for Cartesian Gaussian-type orbitals
//=============================================================================
cint_data.cint_del_optimizer_rust();
// The GTO functions considered here are Cartesian
cint_data.set_cint_type(CintType::Cartesian);
cint_data.cint1e_nuc_optimizer_rust();
let buf = cint_data.cint_ijnuc(0,1);
let mut v1:f64=0.0;
&buf.into_iter().for_each(|i| {v1 += i.abs()});
println!("The reference data for cint1e_nuc : 4.0007622494430706; v1: {:18.16}; ",v1);
//=============================================================================
// Finally deallocate the memory by transferring the raw pointers back to RUST
// i.e. Vec::from_raw_parts();
//=============================================================================
cint_data.final_c2r();