1use super::*;
10use core::ffi::{c_int, c_void};
11
12#[doc = " @brief Creates a new cuEST handle and its associated resources from a parameter structure.\n @ingroup Context\n\n Ownership of handles or pointers passed into the structure is NOT transferred.\n Default parameters will construct a generic GPU context.\n\n Requirements:\n - A cudaStream alone may be provided, all others may be left NULL.\n - If cuBLAS or cuSolver handles are specified, a cudaStream must also be specified.\n - When cuBLAS or cuSolver handles are specified, these handles must be set\n to operate on the provided cudaStream. (i.e. by calling \\c cublasSetStream\n or \\c cusolverDnSetStream with the provided cudaStream);\n\n @param[in] parameters Parameter structure handle (must not be NULL).\n @param[out] handle Pointer to opaque cuEST handle for output.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success,\n - \\c CUEST_STATUS_NULL_POINTER if \\c parameters or \\c handle is NULL,\n - \\c CUEST_STATUS_INVALID_TYPE if \\c parameters is not of the \\c cuestHandleParameters_t type,\n - \\c CUEST_STATUS_UNSUPPORTED_ARCHITECTURE if the GPU architecture is not supported by cuEST,\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a handle parameter value is invalid (e.g. an invalid JIT compile-thread count or an unsafe JIT cache directory),\n - \\c CUEST_STATUS_HOME_NOT_FOUND if no JIT cache directory was specified and the HOME environment variable is unset or empty,\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
13pub unsafe fn cuestCreate(
14 parameters: cuestHandleParameters_t,
15 handle: *mut cuestHandle_t,
16) -> cuestStatus_t {
17 dyload_lib().cuestCreate.expect("cuEST function `cuestCreate` not found in the loaded library")(
18 parameters, handle,
19 )
20}
21
22#[doc = " @brief Destroys a cuEST handle and all associated resources.\n @ingroup Context\n\n Frees memory for GPU resources, quadrature data, solid harmonics coefficients, and rys table.\n\n @param[in] handle Opaque cuEST handle to destroy (must not be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success,\n - \\c CUEST_STATUS_NULL_POINTER if handle is NULL,\n - \\c CUEST_STATUS_INVALID_TYPE if handle is not of the \\c cuestHandle_t type,\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
23pub unsafe fn cuestDestroy(handle: cuestHandle_t) -> cuestStatus_t {
24 dyload_lib()
25 .cuestDestroy
26 .expect("cuEST function `cuestDestroy` not found in the loaded library")(handle)
27}
28
29#[doc = " @brief Sets the math mode used when cuEST functions are called with this handle.\n @ingroup Context\n\n @param[in,out] handle Opaque cuEST handle (must not be NULL).\n @param[in] mode Math mode enum.\n\n - \\c CUEST_DEFAULT_MATH_MODE cuEST will use algorithms that are determined heuristically\n to maximize performance. Some results may use mixed precision arithmetic.\n - \\c CUEST_NATIVE_FP64_MATH_MODE cuEST will use FP64 arithmetic everywhere.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success,\n - \\c CUEST_STATUS_INVALID_HANDLE if handle is NULL,\n - \\c CUEST_STATUS_INVALID_TYPE if handle is not of the \\c cuestHandle_t type,\n - \\c CUEST_STATUS_INVALID_ARGUMENT if the \\c cuestMathMode_t is invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
30pub unsafe fn cuestSetMathMode(handle: cuestHandle_t, mode: cuestMathMode_t) -> cuestStatus_t {
31 dyload_lib()
32 .cuestSetMathMode
33 .expect("cuEST function `cuestSetMathMode` not found in the loaded library")(
34 handle, mode
35 )
36}
37
38#[doc = " @brief Gets the math mode associated with this handle.\n @ingroup Context\n\n @param[in] handle Opaque cuEST handle (must not be NULL).\n @param[out] mode Math mode enum (must not be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success,\n - \\c CUEST_STATUS_INVALID_HANDLE if handle is NULL,\n - \\c CUEST_STATUS_NULL_POINTER if mode is NULL,\n - \\c CUEST_STATUS_INVALID_TYPE if handle is not of the \\c cuestHandle_t type,\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
39pub unsafe fn cuestGetMathMode(handle: cuestHandle_t, mode: *mut cuestMathMode_t) -> cuestStatus_t {
40 dyload_lib()
41 .cuestGetMathMode
42 .expect("cuEST function `cuestGetMathMode` not found in the loaded library")(
43 handle, mode
44 )
45}
46
47#[doc = " @brief Sets the compute capability used in heuristics to determine the most performant code path.\n @ingroup Context\n\n @param[in,out] handle Opaque cuEST handle (must not be NULL).\n @param[in] targetMajorVersion Compute capability target major version.\n @param[in] targetMinorVersion Compute capability target minor version.\n\n Notes:\n - Manually setting the compute capability target is not recommended for production calculations.\n This option is intended only to compare numerical performance of the same algorithm on different\n architectures.\n - Not all algorithms may be available on all architectures. Changing the compute capability\n target may result in exceptions during subsequent calls to cuEST.\n - The compute capability target only affects heuristics. It does not affect kernel execution\n or JIT compilation.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success,\n - \\c CUEST_STATUS_INVALID_HANDLE if handle is NULL,\n - \\c CUEST_STATUS_INVALID_TYPE if handle is not of the \\c cuestHandle_t type,\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
48pub unsafe fn cuestSetComputeCapabilityTarget(
49 handle: cuestHandle_t,
50 targetMajorVersion: u32,
51 targetMinorVersion: u32,
52) -> cuestStatus_t {
53 dyload_lib()
54 .cuestSetComputeCapabilityTarget
55 .expect("cuEST function `cuestSetComputeCapabilityTarget` not found in the loaded library")(
56 handle,
57 targetMajorVersion,
58 targetMinorVersion,
59 )
60}
61
62#[doc = " @brief Gets the compute capability used in heuristics to determine the most performant code path.\n @ingroup Context\n\n @param[in] handle Opaque cuEST handle (must not be NULL).\n @param[out] targetMajorVersion Compute capability target major version (must not be NULL).\n @param[out] targetMinorVersion Compute capability target minor version (must not be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success,\n - \\c CUEST_STATUS_INVALID_HANDLE if handle is NULL,\n - \\c CUEST_STATUS_INVALID_TYPE if handle is not of the \\c cuestHandle_t type,\n - \\c CUEST_STATUS_NULL_POINTER if targetMajorVersion or targetMinorVersion is NULL,\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
63pub unsafe fn cuestGetComputeCapabilityTarget(
64 handle: cuestHandle_t,
65 targetMajorVersion: *mut u32,
66 targetMinorVersion: *mut u32,
67) -> cuestStatus_t {
68 dyload_lib()
69 .cuestGetComputeCapabilityTarget
70 .expect("cuEST function `cuestGetComputeCapabilityTarget` not found in the loaded library")(
71 handle,
72 targetMajorVersion,
73 targetMinorVersion,
74 )
75}
76
77#[doc = " @brief Gets the major version of the cuEST library.\n @ingroup Context\n\n @param[in] handle Opaque cuEST handle (must not be NULL).\n @param[out] majorVersion Major version of the cuEST library (must not be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success,\n - \\c CUEST_STATUS_INVALID_HANDLE if handle is NULL,\n - \\c CUEST_STATUS_INVALID_TYPE if handle is not of the \\c cuestHandle_t type,\n - \\c CUEST_STATUS_NULL_POINTER if majorVersion is NULL,\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
78pub unsafe fn cuestGetMajorVersion(handle: cuestHandle_t, majorVersion: *mut u32) -> cuestStatus_t {
79 dyload_lib()
80 .cuestGetMajorVersion
81 .expect("cuEST function `cuestGetMajorVersion` not found in the loaded library")(
82 handle,
83 majorVersion,
84 )
85}
86
87#[doc = " @brief Gets the minor version of the cuEST library.\n @ingroup Context\n\n @param[in] handle Opaque cuEST handle (must not be NULL).\n @param[out] minorVersion Minor version of the cuEST library (must not be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success,\n - \\c CUEST_STATUS_INVALID_HANDLE if handle is NULL,\n - \\c CUEST_STATUS_INVALID_TYPE if handle is not of the \\c cuestHandle_t type,\n - \\c CUEST_STATUS_NULL_POINTER if minorVersion is NULL,\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
88pub unsafe fn cuestGetMinorVersion(handle: cuestHandle_t, minorVersion: *mut u32) -> cuestStatus_t {
89 dyload_lib()
90 .cuestGetMinorVersion
91 .expect("cuEST function `cuestGetMinorVersion` not found in the loaded library")(
92 handle,
93 minorVersion,
94 )
95}
96
97#[doc = " @brief Gets the patch version of the cuEST library.\n @ingroup Context\n\n @param[in] handle Opaque cuEST handle (must not be NULL).\n @param[out] patchVersion Patch version of the cuEST library (must not be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success,\n - \\c CUEST_STATUS_INVALID_HANDLE if handle is NULL,\n - \\c CUEST_STATUS_INVALID_TYPE if handle is not of the \\c cuestHandle_t type,\n - \\c CUEST_STATUS_NULL_POINTER if patchVersion is NULL,\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
98pub unsafe fn cuestGetPatchVersion(handle: cuestHandle_t, patchVersion: *mut u32) -> cuestStatus_t {
99 dyload_lib()
100 .cuestGetPatchVersion
101 .expect("cuEST function `cuestGetPatchVersion` not found in the loaded library")(
102 handle,
103 patchVersion,
104 )
105}
106
107#[doc = " @brief Create an AO shell object with specified parameters.\n @ingroup Basis\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] isPure Whether the shell uses pure (spherical) functions (any nonzero value is interpreted as true).\n @param[in] L Angular momentum quantum number (s=0, p=1, d=2, etc).\n @param[in] numPrimitive Number of Gaussian primitives; must be greater than zero.\n @param[in] exponents Pointer containing primitive exponents (size: \\c numPrimitive) on the CPU. Must not be NULL.\n @param[in] coefficients Pointer containing contraction coefficients (size: \\c numPrimitive) on the CPU. Must not be NULL.\n @param[in] parameters Handle to \\c cuestAOShellParameters_t. Must not be NULL.\n @param[out] outShell Pointer to output shell object; receives opaque handle on success. Must not be NULL.\n\n The contraction \\c coefficients passed to this function will be used verbatim. It is the user's responsibility\n to normalize the shells as desired. For more information see: \\verbatim embed:rst\n:ref:`cuest_primitive_normalization`\n\\endverbatim\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the cuEST handle or parameters are not of the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numPrimitive is zero;\n - \\c CUEST_STATUS_EXCEPTION for unexpected error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR for non-std exceptions."]
108pub unsafe fn cuestAOShellCreate(
109 handle: cuestHandle_t,
110 isPure: i32,
111 L: u64,
112 numPrimitive: u64,
113 exponents: *const f64,
114 coefficients: *const f64,
115 parameters: cuestAOShellParameters_t,
116 outShell: *mut cuestAOShell_t,
117) -> cuestStatus_t {
118 dyload_lib()
119 .cuestAOShellCreate
120 .expect("cuEST function `cuestAOShellCreate` not found in the loaded library")(
121 handle,
122 isPure,
123 L,
124 numPrimitive,
125 exponents,
126 coefficients,
127 parameters,
128 outShell,
129 )
130}
131
132#[doc = " @brief Destroy/free an AO shell object created with \\c cuestAOShellCreate.\n @ingroup Basis\n\n Frees all memory associated with the AO shell. After destruction, the shell handle must not be used.\n\n @param[in] shell Opaque AO shell handle to destroy. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c shell is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the \\c shell handle is not of the \\c cuestAOShell_t type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on error."]
133pub unsafe fn cuestAOShellDestroy(shell: cuestAOShell_t) -> cuestStatus_t {
134 dyload_lib()
135 .cuestAOShellDestroy
136 .expect("cuEST function `cuestAOShellDestroy` not found in the loaded library")(shell)
137}
138
139#[doc = " @brief Create an atomic orbital basis set object (AO basis).\n @ingroup Basis\n\n The AO basis comprises multiple AO shells, grouped by atomic center.\n - All buffer pointers must be valid (not NULL).\n - Each shell, and each array entry, must be valid.\n - The persistent and temporary workspaces must be provided and preallocated.\n - The output handle is only valid after successful creation.\n\n \\verbatim embed:rst\n.. Note:: After creating the `cuestAOBasis_t` basis handle, the array of `cuestAOShell_t` shell handles are no longer necessary and may be destroyed and any user provided input data to those shell handles may be freed.\n\\endverbatim\n\n \\verbatim embed:rst\n.. Important::\nBasis sets with \"holes\" in the shell angular momentum are not supported. That is, if a\nbasis function center has a p function (L=1), it must also have an s function (L=0). If it has\na d function (L=2), it must also have s and p functions present.\nA basis that violates this requirement is rejected with ``CUEST_STATUS_EXCEPTION``.\n\\endverbatim\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] numAtoms Total number of distinct atoms/centers; must be greater than zero.\n @param[in] numShellsPerAtom Array specifying number of shells per center (size: \\c numAtoms); each must be greater than zero. CPU array, must not be NULL.\n @param[in] shells Flat array of shell handles (\\c cuestAOShell_t), length is sum of \\c numShellsPerAtom.\n CPU array, the array must not be NULL and none of the entries may be NULL.\n @param[in] parameters Handle to \\c cuestAOBasisParameters_t. Must not be NULL.\n @param[in] persistentWorkspace Pointer to preallocated workspace for persistent buffers. Must not be NULL.\n @param[in] temporaryWorkspace Pointer to preallocated workspace for temporary buffers. Must not be NULL.\n @param[out] outBasis Pointer for output basis handle. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any pointer parameter is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the cuEST handle, any shell handle or parameters are not of the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numAtoms == 0 or any \\c numShellsPerAtom[i]==0;\n - \\c CUEST_STATUS_UNSUPPORTED_ARGUMENT if the AO basis mixes pure (solid-harmonic) and Cartesian shells;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on error."]
140pub unsafe fn cuestAOBasisCreate(
141 handle: cuestHandle_t,
142 numAtoms: u64,
143 numShellsPerAtom: *const u64,
144 shells: *const cuestAOShell_t,
145 parameters: cuestAOBasisParameters_t,
146 persistentWorkspace: *mut cuestWorkspace_t,
147 temporaryWorkspace: *mut cuestWorkspace_t,
148 outBasis: *mut cuestAOBasis_t,
149) -> cuestStatus_t {
150 dyload_lib()
151 .cuestAOBasisCreate
152 .expect("cuEST function `cuestAOBasisCreate` not found in the loaded library")(
153 handle,
154 numAtoms,
155 numShellsPerAtom,
156 shells,
157 parameters,
158 persistentWorkspace,
159 temporaryWorkspace,
160 outBasis,
161 )
162}
163
164#[doc = " @brief Query workspace requirements for creating an AO basis object.\n @ingroup Basis\n\n This function simulates the allocation logic to determine necessary persistent and temporary buffer sizes.\n All buffer pointers and arrays must be valid.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] numAtoms Total number of atoms/centers; must be greater than zero.\n @param[in] numShellsPerAtom Array specifying number of shells per center (size: \\c numAtoms); each must be greater than zero. CPU array, must not be NULL.\n @param[in] shells Flat array of shell handles (\\c cuestAOShell_t), length is sum of \\c numShellsPerAtom.\n CPU array, the array must not be NULL and none of the entries may be NULL.\n @param[in] parameters Handle to \\c cuestAOBasisParameters_t. Must not be NULL.\n @param[out] persistentWorkspaceDescriptor Output descriptor for persistent buffer sizing. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary buffer sizing. Must not be NULL.\n @param outBasis Pointer for output basis handle. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the cuEST handle, any shell handle or parameters are not of the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numAtoms == 0 or any \\c numShellsPerAtom[i]==0;\n - \\c CUEST_STATUS_UNSUPPORTED_ARGUMENT if the AO basis mixes pure (solid-harmonic) and Cartesian shells;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR for other errors."]
165pub unsafe fn cuestAOBasisCreateWorkspaceQuery(
166 handle: cuestHandle_t,
167 numAtoms: u64,
168 numShellsPerAtom: *const u64,
169 shells: *const cuestAOShell_t,
170 parameters: cuestAOBasisParameters_t,
171 persistentWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
172 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
173 outBasis: *mut cuestAOBasis_t,
174) -> cuestStatus_t {
175 dyload_lib()
176 .cuestAOBasisCreateWorkspaceQuery
177 .expect("cuEST function `cuestAOBasisCreateWorkspaceQuery` not found in the loaded library")(
178 handle,
179 numAtoms,
180 numShellsPerAtom,
181 shells,
182 parameters,
183 persistentWorkspaceDescriptor,
184 temporaryWorkspaceDescriptor,
185 outBasis,
186 )
187}
188
189#[doc = " @brief Destroy/free an AO basis set object and all associated resources.\n @ingroup Basis\n\n After this function is called, the basis handle must not be used.\n\n @param[in] basis AO basis set handle to destroy; must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if basis is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the cuEST AO basis handle is not of type \\c cuestAOBasis_t;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on error."]
190pub unsafe fn cuestAOBasisDestroy(basis: cuestAOBasis_t) -> cuestStatus_t {
191 dyload_lib()
192 .cuestAOBasisDestroy
193 .expect("cuEST function `cuestAOBasisDestroy` not found in the loaded library")(basis)
194}
195
196#[doc = " @brief Build an AO pair list structure.\n @ingroup Basis\n\n Constructs a sparse or dense pair list for efficient evaluation of integrals over AOs.\n All input pointers and buffers must be valid and not NULL.\n The number of atoms and xyz array length must match.\n Workspace buffers must be preallocated as returned by \\c cuestAOPairListCreateWorkspaceQuery.\n\n The cuestAOBasis_t basis handle used to construct the cuestAOPairList_t pair list handle\n is not needed for the pair list handle to be valid. However, in practice, use of the pair list\n will also require the cuestAOBasis_t basis handle and it should not be destroyed after creating\n the pair list.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] basis AO basis set handle (object describing basis for the atoms). Must not be NULL.\n @param[in] numAtoms Number of atoms in molecule or fragment. Must be greater than zero.\n @param[in] xyz Array of atomic Cartesian coordinates (length \\c numAtoms * 3) on the CPU. Ordering of elements is row-major: \\f$ [x_0, y_0, z_0, ...] \\f$ . Must not be NULL.\n @param[in] thresholdPQ Sparsity threshold for pair sieve (e.g., 1e-10). Must be non-negative.\n @param[in] parameters AO pair list parameters structure. Must not be NULL.\n @param[in] persistentWorkspace Pointer to persistent workspace (preallocated). Must not be NULL.\n @param[in] temporaryWorkspace Pointer to temporary workspace (preallocated). Must not be NULL.\n @param[out] outPairList Output pointer for AO pair list handle. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numAtoms == 0 or \\c thresholdPQ is negative;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on error."]
197pub unsafe fn cuestAOPairListCreate(
198 handle: cuestHandle_t,
199 basis: cuestAOBasis_t,
200 numAtoms: u64,
201 xyz: *const f64,
202 thresholdPQ: f64,
203 parameters: cuestAOPairListParameters_t,
204 persistentWorkspace: *mut cuestWorkspace_t,
205 temporaryWorkspace: *mut cuestWorkspace_t,
206 outPairList: *mut cuestAOPairList_t,
207) -> cuestStatus_t {
208 dyload_lib()
209 .cuestAOPairListCreate
210 .expect("cuEST function `cuestAOPairListCreate` not found in the loaded library")(
211 handle,
212 basis,
213 numAtoms,
214 xyz,
215 thresholdPQ,
216 parameters,
217 persistentWorkspace,
218 temporaryWorkspace,
219 outPairList,
220 )
221}
222
223#[doc = " @brief Query workspace requirements for AO pair list construction.\n @ingroup Basis\n\n Simulates memory usage to determine sizes of persistent and temporary buffers.\n All buffer and parameter pointers must be valid.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] basis AO basis set handle (object describing basis for the atoms); must not be NULL.\n @param[in] numAtoms Number of atoms. Must be greater than zero.\n @param[in] xyz Array of atomic Cartesian coordinates (length \\c numAtoms * 3) on the CPU. Ordering of elements is \\f$ [x_0, y_0, z_0, ...] \\f$. Must not be NULL.\n @param[in] thresholdPQ Sparsity threshold for pair sieve (e.g., 1e-10). Must be non-negative.\n @param[in] parameters AO pair list parameters structure. Must not be NULL.\n @param[out] persistentWorkspaceDescriptor Output workspace descriptor for persistent buffer sizing. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output workspace descriptor for temporary buffer sizing. Must not be NULL.\n @param outPairList Output pointer for AO pair list handle. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numAtoms == 0 or \\c thresholdPQ is negative;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
224pub unsafe fn cuestAOPairListCreateWorkspaceQuery(
225 handle: cuestHandle_t,
226 basis: cuestAOBasis_t,
227 numAtoms: u64,
228 xyz: *const f64,
229 thresholdPQ: f64,
230 parameters: cuestAOPairListParameters_t,
231 persistentWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
232 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
233 outPairList: *mut cuestAOPairList_t,
234) -> cuestStatus_t {
235 dyload_lib().cuestAOPairListCreateWorkspaceQuery.expect(
236 "cuEST function `cuestAOPairListCreateWorkspaceQuery` not found in the loaded library",
237 )(
238 handle,
239 basis,
240 numAtoms,
241 xyz,
242 thresholdPQ,
243 parameters,
244 persistentWorkspaceDescriptor,
245 temporaryWorkspaceDescriptor,
246 outPairList,
247 )
248}
249
250#[doc = " @brief Destroy/free an AO pair list object and its resources.\n @ingroup Basis\n\n The AO pair list handle and associated resources must not be used after this call.\n\n @param[in] pairList AO pair list handle to destroy. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if pairList is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the cuEST AOPairList handle is not of type \\c cuestAOPairList_t;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on error."]
251pub unsafe fn cuestAOPairListDestroy(pairList: cuestAOPairList_t) -> cuestStatus_t {
252 dyload_lib()
253 .cuestAOPairListDestroy
254 .expect("cuEST function `cuestAOPairListDestroy` not found in the loaded library")(
255 pairList
256 )
257}
258
259#[doc = " @brief Compute the effective core potential integral matrix using the provided plan.\n @ingroup ECPCompute\n\n The output buffer must be preallocated and sized for (nao × nao) elements, where nao is the\n number of atomic orbitals in the basis. Temporary workspace must be allocated using size\n returned by \\c cuestECPComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan ECP integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Handle to \\c cuestECPComputeParameters_t. Must not be NULL.\n @param[in] variableBufferSize User-provided descriptor for the amount of memory used to evaluate the ECP integrals.\n 2 GB is a good default buffer size for device memory. If an insufficient amount\n of memory is provided, the cuestECPCompute call will return CUEST_STATUS_EXCEPTION.\n If this occurs, increase the variableBufferSize and make the WorkspaceQuery and Compute calls\n again. This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n Host memory is currently unused. Must not be NULL.\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated). Must not be NULL.\n @param[out] outECPMatrix Output buffer for computed ECP matrix elements (size: nao × nao) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise;\n - \\c CUEST_STATUS_EXCEPTION often indicates variableBufferSize is too small."]
260pub unsafe fn cuestECPCompute(
261 handle: cuestHandle_t,
262 plan: cuestECPIntPlan_t,
263 parameters: cuestECPComputeParameters_t,
264 variableBufferSize: *const cuestWorkspaceDescriptor_t,
265 temporaryWorkspace: *mut cuestWorkspace_t,
266 outECPMatrix: *mut f64,
267) -> cuestStatus_t {
268 dyload_lib()
269 .cuestECPCompute
270 .expect("cuEST function `cuestECPCompute` not found in the loaded library")(
271 handle,
272 plan,
273 parameters,
274 variableBufferSize,
275 temporaryWorkspace,
276 outECPMatrix,
277 )
278}
279
280#[doc = " @brief Query the temporary workspace required (in bytes) for effective core potential matrix calculation.\n @ingroup ECPCompute\n\n This function computes the workspace requirements for a requested ECP calculation. Fill the\n provided workspace descriptor with host and device buffer sizes required. The \\c outECPMatrix pointer may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan ECP integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Handle to \\c cuestECPComputeParameters_t. Must not be NULL.\n @param[in] variableBufferSize User-provided descriptor for the amount of memory used to evaluate the ECP integrals.\n 2 GB is a good default buffer size for device memory. If an insufficient amount\n of memory is provided, the cuestECPCompute call will return CUEST_STATUS_EXCEPTION.\n If this occurs, increase the variableBufferSize and make the WorkspaceQuery and Compute calls\n again. This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n Host memory is currently unused. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param outECPMatrix User matrix buffer. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
281pub unsafe fn cuestECPComputeWorkspaceQuery(
282 handle: cuestHandle_t,
283 plan: cuestECPIntPlan_t,
284 parameters: cuestECPComputeParameters_t,
285 variableBufferSize: *const cuestWorkspaceDescriptor_t,
286 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
287 outECPMatrix: *mut f64,
288) -> cuestStatus_t {
289 dyload_lib()
290 .cuestECPComputeWorkspaceQuery
291 .expect("cuEST function `cuestECPComputeWorkspaceQuery` not found in the loaded library")(
292 handle,
293 plan,
294 parameters,
295 variableBufferSize,
296 temporaryWorkspaceDescriptor,
297 outECPMatrix,
298 )
299}
300
301#[doc = " @brief Compute the electronic gradient (derivative) of the effective core potential integral matrix\n using the provided plan and density matrix.\n @ingroup ECPCompute\n\n Both the input density matrix and the output gradient must be preallocated. The density\n matrix must be an (nao x nao) array and the output gradient must have space for (natom x 3)\n elements, where nao is the number of atomic orbitals and natom the number of atoms in the system.\n All required temporary workspace must be allocated by the user prior to calling this function\n using size returned by \\c cuestECPDerivativeComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan ECP integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Handle to \\c cuestECPDerivativeComputeParameters_t. Must not be NULL.\n @param[in] variableBufferSize User-provided descriptor for the amount of memory used to evaluate the ECP integrals.\n 2 GB is a good default buffer size for device memory. If an insufficient amount\n of memory is provided, the cuestECPDerivativeCompute call will return CUEST_STATUS_EXCEPTION.\n If this occurs, increase the variableBufferSize and make the WorkspaceQuery and Compute calls\n again. This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n Host memory is currently unused. Must not be NULL.\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated). Must not be NULL.\n @param[in] densityMatrix Pointer to input density matrix (size: nao × nao) on the GPU. Must not be NULL.\n @param[out] outGradient Output buffer for computed ECP gradient (size: natom × 3) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise;\n - \\c CUEST_STATUS_EXCEPTION often indicates variableBufferSize is too small."]
302pub unsafe fn cuestECPDerivativeCompute(
303 handle: cuestHandle_t,
304 plan: cuestECPIntPlan_t,
305 parameters: cuestECPDerivativeComputeParameters_t,
306 variableBufferSize: *const cuestWorkspaceDescriptor_t,
307 temporaryWorkspace: *mut cuestWorkspace_t,
308 densityMatrix: *const f64,
309 outGradient: *mut f64,
310) -> cuestStatus_t {
311 dyload_lib()
312 .cuestECPDerivativeCompute
313 .expect("cuEST function `cuestECPDerivativeCompute` not found in the loaded library")(
314 handle,
315 plan,
316 parameters,
317 variableBufferSize,
318 temporaryWorkspace,
319 densityMatrix,
320 outGradient,
321 )
322}
323
324#[doc = " @brief Query the temporary workspace required (in bytes) for electronic gradient (derivative) of the\n effective core potential matrix using the supplied integral plan and density matrix.\n @ingroup ECPCompute\n\n This function computes the workspace requirements for a requested ECP gradient calculation. Fill the\n provided workspace descriptor with host and device buffer sizes required. The \\c outGradient pointer may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan ECP integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Handle to \\c cuestECPDerivativeComputeParameters_t. Must not be NULL.\n @param[in] variableBufferSize User-provided descriptor for the amount of memory used to evaluate the ECP integrals.\n 2 GB is a good default buffer size for device memory. If an insufficient amount\n of memory is provided, the cuestECPDerivativeCompute call will return CUEST_STATUS_EXCEPTION.\n If this occurs, increase the variableBufferSize and make the WorkspaceQuery and Compute calls\n again. This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n Host memory is currently unused. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param densityMatrix Pointer to input density matrix. May be NULL.\n @param outGradient User buffer. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
325pub unsafe fn cuestECPDerivativeComputeWorkspaceQuery(
326 handle: cuestHandle_t,
327 plan: cuestECPIntPlan_t,
328 parameters: cuestECPDerivativeComputeParameters_t,
329 variableBufferSize: *const cuestWorkspaceDescriptor_t,
330 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
331 densityMatrix: *const f64,
332 outGradient: *mut f64,
333) -> cuestStatus_t {
334 dyload_lib().cuestECPDerivativeComputeWorkspaceQuery.expect(
335 "cuEST function `cuestECPDerivativeComputeWorkspaceQuery` not found in the loaded library",
336 )(
337 handle,
338 plan,
339 parameters,
340 variableBufferSize,
341 temporaryWorkspaceDescriptor,
342 densityMatrix,
343 outGradient,
344 )
345}
346
347#[doc = " @brief Create an effective core potential atom from a set of ECPShell.\n @ingroup ECP\n\n An ECP Atom comprises multiple ECP shells, grouped by atomic center.\n - All buffer pointers must be valid (not NULL).\n - Each shell, and each array entry, must be valid.\n - The output handle is only valid after successful creation.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] numElectrons Total number of electrons corresponding to the ECP for this atom; must be greater than zero and even.\n @param[in] numShells Specifies number of shells for this atom with \\f$ L < L_{max} \\f$ ; must be greater than zero. \\f$ L_{max} \\f$ is equal to \\c numShells.\n @param[in] shells Flat CPU array of shell handles \\c cuestECPShell_t (size: \\c numShells). Must not be NULL and none of the entries may be NULL. The array must contain exactly one shell per angular momentum in ascending order, i.e. the entry at index \\c i must have \\f$ L == i \\f$.\n @param[in] topShell Shell handle (\\c cuestECPShell_t) with \\f$ L == L_{max} == \\f$ \\c numShells for this atom. Must not be NULL.\n @param[in] parameters Handle to \\c cuestECPAtomParameters_t. Must not be NULL.\n @param[out] outECPAtom Pointer for output atom handle. Must not be NULL.\n\n All objects on CPU.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any pointer parameter is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numElectrons == 0 or \\c numShells == 0;\n - \\c CUEST_STATUS_EXCEPTION if \\c numElectrons is odd, a shell is out of order (\\c shells[i] with \\f$ L != i \\f$), or \\c topShell does not have \\f$ L == \\f$ \\c numShells;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on other errors."]
348pub unsafe fn cuestECPAtomCreate(
349 handle: cuestHandle_t,
350 numElectrons: u64,
351 numShells: u64,
352 shells: *const cuestECPShell_t,
353 topShell: cuestECPShell_t,
354 parameters: cuestECPAtomParameters_t,
355 outECPAtom: *mut cuestECPAtom_t,
356) -> cuestStatus_t {
357 dyload_lib()
358 .cuestECPAtomCreate
359 .expect("cuEST function `cuestECPAtomCreate` not found in the loaded library")(
360 handle,
361 numElectrons,
362 numShells,
363 shells,
364 topShell,
365 parameters,
366 outECPAtom,
367 )
368}
369
370#[doc = " @brief Destroy/free an ECP Atom object and all associated resources.\n @ingroup ECP\n\n After this function is called, the ECP atom handle must not be used.\n\n @param[in] atom ECP Atom handle to destroy; must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if atom is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the cuEST ECP Atom handle is not of type \\c cuestECPAtom_t;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on error."]
371pub unsafe fn cuestECPAtomDestroy(atom: cuestECPAtom_t) -> cuestStatus_t {
372 dyload_lib()
373 .cuestECPAtomDestroy
374 .expect("cuEST function `cuestECPAtomDestroy` not found in the loaded library")(atom)
375}
376
377#[doc = " @brief Create an ECP shell object with specified parameters.\n @ingroup ECP\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] L Angular momentum quantum number (s=0, p=1, d=2, etc).\n @param[in] numPrimitive Number of primitives; must be greater than zero.\n @param[in] radialPowers Pointer to array containing radial powers (size: \\c numPrimitive) on the CPU. Elements must be non-negative integers, e.g. >= 0. Must not be NULL.\n @param[in] coefficients Pointer to array containing coefficients (size: \\c numPrimitive) on the CPU. Must not be NULL.\n @param[in] exponents Pointer to array containing exponents (size: \\c numPrimitive) on the CPU. Elements must be strictly positive and finite, e.g. > 0. Must not be NULL.\n @param[in] parameters Handle to \\c cuestECPShellParameters_t. Must not be NULL.\n @param[out] outECPShell Pointer to output shell object; receives opaque handle on success. Must not be NULL.\n\n All objects on CPU.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the cuEST handle or parameters are not of the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numPrimitive is zero, or if any exponent is not strictly positive and finite (> 0);\n - \\c CUEST_STATUS_EXCEPTION for unexpected error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR for non-std exceptions."]
378pub unsafe fn cuestECPShellCreate(
379 handle: cuestHandle_t,
380 L: u64,
381 numPrimitive: u64,
382 radialPowers: *const u64,
383 coefficients: *const f64,
384 exponents: *const f64,
385 parameters: cuestECPShellParameters_t,
386 outECPShell: *mut cuestECPShell_t,
387) -> cuestStatus_t {
388 dyload_lib()
389 .cuestECPShellCreate
390 .expect("cuEST function `cuestECPShellCreate` not found in the loaded library")(
391 handle,
392 L,
393 numPrimitive,
394 radialPowers,
395 coefficients,
396 exponents,
397 parameters,
398 outECPShell,
399 )
400}
401
402#[doc = " @brief Destroy/free an ECP shell object created with \\c cuestECPShellCreate.\n @ingroup ECP\n\n Frees all memory associated with the ECP shell. After destruction, the shell handle must not be used.\n\n @param[in] shell Opaque ECP shell handle to destroy. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c shell is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the \\c shell handle is not of the \\c cuestECPShell_t type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on error."]
403pub unsafe fn cuestECPShellDestroy(shell: cuestECPShell_t) -> cuestStatus_t {
404 dyload_lib()
405 .cuestECPShellDestroy
406 .expect("cuEST function `cuestECPShellDestroy` not found in the loaded library")(shell)
407}
408
409#[doc = " @brief Build a plan for effective core potential integrals.\n @ingroup ECPIntegralPlan\n\n All object handles, workspaces, and output pointers must be valid (not NULL).\n Workspace buffers must be preallocated with required sizes (see workspace query).\n\n \\verbatim embed:rst\n.. Note::\n- The number of atoms in the `cuestAOBasis_t` basis handle must match the length of the `xyzCPU` array.\n- The `cuestAOBasis_t` basis handle should define a basis set that is constructed to use the ECP functions\nbeing defined here. For example if the basis set includes a 1s orbital on a particular atom and that\n1s orbital is modelled by the ECPs included here, the downstream results may be undesirable. No checking\nis done for such a situation.\n- It is the user's responsibility to modify other terms that may relate to the presence of ECPs, such as\nthe potential integrals. This will not be done automatically.\n\\endverbatim\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] basis AO basis set handle. Must not be NULL.\n @param[in] xyzCPU Coordinates for full system (size: natom x 3) on the CPU. Must not be NULL.\n @param[in] numECPAtoms Number of atoms with ECPs. Must be greater than zero and less than or equal to total number of system atoms, natom.\n @param[in] activeIndices Indices of atoms with ECPs relative to full list of atoms (size: numECPAtoms) on the CPU. Must not be NULL.\n The \\c activeIndices cannot contain indices greater than or equal to natom and cannot contain duplicate entries.\n @param[in] activeAtoms CPU array of ECP atom handles. Must not be NULL and none of the entries may be NULL.\n @param[in] parameters Plan parameter structure. Must not be NULL.\n @param[in] persistentWorkspace Preallocated workspace for persistent buffers. Must not be NULL.\n @param[in] temporaryWorkspace Preallocated workspace for temporary buffers. Must not be NULL.\n @param[out] outPlan Output pointer for integral plan handle. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any pointer argument is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numECPAtoms is zero or the \\c activeIndices are invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
410pub unsafe fn cuestECPIntPlanCreate(
411 handle: cuestHandle_t,
412 basis: cuestAOBasis_t,
413 xyzCPU: *const f64,
414 numECPAtoms: u64,
415 activeIndices: *const u64,
416 activeAtoms: *const cuestECPAtom_t,
417 parameters: cuestECPIntPlanParameters_t,
418 persistentWorkspace: *mut cuestWorkspace_t,
419 temporaryWorkspace: *mut cuestWorkspace_t,
420 outPlan: *mut cuestECPIntPlan_t,
421) -> cuestStatus_t {
422 dyload_lib()
423 .cuestECPIntPlanCreate
424 .expect("cuEST function `cuestECPIntPlanCreate` not found in the loaded library")(
425 handle,
426 basis,
427 xyzCPU,
428 numECPAtoms,
429 activeIndices,
430 activeAtoms,
431 parameters,
432 persistentWorkspace,
433 temporaryWorkspace,
434 outPlan,
435 )
436}
437
438#[doc = " @brief Query workspace requirements for creating an effective core potential integral plan.\n @ingroup ECPIntegralPlan\n\n Determines persistent and temporary buffer sizes by simulating allocation logic.\n All handles and pointers must be valid (not NULL).\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] basis AO basis set handle. Must not be NULL.\n @param[in] xyzCPU Coordinates for full system (size: natom x 3) on the CPU. Must not be NULL.\n @param[in] numECPAtoms Number of atoms with ECPs. Must be greater than zero and less than or equal to total number of system atoms, natom.\n @param[in] activeIndices Indices of atoms with ECPs relative to full list of atoms (size: numECPAtoms) on the CPU. Must not be NULL.\n The \\c activeIndices cannot contain indices greater than or equal to natom and cannot contain duplicate entries.\n @param[in] activeAtoms CPU array of ECP atom handles. Must not be NULL and none of the entries may be NULL.\n @param[in] parameters Plan parameters handle. Must not be NULL.\n @param[out] persistentWorkspaceDescriptor Output descriptor for persistent buffer sizing. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary buffer sizing. Must not be NULL.\n @param outPlan Pointer for integral plan handle. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any pointer argument is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numECPAtoms is zero or the \\c activeIndices are invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
439pub unsafe fn cuestECPIntPlanCreateWorkspaceQuery(
440 handle: cuestHandle_t,
441 basis: cuestAOBasis_t,
442 xyzCPU: *const f64,
443 numECPAtoms: u64,
444 activeIndices: *const u64,
445 activeAtoms: *const cuestECPAtom_t,
446 parameters: cuestECPIntPlanParameters_t,
447 persistentWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
448 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
449 outPlan: *mut cuestECPIntPlan_t,
450) -> cuestStatus_t {
451 dyload_lib().cuestECPIntPlanCreateWorkspaceQuery.expect(
452 "cuEST function `cuestECPIntPlanCreateWorkspaceQuery` not found in the loaded library",
453 )(
454 handle,
455 basis,
456 xyzCPU,
457 numECPAtoms,
458 activeIndices,
459 activeAtoms,
460 parameters,
461 persistentWorkspaceDescriptor,
462 temporaryWorkspaceDescriptor,
463 outPlan,
464 )
465}
466
467#[doc = " @brief Destroy and release an effective core potential integral plan and its resources.\n @ingroup ECPIntegralPlan\n\n The plan handle and its memory must not be used after destruction.\n\n @param[in] plan Plan handle to destroy. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c plan is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
468pub unsafe fn cuestECPIntPlanDestroy(plan: cuestECPIntPlan_t) -> cuestStatus_t {
469 dyload_lib()
470 .cuestECPIntPlanDestroy
471 .expect("cuEST function `cuestECPIntPlanDestroy` not found in the loaded library")(plan)
472}
473
474#[doc = " @brief Build a plan for one-electron integrals over atomic orbitals.\n @ingroup OneElectronIntegralPlan\n\n All object handles, workspaces, and output pointers must be valid (not NULL).\n Workspace buffers must be preallocated with required sizes (see workspace query).\n\n \\verbatim embed:rst\n.. Note::\n- The `cuestAOBasis_t` basis handle provided here must correspond to the basis handle provided\nwhen the `cuestAOPairList_t` pair list handle was created.\n- It is the user's responsibility not to destroy the `cuestAOBasis_t` basis handle or\n`cuestAOPairList_t` pair list handle until operations involving the `cuestOEIntPlan_t` plan\nhandle are complete.\n- After the `cuestAOBasis_t` basis handle or `cuestAOPairList_t` pair list handle are destroyed,\nthe `cuestOEIntPlan_t` plan handle is no longer valid.\n- Screening of negligible integrals computed while using this `cuestOEIntPlan_t` plan handle\nis controlled by `thresholdPQ` set during construction of the `cuestAOPairList_t` pair list handle.\n\\endverbatim\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] basis AO basis set handle. Must not be NULL.\n @param[in] pairList AO pair list handle. Must not be NULL.\n @param[in] parameters Plan parameter structure. Must not be NULL.\n @param[in] persistentWorkspace Preallocated workspace for persistent buffers. Must not be NULL.\n @param[in] temporaryWorkspace Preallocated workspace for temporary buffers. Must not be NULL.\n @param[out] outPlan Output pointer for integral plan handle. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any pointer argument is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
475pub unsafe fn cuestOEIntPlanCreate(
476 handle: cuestHandle_t,
477 basis: cuestAOBasis_t,
478 pairList: cuestAOPairList_t,
479 parameters: cuestOEIntPlanParameters_t,
480 persistentWorkspace: *mut cuestWorkspace_t,
481 temporaryWorkspace: *mut cuestWorkspace_t,
482 outPlan: *mut cuestOEIntPlan_t,
483) -> cuestStatus_t {
484 dyload_lib()
485 .cuestOEIntPlanCreate
486 .expect("cuEST function `cuestOEIntPlanCreate` not found in the loaded library")(
487 handle,
488 basis,
489 pairList,
490 parameters,
491 persistentWorkspace,
492 temporaryWorkspace,
493 outPlan,
494 )
495}
496
497#[doc = " @brief Query workspace requirements for creating a one-electron integral plan.\n @ingroup OneElectronIntegralPlan\n\n Determines persistent and temporary buffer sizes by simulating allocation logic.\n All handles and pointers must be valid (not NULL).\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] basis AO basis set handle. Must not be NULL.\n @param[in] pairList AO pair list handle. Must not be NULL.\n @param[in] parameters Plan parameters handle. Must not be NULL.\n @param[out] persistentWorkspaceDescriptor Output descriptor for persistent buffer sizing. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary buffer sizing. Must not be NULL.\n @param outPlan Output pointer for integral plan handle. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer argument is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
498pub unsafe fn cuestOEIntPlanCreateWorkspaceQuery(
499 handle: cuestHandle_t,
500 basis: cuestAOBasis_t,
501 pairList: cuestAOPairList_t,
502 parameters: cuestOEIntPlanParameters_t,
503 persistentWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
504 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
505 outPlan: *mut cuestOEIntPlan_t,
506) -> cuestStatus_t {
507 dyload_lib().cuestOEIntPlanCreateWorkspaceQuery.expect(
508 "cuEST function `cuestOEIntPlanCreateWorkspaceQuery` not found in the loaded library",
509 )(
510 handle,
511 basis,
512 pairList,
513 parameters,
514 persistentWorkspaceDescriptor,
515 temporaryWorkspaceDescriptor,
516 outPlan,
517 )
518}
519
520#[doc = " @brief Destroy and release a one-electron integral plan and its resources.\n @ingroup OneElectronIntegralPlan\n\n The plan handle and its memory must not be used after destruction.\n\n @param[in] plan Plan handle to destroy. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c plan is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
521pub unsafe fn cuestOEIntPlanDestroy(plan: cuestOEIntPlan_t) -> cuestStatus_t {
522 dyload_lib()
523 .cuestOEIntPlanDestroy
524 .expect("cuEST function `cuestOEIntPlanDestroy` not found in the loaded library")(plan)
525}
526
527#[doc = " @brief Build a density-fitted integral plan (DF) for atomic orbitals.\n @ingroup DensityFittingIntegralPlan\n\n Constructs all needed metric arrays and three-center integrals. All handles and buffers must be valid.\n Workspace buffers must be preallocated using sizes from workspace query.\n\n The \\c cuestDFIntPlan_t may be configured to treat range-separated Coulomb operators.\n\n \\f[\n \\underbrace{\\frac{1}{r}}_{\\text{full-range}}\n =\n \\underbrace{\\frac{\\mathrm{erfc}(\\omega r)}{r}}_{\\text{short-range}}\n +\n \\underbrace{\\frac{\\mathrm{erf}(\\omega r)}{r}}_{\\text{long-range}}\n \\f]\n\n In cuEST, range-separation is parameterized in terms of the full-range and long-range components.\n\n - \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION: Controls the fraction of full-range exchange included.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION: Controls the fraction of long-range exchange included.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA: Specifies the range separation parameter.\n\n It is required that the operator specification must be positive and respect the following conditions:\n\n - \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION \\f$\\ge 0\\f$.\n - \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION + \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION \\f$\\ge 0\\f$.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA \\f$\\ge 0\\f$.\n\n \\c CUEST_STATUS_INVALID_ARGUMENT will be returned if these conditions are not respected during handle creation.\n\n The operator specification is respected by all subsequent calls involving the \\c cuestDFIntPlan_t. The one\n exception is \\c cuestDFCoulombCompute, which is always evaluated using the full-range Coulomb operator.\n\n Example configurations:\n\n - PBE0 (full-range, only):\n - \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION \\f$= 0.25\\f$.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION \\f$= 0\\f$.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA unused.\n\n - \\f$\\omega\\f$B97 (long-range, only):\n - \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION \\f$= 0.0\\f$.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION \\f$= 1.0\\f$.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA \\f$= 0.4\\f$.\n\n - \\f$\\omega\\f$B97M-V (full- and long-range):\n - \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION \\f$= 0.15\\f$.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION \\f$= 0.85\\f$.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA \\f$= 0.3\\f$.\n\n - HSE06 (short-range, only):\n - \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION \\f$= 0.25\\f$.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION \\f$= -0.25\\f$.\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA \\f$= 0.11\\f$.\n\n It is possible to put or create the \\c cuestDFIntPlan_t in a state where it is no longer possible to use\n the \\c cuestDFIntPlan_t for certain calculations.\n\n - Creating the \\c cuestDFIntPlan_t with the \\c CUEST_DFINTPLAN_PARAMETERS_THREE_INDEX_INTEGRAL_DIRECT parameter\n set to a non-zero value allows the plan to be used in calls to \\c cuestDFMOIntegralsCompute. At present, no\n other functions support this configuration.\n - Calls to \\c cuestDFSymmetricDerivativeCompute using the \\c CUEST_DFSYMMETRICDERIVATIVECOMPUTE_MEMORY_POLICY_OVERWRITE\n memory policy place the \\c cuestDFIntPlan_t in a dirty state. No further compute calls involving this plan will\n succeed.\n\n \\c CUEST_STATUS_INVALID_PLAN will be returned if a compute call is made with a \\c cuestDFIntPlan_t in an\n unusable state.\n\n \\verbatim embed:rst\n.. Note::\n- The number of atoms in the primary basis handle must match the number of atoms in the\nauxiliary basis handle.\n- The `cuestAOBasis_t` primary basis handle provided here must correspond to the basis handle provided\nwhen the `cuestAOPairList_t` pair list handle was created.\n- It is the user's responsibility not to destroy the `cuestAOBasis_t` primary basis handle,\nauxiliary basis handle or `cuestAOPairList_t` pair list handle until operations involving the\n`cuestDFIntPlan_t` plan handle are complete.\n- After the `cuestAOBasis_t` basis handle, auxiliary basis handle or `cuestAOPairList_t` pair list handle are destroyed, the `cuestDFIntPlan_t` plan handle is no longer valid.\n- Screening of negligible integrals computed while using this `cuestDFIntPlan_t` plan handle\nis controlled by `thresholdPQ` set during construction of the `cuestAOPairList_t` pair list handle.\n\\endverbatim\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] primaryBasis AO basis set for primary orbitals. Must not be NULL.\n @param[in] auxiliaryBasis AO basis set for auxiliary/fitting orbitals.\n The auxiliary basis set must use a pure (spherical)\n angular momentum representation. Must not be NULL.\n @param[in] pairList AO pair list describing sparsity. Must not be NULL.\n @param[in] parameters Density-fitting parameters structure. Must not be NULL.\n @param[in] persistentWorkspace Workspace for persistent buffers. Must not be NULL.\n @param[in] temporaryWorkspace Workspace for temporary buffers. Must not be NULL.\n @param[out] outPlan Output pointer for DF plan handle. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if any of the \\c cuestDFIntPlanParameters_t are invalid;\n - \\c CUEST_STATUS_EXCEPTION if \\c auxiliaryBasis is not pure;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
528pub unsafe fn cuestDFIntPlanCreate(
529 handle: cuestHandle_t,
530 primaryBasis: cuestAOBasis_t,
531 auxiliaryBasis: cuestAOBasis_t,
532 pairList: cuestAOPairList_t,
533 parameters: cuestDFIntPlanParameters_t,
534 persistentWorkspace: *mut cuestWorkspace_t,
535 temporaryWorkspace: *mut cuestWorkspace_t,
536 outPlan: *mut cuestDFIntPlan_t,
537) -> cuestStatus_t {
538 dyload_lib()
539 .cuestDFIntPlanCreate
540 .expect("cuEST function `cuestDFIntPlanCreate` not found in the loaded library")(
541 handle,
542 primaryBasis,
543 auxiliaryBasis,
544 pairList,
545 parameters,
546 persistentWorkspace,
547 temporaryWorkspace,
548 outPlan,
549 )
550}
551
552#[doc = " @brief Query workspace sizes for creating a density-fitted integral plan.\n @ingroup DensityFittingIntegralPlan\n\n Simulates all allocations for DF plan, returning size requirements.\n All handles and pointers must be valid (not NULL). Output descriptors are filled on success.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] primaryBasis AO basis set for primary orbitals. Must not be NULL.\n @param[in] auxiliaryBasis AO basis set for auxiliary/fitting orbitals.\n The auxiliary basis set must use a pure (spherical)\n angular momentum representation. Must not be NULL.\n @param[in] pairList AO pair list handle. Must not be NULL.\n @param[in] parameters Density-fitting parameters structure. Must not be NULL.\n @param[out] persistentWorkspaceDescriptor Output descriptor for persistent buffers. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary buffers. Must not be NULL.\n @param outPlan Output pointer for DF plan handle. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if any of the \\c cuestDFIntPlanParameters_t are invalid;\n - \\c CUEST_STATUS_EXCEPTION if \\c auxiliaryBasis is not pure;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
553pub unsafe fn cuestDFIntPlanCreateWorkspaceQuery(
554 handle: cuestHandle_t,
555 primaryBasis: cuestAOBasis_t,
556 auxiliaryBasis: cuestAOBasis_t,
557 pairList: cuestAOPairList_t,
558 parameters: cuestDFIntPlanParameters_t,
559 persistentWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
560 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
561 outPlan: *mut cuestDFIntPlan_t,
562) -> cuestStatus_t {
563 dyload_lib().cuestDFIntPlanCreateWorkspaceQuery.expect(
564 "cuEST function `cuestDFIntPlanCreateWorkspaceQuery` not found in the loaded library",
565 )(
566 handle,
567 primaryBasis,
568 auxiliaryBasis,
569 pairList,
570 parameters,
571 persistentWorkspaceDescriptor,
572 temporaryWorkspaceDescriptor,
573 outPlan,
574 )
575}
576
577#[doc = " @brief Destroy/free a density-fitted integral plan and all resources.\n @ingroup DensityFittingIntegralPlan\n\n The plan handle and its memory must not be used after destruction.\n\n @param[in] plan DF plan handle to destroy. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c plan is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
578pub unsafe fn cuestDFIntPlanDestroy(plan: cuestDFIntPlan_t) -> cuestStatus_t {
579 dyload_lib()
580 .cuestDFIntPlanDestroy
581 .expect("cuEST function `cuestDFIntPlanDestroy` not found in the loaded library")(plan)
582}
583
584#[doc = " @brief Compute the atomic orbital overlap matrix (S) using the provided overlap plan.\n @ingroup Overlap\n\n The output buffer must be preallocated and sized for nao × nao elements, where nao is the\n number of atomic orbitals in the basis. Temporary workspace must be allocated using size\n returned by \\c cuestOverlapComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestOverlapComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated). Must not be NULL.\n @param[out] outSMatrix Output GPU buffer for computed overlap matrix elements [size: nao × nao]. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
585pub unsafe fn cuestOverlapCompute(
586 handle: cuestHandle_t,
587 plan: cuestOEIntPlan_t,
588 parameters: cuestOverlapComputeParameters_t,
589 temporaryWorkspace: *mut cuestWorkspace_t,
590 outSMatrix: *mut f64,
591) -> cuestStatus_t {
592 dyload_lib()
593 .cuestOverlapCompute
594 .expect("cuEST function `cuestOverlapCompute` not found in the loaded library")(
595 handle,
596 plan,
597 parameters,
598 temporaryWorkspace,
599 outSMatrix,
600 )
601}
602
603#[doc = " @brief Query the temporary workspace required (in bytes) for overlap matrix calculation.\n @ingroup Overlap\n\n This function computes the workspace requirements for a requested overlap calculation. Fill the\n provided workspace descriptor with host and device buffer sizes required. The \\c outSMatrix pointer may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestOverlapComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param outSMatrix User matrix buffer (may be NULL during the workspace query).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
604pub unsafe fn cuestOverlapComputeWorkspaceQuery(
605 handle: cuestHandle_t,
606 plan: cuestOEIntPlan_t,
607 parameters: cuestOverlapComputeParameters_t,
608 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
609 outSMatrix: *mut f64,
610) -> cuestStatus_t {
611 dyload_lib().cuestOverlapComputeWorkspaceQuery.expect(
612 "cuEST function `cuestOverlapComputeWorkspaceQuery` not found in the loaded library",
613 )(handle, plan, parameters, temporaryWorkspaceDescriptor, outSMatrix)
614}
615
616#[doc = " @brief Compute the electronic gradient (derivative) of the atomic orbital overlap matrix\n using the supplied integral plan and density matrix.\n @ingroup OverlapGrad\n\n Both the input density matrix and the output gradient must be preallocated. The density\n matrix must be an (nao x nao) array and the output gradient must have space for (natom x 3)\n elements, where nao is the number of atomic orbitals and natom the number of atoms in the system.\n All required temporary workspace must be allocated by the user prior to calling this function.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestOverlapDerivativeComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated). Must not be NULL.\n @param[in] densityMatrix Pointer to input density matrix [size: nao × nao]. GPU array. Must not be NULL.\n @param[out] outGradient Pointer to GPU buffer for computed gradients [size: natom × 3]. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
617pub unsafe fn cuestOverlapDerivativeCompute(
618 handle: cuestHandle_t,
619 plan: cuestOEIntPlan_t,
620 parameters: cuestOverlapDerivativeComputeParameters_t,
621 temporaryWorkspace: *mut cuestWorkspace_t,
622 densityMatrix: *const f64,
623 outGradient: *mut f64,
624) -> cuestStatus_t {
625 dyload_lib()
626 .cuestOverlapDerivativeCompute
627 .expect("cuEST function `cuestOverlapDerivativeCompute` not found in the loaded library")(
628 handle,
629 plan,
630 parameters,
631 temporaryWorkspace,
632 densityMatrix,
633 outGradient,
634 )
635}
636
637#[doc = " @brief Query the temporary workspace required (in bytes) for overlap matrix gradient calculation.\n @ingroup OverlapGrad\n\n This function computes the workspace requirements of a single gradient evaluation,\n based on the supplied plan and dimensions. The workspace descriptor is filled with host and device memory\n requirements. Output buffers may be NULL for the purposes of the query.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestOverlapDerivativeComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param densityMatrix Optional density matrix pointer (may be NULL).\n @param outGradient Optional buffer for computed gradient (may be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
638pub unsafe fn cuestOverlapDerivativeComputeWorkspaceQuery(
639 handle: cuestHandle_t,
640 plan: cuestOEIntPlan_t,
641 parameters: cuestOverlapDerivativeComputeParameters_t,
642 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
643 densityMatrix: *const f64,
644 outGradient: *mut f64,
645) -> cuestStatus_t {
646 dyload_lib().cuestOverlapDerivativeComputeWorkspaceQuery.expect("cuEST function `cuestOverlapDerivativeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, densityMatrix, outGradient)
647}
648
649#[doc = " @brief Compute the atomic orbital kinetic energy matrix (T-matrix) using the supplied integral plan.\n @ingroup Kinetic\n\n The output buffer must be preallocated by the user and have space for (nao × nao) doubles,\n where nao is the number of atomic orbitals in the basis. All required temporary workspace\n must be allocated before calling this function, using the size returned from\n \\c cuestKineticComputeWorkspaceQuery. All pointers must be valid and not NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestKineticComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated).\n @param[out] outTMatrix Output GPU buffer for computed kinetic matrix elements (size: nao × nao). Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
650pub unsafe fn cuestKineticCompute(
651 handle: cuestHandle_t,
652 plan: cuestOEIntPlan_t,
653 parameters: cuestKineticComputeParameters_t,
654 temporaryWorkspace: *mut cuestWorkspace_t,
655 outTMatrix: *mut f64,
656) -> cuestStatus_t {
657 dyload_lib()
658 .cuestKineticCompute
659 .expect("cuEST function `cuestKineticCompute` not found in the loaded library")(
660 handle,
661 plan,
662 parameters,
663 temporaryWorkspace,
664 outTMatrix,
665 )
666}
667
668#[doc = " @brief Query the temporary workspace required (in bytes) for kinetic energy matrix calculation.\n @ingroup Kinetic\n\n This function determines the workspace requirements for a kinetic energy matrix evaluation\n (such as buffer sizes), given a particular plan. The output descriptor is filled on success.\n User matrix buffer may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestKineticComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param outTMatrix Optional buffer for computed kinetic matrix (may be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
669pub unsafe fn cuestKineticComputeWorkspaceQuery(
670 handle: cuestHandle_t,
671 plan: cuestOEIntPlan_t,
672 parameters: cuestKineticComputeParameters_t,
673 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
674 outTMatrix: *mut f64,
675) -> cuestStatus_t {
676 dyload_lib().cuestKineticComputeWorkspaceQuery.expect(
677 "cuEST function `cuestKineticComputeWorkspaceQuery` not found in the loaded library",
678 )(handle, plan, parameters, temporaryWorkspaceDescriptor, outTMatrix)
679}
680
681#[doc = " @brief Compute the gradient (nuclear derivative) of the AO kinetic energy matrix (T)\n with respect to atomic positions, contracted with a density matrix.\n @ingroup KineticGrad\n\n The user must provide a preallocated density matrix (size nao × nao) and a preallocated\n output gradient buffer (size natom × 3). All required temporary workspace must be sized and\n allocated using the query function below.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestKineticDerivativeComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers (preallocated for this operation). Must not be NULL.\n @param[in] densityMatrix Input density matrix (size: nao × nao). GPU array. Must not be NULL.\n @param[out] outGradient Output GPU buffer for gradient (size: natom × 3). Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
682pub unsafe fn cuestKineticDerivativeCompute(
683 handle: cuestHandle_t,
684 plan: cuestOEIntPlan_t,
685 parameters: cuestKineticDerivativeComputeParameters_t,
686 temporaryWorkspace: *mut cuestWorkspace_t,
687 densityMatrix: *const f64,
688 outGradient: *mut f64,
689) -> cuestStatus_t {
690 dyload_lib()
691 .cuestKineticDerivativeCompute
692 .expect("cuEST function `cuestKineticDerivativeCompute` not found in the loaded library")(
693 handle,
694 plan,
695 parameters,
696 temporaryWorkspace,
697 densityMatrix,
698 outGradient,
699 )
700}
701
702#[doc = " @brief Query the temporary workspace required (in bytes) for a kinetic energy gradient computation.\n @ingroup KineticGrad\n\n This function determines the workspace required for a\n kinetic energy gradient evaluation with a given plan. The output\n descriptor is filled on success.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestKineticDerivativeComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes (host and device). Must not be NULL.\n @param densityMatrix Optional density matrix (may be NULL).\n @param outGradient Optional output gradient (may be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
703pub unsafe fn cuestKineticDerivativeComputeWorkspaceQuery(
704 handle: cuestHandle_t,
705 plan: cuestOEIntPlan_t,
706 parameters: cuestKineticDerivativeComputeParameters_t,
707 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
708 densityMatrix: *const f64,
709 outGradient: *mut f64,
710) -> cuestStatus_t {
711 dyload_lib().cuestKineticDerivativeComputeWorkspaceQuery.expect("cuEST function `cuestKineticDerivativeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, densityMatrix, outGradient)
712}
713
714#[doc = " @brief Compute the atomic orbital multipole matrix using the provided \\c cuestOEIntPlan_t plan.\n @ingroup Multipole\n @since v0.2.0\n\n The output buffer must be preallocated and sized for nao × nao elements, where nao is the\n number of atomic orbitals in the basis. Temporary workspace must be allocated using size\n returned by \\c cuestMultipoleComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestMultipoleComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated). Must not be NULL.\n @param[in] multipoleOrder Exponents defining the multipole operator: x^l y^m z^n [size: 3]. CPU array. Must not be NULL.\n @param[in] origin Cartesian coordinates defining the multipole origin [size: 3]. CPU array. Must not be NULL.\n @param[out] outMatrix Output GPU buffer for computed multipole matrix elements [size: nao × nao]. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n With the default configuration of the cuEST handle, multipole moments with a total order of up to 30 are supported (assuming an\n orbital basis including g orbitals). Support for higher-order multipoles can be enabled by increasing \\c CUEST_HANDLE_PARAMETERS_MAX_GAUSS_HERMITE.\n Exceeding this limit will result in a \\c CUEST_STATUS_EXCEPTION return code.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
715pub unsafe fn cuestMultipoleCompute(
716 handle: cuestHandle_t,
717 plan: cuestOEIntPlan_t,
718 parameters: cuestMultipoleComputeParameters_t,
719 temporaryWorkspace: *mut cuestWorkspace_t,
720 multipoleOrder: *const u32,
721 origin: *const f64,
722 outMatrix: *mut f64,
723) -> cuestStatus_t {
724 dyload_lib()
725 .cuestMultipoleCompute
726 .expect("cuEST function `cuestMultipoleCompute` not found in the loaded library")(
727 handle,
728 plan,
729 parameters,
730 temporaryWorkspace,
731 multipoleOrder,
732 origin,
733 outMatrix,
734 )
735}
736
737#[doc = " @brief Query the temporary workspace required (in bytes) for multipole matrix calculation.\n @ingroup Multipole\n @since v0.2.0\n\n This function computes the workspace requirements for a requested multipole calculation. Fill the\n provided workspace descriptor with host and device buffer sizes required. The \\c outMatrix pointer may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestMultipoleComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] multipoleOrder Integer exponents defining the multipole operator: x^l y^m z^n [size: 3]. CPU array. Must not be NULL.\n @param[in] origin Cartesian coordinates defining the multipole origin [size: 3]. CPU array. Must not be NULL.\n @param outMatrix User matrix buffer (may be NULL during the workspace query).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
738pub unsafe fn cuestMultipoleComputeWorkspaceQuery(
739 handle: cuestHandle_t,
740 plan: cuestOEIntPlan_t,
741 parameters: cuestMultipoleComputeParameters_t,
742 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
743 multipoleOrder: *const u32,
744 origin: *const f64,
745 outMatrix: *mut f64,
746) -> cuestStatus_t {
747 dyload_lib().cuestMultipoleComputeWorkspaceQuery.expect(
748 "cuEST function `cuestMultipoleComputeWorkspaceQuery` not found in the loaded library",
749 )(handle, plan, parameters, temporaryWorkspaceDescriptor, multipoleOrder, origin, outMatrix)
750}
751
752#[doc = " @brief Compute the electronic gradient (derivative) of the atomic orbital multipole matrix\n using the supplied integral plan and density matrix.\n @ingroup MultipoleGrad\n @since v0.2.0\n\n Both the input density matrix and the output gradient must be preallocated. The density\n matrix must be an (nao x nao) array and the output gradient must have space for (natom x 3)\n elements, where nao is the number of atomic orbitals and natom the number of atoms in the system.\n All required temporary workspace must be allocated by the user prior to calling this function.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestMultipoleDerivativeComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated). Must not be NULL.\n @param[in] multipoleOrder Exponents defining the multipole operator: x^l y^m z^n [size: 3]. CPU array. Must not be NULL.\n @param[in] origin Cartesian coordinates defining the multipole origin [size: 3]. CPU array. Must not be NULL.\n @param[in] densityMatrix Pointer to input density matrix [size: nao × nao]. GPU array. Must not be NULL.\n @param[out] outGradient Pointer to GPU buffer for computed gradients [size: natom × 3]. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n With the default configuration of the cuEST handle, multipole moment derivatives with a total order of up to 29 are supported (assuming an\n orbital basis including g orbitals). Support for higher-order multipoles can be enabled by increasing \\c CUEST_HANDLE_PARAMETERS_MAX_GAUSS_HERMITE.\n Exceeding this limit will result in a \\c CUEST_STATUS_EXCEPTION return code.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
753pub unsafe fn cuestMultipoleDerivativeCompute(
754 handle: cuestHandle_t,
755 plan: cuestOEIntPlan_t,
756 parameters: cuestMultipoleDerivativeComputeParameters_t,
757 temporaryWorkspace: *mut cuestWorkspace_t,
758 multipoleOrder: *const u32,
759 origin: *const f64,
760 densityMatrix: *const f64,
761 outGradient: *mut f64,
762) -> cuestStatus_t {
763 dyload_lib()
764 .cuestMultipoleDerivativeCompute
765 .expect("cuEST function `cuestMultipoleDerivativeCompute` not found in the loaded library")(
766 handle,
767 plan,
768 parameters,
769 temporaryWorkspace,
770 multipoleOrder,
771 origin,
772 densityMatrix,
773 outGradient,
774 )
775}
776
777#[doc = " @brief Query the temporary workspace required (in bytes) for multipole matrix gradient calculation.\n @ingroup MultipoleGrad\n @since v0.2.0\n\n This function computes the workspace requirements of a single gradient evaluation,\n based on the supplied plan and dimensions. The workspace descriptor is filled with host and device memory\n requirements. Output buffers may be NULL for the purposes of the query.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestMultipoleDerivativeComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] multipoleOrder Exponents defining the multipole operator: x^l y^m z^n [size: 3]. CPU array. Must not be NULL.\n @param[in] origin Cartesian coordinates defining the multipole origin [size: 3]. CPU array. Must not be NULL.\n @param densityMatrix Optional density matrix pointer (may be NULL).\n @param outGradient Optional buffer for computed gradient (may be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
778pub unsafe fn cuestMultipoleDerivativeComputeWorkspaceQuery(
779 handle: cuestHandle_t,
780 plan: cuestOEIntPlan_t,
781 parameters: cuestMultipoleDerivativeComputeParameters_t,
782 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
783 multipoleOrder: *const u32,
784 origin: *const f64,
785 densityMatrix: *const f64,
786 outGradient: *mut f64,
787) -> cuestStatus_t {
788 dyload_lib().cuestMultipoleDerivativeComputeWorkspaceQuery.expect("cuEST function `cuestMultipoleDerivativeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, multipoleOrder, origin, densityMatrix, outGradient)
789}
790
791#[doc = " @brief Compute the atomic orbital angular momentum matrix using the provided \\c cuestOEIntPlan_t plan.\n @ingroup AngularMomentum\n @since v0.2.0\n\n The output buffer must be preallocated and sized for nao × nao elements, where nao is the\n number of atomic orbitals in the basis. Temporary workspace must be allocated using size\n returned by \\c cuestAngularMomentumComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestAngularMomentumComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated). Must not be NULL.\n @param[in] component Enum (\\c cuestAngularMomentumComputeParametersComponent_t) defining the angular momentum operator (i.e. \\f$L_x\\f$, \\f$L_y\\f$, \\f$L_z\\f$).\n @param[in] origin Cartesian coordinates defining the operator origin [size: 3]. CPU array. Must not be NULL.\n @param[out] outMatrix Output GPU buffer for computed angular momentum matrix elements [size: nao × nao]. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c component is not a valid \\c cuestAngularMomentumComputeParametersComponent_t value;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
792pub unsafe fn cuestAngularMomentumCompute(
793 handle: cuestHandle_t,
794 plan: cuestOEIntPlan_t,
795 parameters: cuestAngularMomentumComputeParameters_t,
796 temporaryWorkspace: *mut cuestWorkspace_t,
797 component: cuestAngularMomentumComputeParametersComponent_t,
798 origin: *const f64,
799 outMatrix: *mut f64,
800) -> cuestStatus_t {
801 dyload_lib()
802 .cuestAngularMomentumCompute
803 .expect("cuEST function `cuestAngularMomentumCompute` not found in the loaded library")(
804 handle,
805 plan,
806 parameters,
807 temporaryWorkspace,
808 component,
809 origin,
810 outMatrix,
811 )
812}
813
814#[doc = " @brief Query the temporary workspace required (in bytes) for angular momentum matrix calculation.\n @ingroup AngularMomentum\n @since v0.2.0\n\n This function computes the workspace requirements for a requested angular momentum calculation. Fill the\n provided workspace descriptor with host and device buffer sizes required. The \\c outMatrix pointer may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestAngularMomentumComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] component Enum (\\c cuestAngularMomentumComputeParametersComponent_t) defining the angular momentum operator (i.e. \\f$L_x\\f$, \\f$L_y\\f$, \\f$L_z\\f$).\n @param[in] origin Cartesian coordinates defining the operator origin [size: 3]. CPU array. Must not be NULL.\n @param outMatrix User matrix buffer (may be NULL during the workspace query).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c component is not a valid \\c cuestAngularMomentumComputeParametersComponent_t value;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
815pub unsafe fn cuestAngularMomentumComputeWorkspaceQuery(
816 handle: cuestHandle_t,
817 plan: cuestOEIntPlan_t,
818 parameters: cuestAngularMomentumComputeParameters_t,
819 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
820 component: cuestAngularMomentumComputeParametersComponent_t,
821 origin: *const f64,
822 outMatrix: *mut f64,
823) -> cuestStatus_t {
824 dyload_lib().cuestAngularMomentumComputeWorkspaceQuery.expect("cuEST function `cuestAngularMomentumComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, component, origin, outMatrix)
825}
826
827#[doc = " @brief Compute the electronic gradient (derivative) of the atomic orbital angular momentum matrix\n using the supplied integral plan and density matrix.\n @ingroup AngularMomentumGrad\n @since v0.2.0\n\n Both the input density matrix and the output gradient must be preallocated. The density\n matrix must be an (nao x nao) array and the output gradient must have space for (natom x 3)\n elements, where nao is the number of atomic orbitals and natom the number of atoms in the system.\n All required temporary workspace must be allocated by the user prior to calling this function.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestAngularMomentumDerivativeComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated). Must not be NULL.\n @param[in] component Enum (\\c cuestAngularMomentumComputeParametersComponent_t) defining the angular momentum operator (i.e. \\f$L_x\\f$, \\f$L_y\\f$, \\f$L_z\\f$).\n @param[in] origin Cartesian coordinates defining the operator origin [size: 3]. CPU array. Must not be NULL.\n @param[in] densityMatrix Pointer to input density matrix [size: nao × nao]. GPU array. Must not be NULL.\n @param[out] outGradient Pointer to GPU buffer for computed gradients [size: natom × 3]. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c component is not a valid \\c cuestAngularMomentumComputeParametersComponent_t value;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
828pub unsafe fn cuestAngularMomentumDerivativeCompute(
829 handle: cuestHandle_t,
830 plan: cuestOEIntPlan_t,
831 parameters: cuestAngularMomentumDerivativeComputeParameters_t,
832 temporaryWorkspace: *mut cuestWorkspace_t,
833 component: cuestAngularMomentumComputeParametersComponent_t,
834 origin: *const f64,
835 densityMatrix: *const f64,
836 outGradient: *mut f64,
837) -> cuestStatus_t {
838 dyload_lib().cuestAngularMomentumDerivativeCompute.expect(
839 "cuEST function `cuestAngularMomentumDerivativeCompute` not found in the loaded library",
840 )(
841 handle, plan, parameters, temporaryWorkspace, component, origin, densityMatrix, outGradient
842 )
843}
844
845#[doc = " @brief Query the temporary workspace required (in bytes) for angular momentum matrix gradient calculation.\n @ingroup AngularMomentumGrad\n @since v0.2.0\n\n This function computes the workspace requirements of a single gradient evaluation,\n based on the supplied plan and dimensions. The workspace descriptor is filled with host and device memory\n requirements. Output buffers may be NULL for the purposes of the query.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestAngularMomentumDerivativeComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] component Enum (\\c cuestAngularMomentumComputeParametersComponent_t) defining the angular momentum operator (i.e. \\f$L_x\\f$, \\f$L_y\\f$, \\f$L_z\\f$).\n @param[in] origin Cartesian coordinates defining the operator origin [size: 3]. CPU array. Must not be NULL.\n @param densityMatrix Optional density matrix pointer (may be NULL).\n @param outGradient Optional buffer for computed gradient (may be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c component is not a valid \\c cuestAngularMomentumComputeParametersComponent_t value;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
846pub unsafe fn cuestAngularMomentumDerivativeComputeWorkspaceQuery(
847 handle: cuestHandle_t,
848 plan: cuestOEIntPlan_t,
849 parameters: cuestAngularMomentumDerivativeComputeParameters_t,
850 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
851 component: cuestAngularMomentumComputeParametersComponent_t,
852 origin: *const f64,
853 densityMatrix: *const f64,
854 outGradient: *mut f64,
855) -> cuestStatus_t {
856 dyload_lib().cuestAngularMomentumDerivativeComputeWorkspaceQuery.expect("cuEST function `cuestAngularMomentumDerivativeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, component, origin, densityMatrix, outGradient)
857}
858
859#[doc = " @brief Compute the atomic orbital nabla matrix using the provided \\c cuestOEIntPlan_t plan.\n @ingroup Nabla\n @since v0.2.0\n\n The output buffer must be preallocated and sized for nao × nao elements, where nao is the\n number of atomic orbitals in the basis. Temporary workspace must be allocated using size\n returned by \\c cuestNablaComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestNablaComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated). Must not be NULL.\n @param[in] component Enum (\\c cuestNablaComputeParametersComponent_t) defining the nabla operator (i.e. \\f$\\nabla_x\\f$, \\f$\\nabla_y\\f$, or \\f$\\nabla_z\\f$).\n @param[out] outMatrix Output GPU buffer for computed nabla matrix elements [size: nao × nao]. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c component is not a valid \\c cuestNablaComputeParametersComponent_t value;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
860pub unsafe fn cuestNablaCompute(
861 handle: cuestHandle_t,
862 plan: cuestOEIntPlan_t,
863 parameters: cuestNablaComputeParameters_t,
864 temporaryWorkspace: *mut cuestWorkspace_t,
865 component: cuestNablaComputeParametersComponent_t,
866 outMatrix: *mut f64,
867) -> cuestStatus_t {
868 dyload_lib()
869 .cuestNablaCompute
870 .expect("cuEST function `cuestNablaCompute` not found in the loaded library")(
871 handle,
872 plan,
873 parameters,
874 temporaryWorkspace,
875 component,
876 outMatrix,
877 )
878}
879
880#[doc = " @brief Query the temporary workspace required (in bytes) for nabla matrix calculation.\n @ingroup Nabla\n @since v0.2.0\n\n This function computes the workspace requirements for a requested nabla calculation. Fill the\n provided workspace descriptor with host and device buffer sizes required. The \\c outMatrix pointer may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestNablaComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] component Enum (\\c cuestNablaComputeParametersComponent_t) defining the nabla operator (i.e. \\f$\\nabla_x\\f$, \\f$\\nabla_y\\f$, or \\f$\\nabla_z\\f$).\n @param outMatrix User matrix buffer (may be NULL during the workspace query).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c component is not a valid \\c cuestNablaComputeParametersComponent_t value;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
881pub unsafe fn cuestNablaComputeWorkspaceQuery(
882 handle: cuestHandle_t,
883 plan: cuestOEIntPlan_t,
884 parameters: cuestNablaComputeParameters_t,
885 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
886 component: cuestNablaComputeParametersComponent_t,
887 outMatrix: *mut f64,
888) -> cuestStatus_t {
889 dyload_lib()
890 .cuestNablaComputeWorkspaceQuery
891 .expect("cuEST function `cuestNablaComputeWorkspaceQuery` not found in the loaded library")(
892 handle,
893 plan,
894 parameters,
895 temporaryWorkspaceDescriptor,
896 component,
897 outMatrix,
898 )
899}
900
901#[doc = " @brief Compute the electronic gradient (derivative) of the atomic orbital nabla matrix\n using the supplied integral plan and density matrix.\n @ingroup NablaGrad\n @since v0.2.0\n\n Both the input density matrix and the output gradient must be preallocated. The density\n matrix must be an (nao x nao) array and the output gradient must have space for (natom x 3)\n elements, where nao is the number of atomic orbitals and natom the number of atoms in the system.\n All required temporary workspace must be allocated by the user prior to calling this function.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestNablaDerivativeComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers for computation (preallocated). Must not be NULL.\n @param[in] component Enum (\\c cuestNablaComputeParametersComponent_t) defining the nabla operator (i.e. \\f$\\nabla_x\\f$, \\f$\\nabla_y\\f$, or \\f$\\nabla_z\\f$).\n @param[in] densityMatrix Pointer to input density matrix [size: nao × nao]. GPU array. Must not be NULL.\n @param[out] outGradient Pointer to GPU buffer for computed gradients [size: natom × 3]. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c component is not a valid \\c cuestNablaComputeParametersComponent_t value;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
902pub unsafe fn cuestNablaDerivativeCompute(
903 handle: cuestHandle_t,
904 plan: cuestOEIntPlan_t,
905 parameters: cuestNablaDerivativeComputeParameters_t,
906 temporaryWorkspace: *mut cuestWorkspace_t,
907 component: cuestNablaComputeParametersComponent_t,
908 densityMatrix: *const f64,
909 outGradient: *mut f64,
910) -> cuestStatus_t {
911 dyload_lib()
912 .cuestNablaDerivativeCompute
913 .expect("cuEST function `cuestNablaDerivativeCompute` not found in the loaded library")(
914 handle,
915 plan,
916 parameters,
917 temporaryWorkspace,
918 component,
919 densityMatrix,
920 outGradient,
921 )
922}
923
924#[doc = " @brief Query the temporary workspace required (in bytes) for nabla matrix gradient calculation.\n @ingroup NablaGrad\n @since v0.2.0\n\n This function computes the workspace requirements of a single gradient evaluation,\n based on the supplied plan and dimensions. The workspace descriptor is filled with host and device memory\n requirements. Output buffers may be NULL for the purposes of the query.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestNablaDerivativeComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] component Enum (\\c cuestNablaComputeParametersComponent_t) defining the nabla operator (i.e. \\f$\\nabla_x\\f$, \\f$\\nabla_y\\f$, or \\f$\\nabla_z\\f$).\n @param densityMatrix Optional density matrix pointer (may be NULL).\n @param outGradient Optional buffer for computed gradient (may be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c component is not a valid \\c cuestNablaComputeParametersComponent_t value;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
925pub unsafe fn cuestNablaDerivativeComputeWorkspaceQuery(
926 handle: cuestHandle_t,
927 plan: cuestOEIntPlan_t,
928 parameters: cuestNablaDerivativeComputeParameters_t,
929 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
930 component: cuestNablaComputeParametersComponent_t,
931 densityMatrix: *const f64,
932 outGradient: *mut f64,
933) -> cuestStatus_t {
934 dyload_lib().cuestNablaDerivativeComputeWorkspaceQuery.expect("cuEST function `cuestNablaDerivativeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, component, densityMatrix, outGradient)
935}
936
937#[doc = " @brief Compute the atomic orbital nuclear attraction (potential energy) matrix (V) for given point charges.\n @ingroup Potential\n\n This function computes the AO potential energy matrix for a set of point charges (typically nuclei) as:\n \\f[ V_{pq} = \\sum_{A} q_A * \\left< p \\left| \\frac{1}{|r - R_A|} \\right| q \\right> \\f]\n All input arrays must be preallocated and valid.\n - The \\c xyz array has size \\c numCharges × 3 (row major order: \\f$ [x_0, y_0, z_0, x_1, y_1, z_1, ...] \\f$ ).\n - The \\c q array has length \\c numCharges.\n - The output buffer \\c outVMatrix must be preallocated for (nao × nao) doubles.\n Temporary workspace must be preallocated using the requirements from \\c cuestPotentialComputeWorkspaceQuery.\n\n Note:\n - The potential is evaluated with a positive unit test charge. To obtain\n nuclear attraction integrals, the \\c q array could have negative entries. Alternatively, the \\c q array\n could have positive entries and the result scaled by the charge of an electron (i.e. -1 in atomic units).\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_POTENTIALCOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_POTENTIALCOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is expected to provide\n a performance advantage on the present GPU architecture.\n - ffloat compute is only compatible with JIT-compiled kernels. Requesting ffloat compute while JIT is\n disabled (\\c CUEST_FFLOAT_USAGE_MODE_ON together with \\c CUEST_JIT_USAGE_MODE_OFF) is not supported and\n returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestPotentialComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers, preallocated as required. Must not be NULL.\n @param[in] numCharges Number of point charges (must be greater than zero).\n @param[in] xyz Array of charge coordinates (size: \\c numCharges × 3) in atomic units on GPU. Must not be NULL.\n @param[in] q Array of charge magnitudes (size: \\c numCharges) on GPU. Must not be NULL.\n @param[out] outVMatrix Output AO potential matrix buffer (size: nao × nao) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numCharges is zero;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package, or if ffloat compute is requested while JIT is disabled (incompatible\n JIT/ffloat combination);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
938pub unsafe fn cuestPotentialCompute(
939 handle: cuestHandle_t,
940 plan: cuestOEIntPlan_t,
941 parameters: cuestPotentialComputeParameters_t,
942 temporaryWorkspace: *mut cuestWorkspace_t,
943 numCharges: u64,
944 xyz: *const f64,
945 q: *const f64,
946 outVMatrix: *mut f64,
947) -> cuestStatus_t {
948 dyload_lib()
949 .cuestPotentialCompute
950 .expect("cuEST function `cuestPotentialCompute` not found in the loaded library")(
951 handle,
952 plan,
953 parameters,
954 temporaryWorkspace,
955 numCharges,
956 xyz,
957 q,
958 outVMatrix,
959 )
960}
961
962#[doc = " @brief Query the temporary workspace required (in bytes) for a potential energy matrix calculation.\n @ingroup Potential\n\n This function calculates the workspace required for a potential energy matrix evaluation,\n returning host/device workspace buffer sizes in the output descriptor. The user arrays \\c q, \\c xyz, and \\c outVMatrix may be NULL;\n only sizes are computed. \\c numCharges must be greater than zero.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_POTENTIALCOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_POTENTIALCOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is expected to provide\n a performance advantage on the present GPU architecture.\n - ffloat compute is only compatible with JIT-compiled kernels. Requesting ffloat compute while JIT is\n disabled (\\c CUEST_FFLOAT_USAGE_MODE_ON together with \\c CUEST_JIT_USAGE_MODE_OFF) is not supported and\n returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestPotentialComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes (host and device). Must not be NULL.\n @param[in] numCharges Number of point charges (must be greater than zero.).\n @param xyz Optional array of charge coordinates (may be NULL).\n @param q Optional array of charge magnitudes (may be NULL).\n @param outVMatrix Optional output AO potential matrix buffer (may be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numCharges is zero;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package, or if ffloat compute is requested while JIT is disabled (incompatible\n JIT/ffloat combination);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
963pub unsafe fn cuestPotentialComputeWorkspaceQuery(
964 handle: cuestHandle_t,
965 plan: cuestOEIntPlan_t,
966 parameters: cuestPotentialComputeParameters_t,
967 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
968 numCharges: u64,
969 xyz: *const f64,
970 q: *const f64,
971 outVMatrix: *mut f64,
972) -> cuestStatus_t {
973 dyload_lib().cuestPotentialComputeWorkspaceQuery.expect(
974 "cuEST function `cuestPotentialComputeWorkspaceQuery` not found in the loaded library",
975 )(handle, plan, parameters, temporaryWorkspaceDescriptor, numCharges, xyz, q, outVMatrix)
976}
977
978#[doc = " @brief Compute the potential integral derivatives with respect to atomic and charge coordinates,\n contracted with a density matrix.\n @ingroup PotentialGrad\n\n This routine evaluates the derivative of the potential integrals and contracts the result with\n a density matrix in the AO basis. The resulting gradient is returned both with\n respect to the AO basis functions and with respect to the point-charge\n coordinates. All required temporary workspace must be sized and allocated\n using the corresponding workspace query function.\n\n The user must provide:\n - A preallocated/populated density matrix of size (nao × nao).\n - A list of point charges and their Cartesian coordinates.\n - Preallocated output buffers for the AO basis gradients and charge gradients (to be overwritten).\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_POTENTIALDERIVATIVECOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_POTENTIALDERIVATIVECOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is expected to provide\n a performance advantage on the present GPU architecture.\n - ffloat compute is only compatible with JIT-compiled kernels. Requesting ffloat compute while JIT is\n disabled (\\c CUEST_FFLOAT_USAGE_MODE_ON together with \\c CUEST_JIT_USAGE_MODE_OFF) is not supported and\n returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - It is recommended to leave \\c CUEST_FFLOAT_USAGE_MODE_OFF for general use of the potential derivative.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestPotentialDerivativeComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffers (preallocated for this operation). Must not be NULL.\n @param[in] numCharges Number of point charges. Must be greater than zero.\n @param[in] xyz Cartesian coordinates of the point charges\n (size: \\c numCharges × 3, in row-major order) on GPU. Must not be NULL.\n @param[in] q Point charges (size: \\c numCharges) on GPU. Must not be NULL.\n @param[in] densityMatrix Input density matrix (size: nao × nao) on GPU. Must not be NULL.\n @param[out] outBasisGradient Output gradient with respect to AO basis centers\n (size: natom × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n @param[out] outChargeGradient Output gradient with respect to the point-charge coordinates\n (size: \\c numCharges × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numCharges is zero;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package, or if ffloat compute is requested while JIT is disabled (incompatible\n JIT/ffloat combination);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
979pub unsafe fn cuestPotentialDerivativeCompute(
980 handle: cuestHandle_t,
981 plan: cuestOEIntPlan_t,
982 parameters: cuestPotentialDerivativeComputeParameters_t,
983 temporaryWorkspace: *mut cuestWorkspace_t,
984 numCharges: u64,
985 xyz: *const f64,
986 q: *const f64,
987 densityMatrix: *const f64,
988 outBasisGradient: *mut f64,
989 outChargeGradient: *mut f64,
990) -> cuestStatus_t {
991 dyload_lib()
992 .cuestPotentialDerivativeCompute
993 .expect("cuEST function `cuestPotentialDerivativeCompute` not found in the loaded library")(
994 handle,
995 plan,
996 parameters,
997 temporaryWorkspace,
998 numCharges,
999 xyz,
1000 q,
1001 densityMatrix,
1002 outBasisGradient,
1003 outChargeGradient,
1004 )
1005}
1006
1007#[doc = " @brief Query the temporary workspace required to compute the potential integral\n derivatives with respect to atomic and charge coordinates,\n contracted with a density matrix.\n @ingroup PotentialGrad\n\n This function determines the workspace required for a potential derivative\n evaluation with a given plan and point-charge specification. The output\n descriptor is filled on success and can be used to allocate host and device\n workspace buffers prior to calling \\c cuestPotentialDerivativeCompute.\n\n The density matrix and output gradient pointers are optional and may be NULL.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_POTENTIALDERIVATIVECOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_POTENTIALDERIVATIVECOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is expected to provide\n a performance advantage on the present GPU architecture.\n - ffloat compute is only compatible with JIT-compiled kernels. Requesting ffloat compute while JIT is\n disabled (\\c CUEST_FFLOAT_USAGE_MODE_ON together with \\c CUEST_JIT_USAGE_MODE_OFF) is not supported and\n returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - It is recommended to leave \\c CUEST_FFLOAT_USAGE_MODE_OFF for general use of the potential derivative.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan One-electron integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestPotentialDerivativeComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes (host and device). Must not be NULL.\n @param[in] numCharges Number of point charges. Must be greater than zero.\n @param xyz Optional Cartesian coordinates of the point charges. May be NULL.\n @param q Optional point charges. May be NULL.\n @param densityMatrix Optional density matrix. May be NULL.\n @param outBasisGradient Optional output gradient buffer with respect to AO basis centers. May be NULL.\n @param outChargeGradient Optional output gradient buffer with respect to the point-charge coordinates. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numCharges is zero;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package, or if ffloat compute is requested while JIT is disabled (incompatible\n JIT/ffloat combination);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1008pub unsafe fn cuestPotentialDerivativeComputeWorkspaceQuery(
1009 handle: cuestHandle_t,
1010 plan: cuestOEIntPlan_t,
1011 parameters: cuestPotentialDerivativeComputeParameters_t,
1012 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1013 numCharges: u64,
1014 xyz: *const f64,
1015 q: *const f64,
1016 densityMatrix: *const f64,
1017 outBasisGradient: *mut f64,
1018 outChargeGradient: *mut f64,
1019) -> cuestStatus_t {
1020 dyload_lib().cuestPotentialDerivativeComputeWorkspaceQuery.expect("cuEST function `cuestPotentialDerivativeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, numCharges, xyz, q, densityMatrix, outBasisGradient, outChargeGradient)
1021}
1022
1023#[doc = " @brief Compute the AO Coulomb (J) matrix using density fitting (DF) with the supplied DF integral plan and density matrix.\n @ingroup Coulomb\n\n This routine computes the Coulomb matrix (J) from a density matrix using an auxiliary basis and\n density-fitted integrals. The user must provide a preallocated density matrix (size: nao × nao),\n a \\c cuestDFIntPlan_t, and a preallocated output buffer (size: nao × nao).\n All required temporary workspace must be allocated using the size returned by\n \\c cuestDFCoulombComputeWorkspaceQuery.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_DFCOULOMBCOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_DFCOULOMBCOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is expected to provide\n a performance advantage on the present GPU architecture.\n - ffloat compute is only compatible with JIT-compiled kernels. Requesting ffloat compute while JIT is\n disabled (\\c CUEST_FFLOAT_USAGE_MODE_ON together with \\c CUEST_JIT_USAGE_MODE_OFF) is not supported and\n returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan Density-fitted integral plan (opaque handle) constructed with \\c cuestDFIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestDFCoulombComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] densityMatrix Input density matrix (size: nao × nao) on GPU. Must not be NULL.\n @param[out] outCoulombMatrix Output buffer for computed Coulomb matrix (size: nao × nao) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_PLAN if the \\c cuestDFIntPlan_t is not correctly configured or in a dirty state;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package, or if ffloat compute is requested while JIT is disabled (incompatible\n JIT/ffloat combination);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1024pub unsafe fn cuestDFCoulombCompute(
1025 handle: cuestHandle_t,
1026 plan: cuestDFIntPlan_t,
1027 parameters: cuestDFCoulombComputeParameters_t,
1028 temporaryWorkspace: *mut cuestWorkspace_t,
1029 densityMatrix: *const f64,
1030 outCoulombMatrix: *mut f64,
1031) -> cuestStatus_t {
1032 dyload_lib()
1033 .cuestDFCoulombCompute
1034 .expect("cuEST function `cuestDFCoulombCompute` not found in the loaded library")(
1035 handle,
1036 plan,
1037 parameters,
1038 temporaryWorkspace,
1039 densityMatrix,
1040 outCoulombMatrix,
1041 )
1042}
1043
1044#[doc = " @brief Query the temporary workspace required (in bytes) for a DF Coulomb matrix computation.\n @ingroup Coulomb\n\n This function returns the workspace needed (host/device) for a single computation,\n based on the provided \\c cuestDFIntPlan_t. Only sizes are computed; output and density\n buffers may be NULL.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_DFCOULOMBCOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_DFCOULOMBCOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is expected to provide\n a performance advantage on the present GPU architecture.\n - ffloat compute is only compatible with JIT-compiled kernels. Requesting ffloat compute while JIT is\n disabled (\\c CUEST_FFLOAT_USAGE_MODE_ON together with \\c CUEST_JIT_USAGE_MODE_OFF) is not supported and\n returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan Density-fitted integral plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestDFCoulombComputeParameters_t). Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param densityMatrix Optional density matrix (may be NULL).\n @param outCoulombMatrix Optional output Coulomb matrix (may be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_PLAN if the \\c cuestDFIntPlan_t is not correctly configured or in a dirty state;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package, or if ffloat compute is requested while JIT is disabled (incompatible\n JIT/ffloat combination);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1045pub unsafe fn cuestDFCoulombComputeWorkspaceQuery(
1046 handle: cuestHandle_t,
1047 plan: cuestDFIntPlan_t,
1048 parameters: cuestDFCoulombComputeParameters_t,
1049 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1050 densityMatrix: *const f64,
1051 outCoulombMatrix: *mut f64,
1052) -> cuestStatus_t {
1053 dyload_lib().cuestDFCoulombComputeWorkspaceQuery.expect(
1054 "cuEST function `cuestDFCoulombComputeWorkspaceQuery` not found in the loaded library",
1055 )(handle, plan, parameters, temporaryWorkspaceDescriptor, densityMatrix, outCoulombMatrix)
1056}
1057
1058#[doc = " @brief Compute the AO symmetric exchange (K) matrix using density fitting (DF) with the supplied DF integral plan and coefficient matrix.\n @ingroup Exchange\n\n - The input coefficient matrix must be preallocated to size (\\c numOccupied × nao) (row-major).\n - The output buffer \\c outExchangeMatrix must be preallocated for (nao × nao) doubles.\n - All handles, pointers, and buffers must be valid and non-NULL.\n - Temporary workspace must be preallocated using size returned by \\c cuestDFSymmetricExchangeComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan Density-fitted integral plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestDFSymmetricExchangeComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for an internal scratch buffer (host and device). Must not be NULL.\n For most problem sizes, 8 GB is a good buffer size. On older devices, such as A100,\n smaller buffer sizes down to 2 GB can be used without degrading performance. Host memory\n is currently unused. Note that the variableBufferSize does not limit total memory usage.\n There may be static allocations required outside of the scope of what is limited by the\n variableBufferSize. This value must remain unchanged between WorkspaceQuery and Compute calls.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param[in] coefficientMatrix Input coefficient matrix (size: \\c numOccupied × nao) on GPU. Must not be NULL.\n @param[out] outExchangeMatrix Output buffer for the AO exchange matrix (size: nao × nao) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_PLAN if the \\c cuestDFIntPlan_t is not correctly configured or in a dirty state;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise.\n\n The exchange matrix is computed as:\n \\f[ K_{\\mu\\nu} = \\sum^{N_{ao}}_{\\lambda\\sigma} \\sum^{N_{occ}}_{i}\n \\left[ f_{\\rm HF} (\\mu\\lambda|\\frac{1}{r}|\\nu\\sigma) + f_{\\rm LRC} (\\mu\\lambda|\\frac{{\\rm erf}(\\omega r)}{r}|\\nu\\sigma) \\right]\n C_{i\\lambda} C_{i\\sigma} \\f]\n\n where \\f$ f_{\\rm HF} \\f$ is the fraction of Hartree-Fock exchange to add (\\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION),\n \\f$ f_{\\rm LRC} \\f$ is the fraction of the long-range component of range-separated exchange to add (\\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION),\n and \\f$ \\omega \\f$ is the range-separation parameter.\n\n When the operator definition leads to zero exchange, the exchange matrix is still calculated and scaled by zero. The user should\n avoid calling this function in that case to avoid unnecessary compute.\n"]
1059pub unsafe fn cuestDFSymmetricExchangeCompute(
1060 handle: cuestHandle_t,
1061 plan: cuestDFIntPlan_t,
1062 parameters: cuestDFSymmetricExchangeComputeParameters_t,
1063 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1064 temporaryWorkspace: *mut cuestWorkspace_t,
1065 numOccupied: u64,
1066 coefficientMatrix: *const f64,
1067 outExchangeMatrix: *mut f64,
1068) -> cuestStatus_t {
1069 dyload_lib()
1070 .cuestDFSymmetricExchangeCompute
1071 .expect("cuEST function `cuestDFSymmetricExchangeCompute` not found in the loaded library")(
1072 handle,
1073 plan,
1074 parameters,
1075 variableBufferSize,
1076 temporaryWorkspace,
1077 numOccupied,
1078 coefficientMatrix,
1079 outExchangeMatrix,
1080 )
1081}
1082
1083#[doc = " @brief Query the temporary workspace required (in bytes) for a DF exchange matrix calculation.\n @ingroup Exchange\n\n This function returns (via output parameters) the host and device workspace buffer sizes needed to perform\n a symmetric exchange computation, given the plan and matrix dimensions. The coefficient matrix and output\n buffer may be NULL (only sizes are computed).\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan Density-fitted integral plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestDFSymmetricExchangeComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for an internal scratch buffer (host and device). Must not be NULL.\n For most problem sizes, 8 GB is a good buffer size. On older devices, such as A100,\n smaller buffer sizes down to 2 GB can be used without degrading performance. Host memory\n is currently unused. Note that the variableBufferSize does not limit total memory usage.\n There may be static allocations required outside of the scope of what is limited by the\n variableBufferSize. This value must remain unchanged between WorkspaceQuery and Compute calls.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for workspace sizes (host and device). Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param coefficientMatrix Optional pointer to coefficient matrix buffer (may be NULL).\n @param outExchangeMatrix Optional pointer to output exchange matrix buffer (may be NULL).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_PLAN if the \\c cuestDFIntPlan_t is not correctly configured or in a dirty state;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1084pub unsafe fn cuestDFSymmetricExchangeComputeWorkspaceQuery(
1085 handle: cuestHandle_t,
1086 plan: cuestDFIntPlan_t,
1087 parameters: cuestDFSymmetricExchangeComputeParameters_t,
1088 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1089 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1090 numOccupied: u64,
1091 coefficientMatrix: *const f64,
1092 outExchangeMatrix: *mut f64,
1093) -> cuestStatus_t {
1094 dyload_lib().cuestDFSymmetricExchangeComputeWorkspaceQuery.expect("cuEST function `cuestDFSymmetricExchangeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, variableBufferSize, temporaryWorkspaceDescriptor, numOccupied, coefficientMatrix, outExchangeMatrix)
1095}
1096
1097#[doc = " @brief Compute AO exchange (K) matrices with nonsymmetric densities using density fitting (DF) with the supplied DF integral plan and coefficient matrices.\n @ingroup Exchange\n @since v0.2.0\n\n - The input left coefficient matrix must be preallocated to size (\\c numOccupied × nao) (row-major).\n - The input right coefficient matrices must be preallocated to size (\\c numCoefficientMatrices × numOccupied × nao) (row-major).\n - The output buffer \\c outExchangeMatrices must be preallocated for (\\c numCoefficientMatrices × nao × nao) doubles.\n - All handles, pointers, and buffers must be valid and non-NULL.\n - Temporary workspace must be preallocated using size returned by \\c cuestDFNonsymmetricExchangeComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan Density-fitted integral plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestDFNonsymmetricExchangeComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for an internal scratch buffer (host and device). Must not be NULL.\n For most problem sizes, 8 GB is a good buffer size. On older devices, such as A100,\n smaller buffer sizes down to 2 GB can be used without degrading performance. Host memory\n is currently unused. Note that the variableBufferSize does not limit total memory usage.\n There may be static allocations required outside of the scope of what is limited by the\n variableBufferSize. This value must remain unchanged between WorkspaceQuery and Compute calls.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numCoefficientMatrices Number of right coefficient matrices provided and output exchange matrices; must be greater than zero.\n @param[in] numOccupied Number of occupied orbitals (rows in left and right coefficient matrices); must be greater than zero.\n @param[in] leftCoefficientMatrix Input left coefficient matrix (size: \\c numOccupied × nao) on GPU. Must not be NULL.\n @param[in] rightCoefficientMatrices Input right coefficient matrices (size: \\c numCoefficientMatrices × numOccupied × nao) on GPU. Must not be NULL.\n @param[out] outExchangeMatrices Output buffer for the AO exchange matrices (size: numCoefficientMatrices × nao × nao) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_PLAN if the \\c cuestDFIntPlan_t is not correctly configured or in a dirty state;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied or \\c numCoefficientMatrices is zero;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise.\n\n The exchange matrix is computed as:\n \\f[ K^{n}_{\\mu\\nu} = \\sum^{N_{ao}}_{\\lambda\\sigma} \\sum^{N_{occ}}_{i}\n \\left[ f_{\\rm HF} (\\mu\\lambda|\\frac{1}{r}|\\nu\\sigma) + f_{\\rm LRC} (\\mu\\lambda|\\frac{{\\rm erf}(\\omega r)}{r}|\\nu\\sigma) \\right]\n L_{i\\lambda} R^{n}_{i\\sigma} \\f]\n\n where \\f$ f_{\\rm HF} \\f$ is the fraction of Hartree-Fock exchange to add (\\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION),\n \\f$ f_{\\rm LRC} \\f$ is the fraction of the long-range component of range-separated exchange to add (\\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION),\n and \\f$ \\omega \\f$ is the range-separation parameter.\n\n When the operator definition leads to zero exchange, the exchange matrix is still calculated and scaled by zero. The user should\n avoid calling this function in that case to avoid unnecessary compute."]
1098pub unsafe fn cuestDFNonsymmetricExchangeCompute(
1099 handle: cuestHandle_t,
1100 plan: cuestDFIntPlan_t,
1101 parameters: cuestDFNonsymmetricExchangeComputeParameters_t,
1102 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1103 temporaryWorkspace: *mut cuestWorkspace_t,
1104 numCoefficientMatrices: u64,
1105 numOccupied: u64,
1106 leftCoefficientMatrix: *const f64,
1107 rightCoefficientMatrices: *const f64,
1108 outExchangeMatrices: *mut f64,
1109) -> cuestStatus_t {
1110 dyload_lib().cuestDFNonsymmetricExchangeCompute.expect(
1111 "cuEST function `cuestDFNonsymmetricExchangeCompute` not found in the loaded library",
1112 )(
1113 handle,
1114 plan,
1115 parameters,
1116 variableBufferSize,
1117 temporaryWorkspace,
1118 numCoefficientMatrices,
1119 numOccupied,
1120 leftCoefficientMatrix,
1121 rightCoefficientMatrices,
1122 outExchangeMatrices,
1123 )
1124}
1125
1126#[doc = " @brief Query the temporary workspace required (in bytes) for the calculation of nonsymmetric DF exchange matrices.\n @ingroup Exchange\n @since v0.2.0\n\n This function returns (via output parameters) the host and device workspace buffer sizes needed to perform\n a nonsymmetric exchange computation, given the plan and matrix dimensions. The coefficient matrices and output\n buffer may be NULL (only sizes are computed).\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan Density-fitted integral plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestDFNonsymmetricExchangeComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for an internal scratch buffer (host and device). Must not be NULL.\n For most problem sizes, 8 GB is a good buffer size. On older devices, such as A100,\n smaller buffer sizes down to 2 GB can be used without degrading performance. Host memory\n is currently unused. Note that the variableBufferSize does not limit total memory usage.\n There may be static allocations required outside of the scope of what is limited by the\n variableBufferSize. This value must remain unchanged between WorkspaceQuery and Compute calls.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for workspace sizes (host and device). Must not be NULL.\n @param[in] numCoefficientMatrices Number of right coefficient matrices provided and output exchange matrices; must be greater than zero.\n @param[in] numOccupied Number of occupied orbitals (rows in left and right coefficient matrices); must be greater than zero.\n @param leftCoefficientMatrix Input left coefficient matrix (size: \\c numOccupied × nao) on GPU. May be NULL.\n @param rightCoefficientMatrices Input right coefficient matrices (size: \\c numCoefficientMatrices × numOccupied × nao) on GPU. May be NULL.\n @param outExchangeMatrices Output buffer for the AO exchange matrices (size: numCoefficientMatrices × nao × nao) on GPU. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_PLAN if the \\c cuestDFIntPlan_t is not correctly configured or in a dirty state;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied or \\c numCoefficientMatrices is zero;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1127pub unsafe fn cuestDFNonsymmetricExchangeComputeWorkspaceQuery(
1128 handle: cuestHandle_t,
1129 plan: cuestDFIntPlan_t,
1130 parameters: cuestDFNonsymmetricExchangeComputeParameters_t,
1131 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1132 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1133 numCoefficientMatrices: u64,
1134 numOccupied: u64,
1135 leftCoefficientMatrix: *const f64,
1136 rightCoefficientMatrices: *const f64,
1137 outExchangeMatrices: *mut f64,
1138) -> cuestStatus_t {
1139 dyload_lib().cuestDFNonsymmetricExchangeComputeWorkspaceQuery.expect("cuEST function `cuestDFNonsymmetricExchangeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, variableBufferSize, temporaryWorkspaceDescriptor, numCoefficientMatrices, numOccupied, leftCoefficientMatrix, rightCoefficientMatrices, outExchangeMatrices)
1140}
1141
1142#[doc = " @brief Compute the nuclear gradient of the symmetric DF J/K matrices contracted\n with a density matrix and multiple coefficient matrices.\n @ingroup JKGrad\n\n This routine evaluates the nuclear derivatives (gradients) of the Coulomb (J) and\n exchange (K) matrices in density fitting approximation, where the J matrix is\n contracted with a single density matrix and the K matrices are contracted with\n multiple occupied orbital coefficient matrices. The result overwrites the\n output gradient buffer (size: natom × 3).\n\n All required temporary workspace must be sized using the corresponding workspace\n query function. A \\c variableBufferSize descriptor must also be provided to\n constrain the memory usage.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_DFSYMMETRICDERIVATIVECOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_DFSYMMETRICDERIVATIVECOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is expected to provide\n a performance advantage on the present GPU architecture.\n - ffloat compute is only compatible with JIT-compiled kernels. Requesting ffloat compute while JIT is\n disabled (\\c CUEST_FFLOAT_USAGE_MODE_ON together with \\c CUEST_JIT_USAGE_MODE_OFF) is not supported and\n returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan DF integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestDFSymmetricDerivativeComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize The variableBufferSize determines the size of an internal scratch buffer\n used for certain transformations. A buffer of 2GB is a reasonable default value.\n Host memory is currently unused. Note that the variableBufferSize does not limit total\n memory usage. The value of the variableBufferSize must not change between WorkspaceQuery\n and Compute calls.\n @param[in] temporaryWorkspace Temporary workspace buffers (preallocated for\n this operation using the query function).\n Must not be NULL.\n @param[in] densityScale Scaling factor for the J (Coulomb) contribution.\n @param[in] densityMatrix Input density matrix (size: nao × nao) on GPU.\n Must not be NULL.\n @param[in] coefficientScale Scaling factor for each K (exchange) contribution.\n @param[in] numCoefficientMatrices Number of coefficient matrices. Must be > 0 when exchange is active; may be 0 for pure functionals.\n @param[in] numOccupied Array of occupied orbital counts for each\n coefficient matrix (size: \\c numCoefficientMatrices) on CPU.\n Each entry must be > 0 when exchange is active; for pure functionals the array may be NULL or contain zeros.\n @param[in] coefficientMatrices Concatenated coefficient matrices. Each matrix\n has shape [\\c numOccupied[i], nao] on GPU. Total size:\n sum(\\c numOccupied[i]) × nao. Must not be NULL when exchange\n is active; may be NULL for pure functionals (if provided, it is ignored).\n @param[out] outGradient Output nuclear gradient (size: natom × 3) on GPU.\n Gradient results overwrite this buffer.\n Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_PLAN if the \\c cuestDFIntPlan_t is not correctly configured or in a dirty state;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c coefficientScale != 0.0 and\n if \\c numCoefficientMatrices == 0 or any \\c numOccupied[i] == 0;\n or if \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION or \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION\n != 0.0 and\n if \\c numCoefficientMatrices == 0 or any \\c numOccupied[i] == 0;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package, or if ffloat compute is requested while JIT is disabled (incompatible\n JIT/ffloat combination);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise.\n\n The bare Coulomb and exchange energies are given as:\n\n \\f[ E_{J} = \\sum_{\\mu\\nu\\lambda\\sigma} D_{\\mu\\nu} (\\mu\\nu|\\lambda\\sigma) D_{\\lambda\\sigma} \\f]\n \\f[ E_{K}^{N} = \\sum_{\\mu\\nu\\lambda\\sigma} \\sum_{ij}\n \\left[ f_{\\rm HF} (\\mu\\lambda|\\frac{1}{r}|\\nu\\sigma) + f_{\\rm LRC} (\\mu\\lambda|\\frac{{\\rm erf}(\\omega r)}{r}|\\nu\\sigma) \\right]\n C_{i\\mu}^{N} C_{i\\nu}^{N} C_{j\\lambda}^{N} C_{j\\sigma}^{N} \\f]\n\n An effective J/K energy can be written as:\n\n \\f[ E_{JK} = s_D * E_{J} + \\sum_{N} s_C * E_{K}^{N} \\f]\n\n where\n - \\f$ s_D \\f$ is a density scaling factor \\c densityScale,\n - \\f$ s_C \\f$ is a coefficient scaling factor \\c coefficientScale,\n - \\f$ f_{\\rm HF} \\f$ is the fraction of Hartree-Fock exchange to add, \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION\n - \\f$ f_{\\rm LRC} \\f$ is the fraction of long-range range-separated exchange to add, \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION\n - \\f$ \\omega \\f$ is the range-separation parameter to use, \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA\n\n This function computes: \\f$dE_{JK}/dR\\f$, where R represents the basis function centers of the electron\n repulsion integrals.\n\n \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION, \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION, and \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA\n are set when the \\c cuestDFIntPlan_t is constructed and is intended to\n describe the exchange parameterization in hybrid and range-separated hybrid functionals.\n\n The \\c densityScale and \\c coefficientScale parameters are intended to account for the spin summations needed to obtain\n the correct two-electron energy.\n\n For example, in a B3LYP RKS computation the intended usage would be:\n - \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION = 0.2\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION = 0.0\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA unused\n - \\c densityScale = 2.0\n - \\c coefficientScale = -1.0\n - \\c numCoefficientMatrices = 1\n - \\f$ D_{mn} = \\sum_{i} C_{im} C_{in} \\f$\n - \\f$ I_{ij} = \\sum_{mn} C_{im} S_{mn} C_{jn} \\f$\n\n For a PBE0 UKS computation the intended usage would be:\n - \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION = 0.25\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION = 0.0\n - \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA unused\n - \\c densityScale = 0.5\n - \\c coefficientScale = -0.5\n - \\c numCoefficientMatrices = 2\n - \\f$D_{mn} = \\sum_{i} C_{im}^{\\alpha} C_{in}^{\\alpha} + \\sum_{i} C_{im}^{\\beta} C_{in}^{\\beta} \\f$\n - \\f$I_{ij} = \\sum_{mn} C_{im}^{\\alpha} S_{mn} C_{jn}^{\\alpha} \\f$\n - \\f$I_{ij} = \\sum_{mn} C_{im}^{\\beta} S_{mn} C_{jn}^{\\beta} \\f$\n\n For pure functionals, where \\c coefficientScale = 0.0 (\\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION\n and \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION are zero),\n the coefficient matrices do not need to be provided (if they are, they will not be used). For the pure\n functional case, the \\c numCoefficientMatrices can be 0. The \\c numOccupied array can be NULL (or contain zeros).\n The \\c coefficientMatrices array can be NULL.\n\n The following memory usage considerations apply only to cases where the fraction of Hartree-Fock exchange is non-zero.\n\n The memory usage during the gradient evaluation can be changed at a high level by CUEST_DFSYMMETRICDERIVATIVECOMPUTE_PARAMETERS_MEMORY_POLICY.\n - \\c CUEST_DFSYMMETRICDERIVATIVECOMPUTE_MEMORY_POLICY_DEVICECACHE: Default. This will provide good performance, but may try to allocate a large\n amount of GPU memory.\n - \\c CUEST_DFSYMMETRICDERIVATIVECOMPUTE_MEMORY_POLICY_HOSTCACHE: Provides similar performance, but will allocate that memory on the CPU,\n incurring a bit of overhead transferring memory to/from the CPU.\n - \\c CUEST_DFSYMMETRICDERIVATIVECOMPUTE_MEMORY_POLICY_OVERWRITE: Preferred, where possible.\n This memory policy avoids any additional large allocations and/or host/device memory transfers by overwriting some of the temporary data in\n the \\c cuestDFIntPlan_t. This corrupts the \\c cuestDFIntPlan_t and should be destroyed following this call.\n If the gradient evaluation is the final function call\n using the \\c cuestDFIntPlan_t, then this is optimal (this is often the case in usual HF/DFT gradient calculations).\n If the \\c cuestDFIntPlan_t will be needed again, then this option is not suitable.\n - \\c CUEST_DFSYMMETRICDERIVATIVECOMPUTE_MEMORY_POLICY_RECOMPUTE: This memory policy does not require any additional allocations or memory transfers.\n It corrupts the data in the \\c cuestDFIntPlan_t during the gradient calculation. However, following the gradient call, it returns the\n \\c cuestDFIntPlan_t to a usable state by recomputing (and replacing) any corrupted data. This may add significantly to the cost of the\n gradient evaluation.\n\n Note that variableBufferSize only applies to the formation of certain intermediates during the cuestDFSymmetricDerivativeCompute and will not\n limit overall memory usage. We recommend a buffer size of at least 2 GB with modest performance improvements possible if larger buffers can be provided.\n"]
1143pub unsafe fn cuestDFSymmetricDerivativeCompute(
1144 handle: cuestHandle_t,
1145 plan: cuestDFIntPlan_t,
1146 parameters: cuestDFSymmetricDerivativeComputeParameters_t,
1147 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1148 temporaryWorkspace: *mut cuestWorkspace_t,
1149 densityScale: f64,
1150 densityMatrix: *const f64,
1151 coefficientScale: f64,
1152 numCoefficientMatrices: u64,
1153 numOccupied: *const u64,
1154 coefficientMatrices: *const f64,
1155 outGradient: *mut f64,
1156) -> cuestStatus_t {
1157 dyload_lib().cuestDFSymmetricDerivativeCompute.expect(
1158 "cuEST function `cuestDFSymmetricDerivativeCompute` not found in the loaded library",
1159 )(
1160 handle,
1161 plan,
1162 parameters,
1163 variableBufferSize,
1164 temporaryWorkspace,
1165 densityScale,
1166 densityMatrix,
1167 coefficientScale,
1168 numCoefficientMatrices,
1169 numOccupied,
1170 coefficientMatrices,
1171 outGradient,
1172 )
1173}
1174
1175#[doc = " @brief Query the temporary workspace required for a DF J/K nuclear gradient computation.\n @ingroup JKGrad\n\n This function determines the workspace required for a symmetric DF J/K gradient\n evaluation with the given plan, density matrix, coefficient matrices, and maximum\n workspace constraint. The output descriptor is filled on success and can be used\n to allocate host and device workspace buffers prior to calling\n \\c cuestDFSymmetricDerivativeCompute.\n\n Some input pointers (\\c densityMatrix, \\c coefficientMatrices, \\c outGradient) are optional\n and may be NULL.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_DFSYMMETRICDERIVATIVECOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_DFSYMMETRICDERIVATIVECOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is expected to provide\n a performance advantage on the present GPU architecture.\n - ffloat compute is only compatible with JIT-compiled kernels. Requesting ffloat compute while JIT is\n disabled (\\c CUEST_FFLOAT_USAGE_MODE_ON together with \\c CUEST_JIT_USAGE_MODE_OFF) is not supported and\n returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan DF integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestDFSymmetricDerivativeComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize The variableBufferSize determines the size of an internal scratch buffer\n used for certain transformations. A buffer of 2GB is a reasonable default value.\n Host memory is currently unused. Note that the variableBufferSize does not limit total\n memory usage. The value of the variableBufferSize must not change between WorkspaceQuery\n and Compute calls.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for required temporary workspace\n sizes (host and device). Must not be NULL.\n @param[in] densityScale Scaling factor for the J (Coulomb) contribution.\n @param densityMatrix Optional density matrix. May be NULL.\n @param[in] coefficientScale Scaling factor for each K (exchange) contribution.\n @param[in] numCoefficientMatrices Number of coefficient matrices. Must be > 0 when exchange is active; may be 0 for pure functionals.\n @param[in] numOccupied Array of occupied orbital counts for each\n coefficient matrix (size: \\c numCoefficientMatrices) on CPU.\n Each entry must be > 0 when exchange is active; for pure functionals the array may be NULL or contain zeros.\n @param coefficientMatrices Optional concatenated coefficient matrices. May be NULL.\n @param outGradient Optional output gradient buffer. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_PLAN if the \\c cuestDFIntPlan_t is not correctly configured or in a dirty state;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c coefficientScale != 0.0 and\n if \\c numCoefficientMatrices == 0 or any \\c numOccupied[i] == 0;\n or if \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION or \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION\n != 0.0 and\n if \\c numCoefficientMatrices == 0 or any \\c numOccupied[i] == 0;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package, or if ffloat compute is requested while JIT is disabled (incompatible\n JIT/ffloat combination);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1176pub unsafe fn cuestDFSymmetricDerivativeComputeWorkspaceQuery(
1177 handle: cuestHandle_t,
1178 plan: cuestDFIntPlan_t,
1179 parameters: cuestDFSymmetricDerivativeComputeParameters_t,
1180 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1181 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1182 densityScale: f64,
1183 densityMatrix: *const f64,
1184 coefficientScale: f64,
1185 numCoefficientMatrices: u64,
1186 numOccupied: *const u64,
1187 coefficientMatrices: *const f64,
1188 outGradient: *mut f64,
1189) -> cuestStatus_t {
1190 dyload_lib().cuestDFSymmetricDerivativeComputeWorkspaceQuery.expect("cuEST function `cuestDFSymmetricDerivativeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, variableBufferSize, temporaryWorkspaceDescriptor, densityScale, densityMatrix, coefficientScale, numCoefficientMatrices, numOccupied, coefficientMatrices, outGradient)
1191}
1192
1193#[doc = " @brief Transforms the 3-index density fitting tensor from the AO basis to the MO basis.\n @ingroup DFMOIntegrals\n @since v0.2.0\n\n This routine transforms three-index AO integrals into the MO basis within the density\n fitting representation. Pairs of coefficient matrices are taken as input.\n\n Starting from a density-fitted representation of the AO integrals:\n\n \\f[\n \\left[ f_{\\rm HF} (\\mu\\nu|\\frac{1}{r}|\\lambda\\sigma) + f_{\\rm LRC} (\\mu\\nu|\\frac{{\\rm erf}(\\omega r)}{r}|\\lambda\\sigma) \\right]\n = \\sum_{A} B^{A}_{\\mu\\nu} B^{A}_{\\lambda\\sigma}\n \\f]\n\n This function performs the transformation:\n\n \\f[ B^{A}_{ia} = \\sum_{\\mu\\nu} B^{A}_{\\mu\\nu} C(L)_{i\\mu} C(R)_{a\\nu} \\f]\n\n The resulting tensors can be used to directly construct 4-index MO integrals by contracting over the auxiliary index.\n\n \\f[\n \\left[ f_{\\rm HF} (ia|\\frac{1}{r}|jb) + f_{\\rm LRC} (ia|\\frac{{\\rm erf}(\\omega r)}{r}|jb) \\right]\n = \\sum_{A} B^{A}_{ia} B^{A}_{jb}\n \\f]\n\n The transformation is most efficient when the MO dimension of C(L) is\n smaller than the MO dimension of C(R), as C(L) is applied first. The\n resulting tensor is transformed by the fitting metric.\n\n Multiple MO integral tensors can be evaluated in a single function call.\n The resulting MO integral tensors respect the values of\n \\c CUEST_DFINTPLAN_PARAMETERS_EXCHANGE_FRACTION,\n \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_FRACTION, and\n \\c CUEST_DFINTPLAN_PARAMETERS_LRC_EXCHANGE_OMEGA set in the \\c cuestDFIntPlan_t.\n\n This function supports the use of a \\c cuestDFIntPlan_t constructed with the\n CUEST_DFINTPLAN_PARAMETERS_THREE_INDEX_INTEGRAL_DIRECT parameter set to either\n 0 or 1.\n\n All required temporary workspace must be sized using the corresponding workspace\n query function. A \\c variableBufferSize descriptor must also be provided to\n constrain the memory usage.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan DF integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestDFMOIntegralsComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize The variableBufferSize determines the size of an internal scratch buffer\n used for certain transformations. A buffer of 2GB is a reasonable default value.\n Host memory is currently unused. Note that the variableBufferSize does not limit total\n memory usage. The value of the variableBufferSize must not change between WorkspaceQuery\n and Compute calls.\n @param[in] temporaryWorkspace Temporary workspace buffers (preallocated for\n this operation using the query function).\n Must not be NULL.\n @param[in] numCoefficientMatrices Number of pairs of coefficient matrices. Must be > 0.\n @param[in] numLeftOrbitals Array of molecular orbital counts for each left\n coefficient matrix (size: \\c numCoefficientMatrices) on CPU.\n Each entry must be > 0. Must not be NULL.\n @param[in] numRightOrbitals Array of molecular orbital counts for each right\n coefficient matrix (size: \\c numCoefficientMatrices) on CPU.\n Each entry must be > 0. Must not be NULL.\n @param[in] leftCoefficientMatrices Concatenated left coefficient matrices. Each matrix\n has shape [\\c numLeftOrbitals[i], nao] on GPU. Total size:\n sum(\\c numLeftOrbitals[i]) × nao. Must not be NULL.\n @param[in] rightCoefficientMatrices Concatenated right coefficient matrices. Each matrix\n has shape [\\c numRightOrbitals[i], nao] on GPU. Total size:\n sum(\\c numRightOrbitals[i]) × nao. Must not be NULL.\n @param[out] outTensors Output concatenated MO integral tensors. Each tensor has shape\n [naux, \\c numLeftOrbitals[i], \\c numRightOrbitals[i]] on GPU.\n Total size: naux × sum(\\c numRightOrbitals[i] × \\c numLeftOrbitals[i]).\n Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_PLAN if the \\c cuestDFIntPlan_t is not correctly configured or in a dirty state;\n - \\c CUEST_STATUS_INVALID_ARGUMENT\n if \\c numCoefficientMatrices == 0,\n or any \\c numLeftOrbitals[i] == 0,\n or any \\c numRightOrbitals[i] == 0;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise.\n"]
1194pub unsafe fn cuestDFMOIntegralsCompute(
1195 handle: cuestHandle_t,
1196 plan: cuestDFIntPlan_t,
1197 parameters: cuestDFMOIntegralsComputeParameters_t,
1198 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1199 temporaryWorkspace: *mut cuestWorkspace_t,
1200 numCoefficientMatrices: u64,
1201 numLeftOrbitals: *const u64,
1202 numRightOrbitals: *const u64,
1203 leftCoefficientMatrices: *const f64,
1204 rightCoefficientMatrices: *const f64,
1205 outTensors: *mut f64,
1206) -> cuestStatus_t {
1207 dyload_lib()
1208 .cuestDFMOIntegralsCompute
1209 .expect("cuEST function `cuestDFMOIntegralsCompute` not found in the loaded library")(
1210 handle,
1211 plan,
1212 parameters,
1213 variableBufferSize,
1214 temporaryWorkspace,
1215 numCoefficientMatrices,
1216 numLeftOrbitals,
1217 numRightOrbitals,
1218 leftCoefficientMatrices,
1219 rightCoefficientMatrices,
1220 outTensors,
1221 )
1222}
1223
1224#[doc = " @brief Query the temporary workspace required to transform the 3-index density\n fitting tensor from the AO basis to the MO basis.\n @ingroup DFMOIntegrals\n @since v0.2.0\n\n This function determines the workspace required to perform an AO to MO transform\n of the DF 3-index tensor with the given plan, coefficient matrices, and maximum\n workspace constraint. The output descriptor is filled on success and can be used\n to allocate host and device workspace buffers prior to calling\n \\c cuestDFMOIntegralsCompute.\n\n Some input pointers (\\c coefficientMatrices and \\c outTensors) are optional\n and may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan DF integral computation plan (opaque handle). Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestDFMOIntegralsComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize The variableBufferSize determines the size of an internal scratch buffer\n used for certain transformations. A buffer of 2GB is a reasonable default value.\n Host memory is currently unused. Note that the variableBufferSize does not limit total\n memory usage. The value of the variableBufferSize must not change between WorkspaceQuery\n and Compute calls.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for required temporary workspace\n sizes (host and device). Must not be NULL.\n @param[in] numCoefficientMatrices Number of pairs of coefficient matrices. Must be > 0.\n @param[in] numLeftOrbitals Array of molecular orbital counts for each left\n coefficient matrix (size: \\c numCoefficientMatrices) on CPU.\n Each entry must be > 0. Must not be NULL.\n @param[in] numRightOrbitals Array of molecular orbital counts for each right\n coefficient matrix (size: \\c numCoefficientMatrices) on CPU.\n Each entry must be > 0. Must not be NULL.\n @param leftCoefficientMatrices Concatenated left coefficient matrices. Each matrix\n has shape [\\c numLeftOrbitals[i], nao] on GPU. Total size:\n sum(\\c numLeftOrbitals[i]) × nao. May be NULL.\n @param rightCoefficientMatrices Concatenated right coefficient matrices. Each matrix\n has shape [\\c numRightOrbitals[i], nao] on GPU. Total size:\n sum(\\c numRightOrbitals[i]) × nao. May be NULL.\n @param outTensors Output concatenated MO integral tensors. Each tensor has shape\n [naux, \\c numLeftOrbitals[i], \\c numRightOrbitals[i]] on GPU.\n Total size: naux × sum(\\c numRightOrbitals[i] × \\c numLeftOrbitals[i]).\n May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_PLAN if the \\c cuestDFIntPlan_t is not correctly configured or in a dirty state;\n - \\c CUEST_STATUS_INVALID_ARGUMENT\n if \\c numCoefficientMatrices == 0,\n or any \\c numLeftOrbitals[i] == 0,\n or any \\c numRightOrbitals[i] == 0;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1225pub unsafe fn cuestDFMOIntegralsComputeWorkspaceQuery(
1226 handle: cuestHandle_t,
1227 plan: cuestDFIntPlan_t,
1228 parameters: cuestDFMOIntegralsComputeParameters_t,
1229 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1230 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1231 numCoefficientMatrices: u64,
1232 numLeftOrbitals: *const u64,
1233 numRightOrbitals: *const u64,
1234 leftCoefficientMatrices: *const f64,
1235 rightCoefficientMatrices: *const f64,
1236 outTensors: *mut f64,
1237) -> cuestStatus_t {
1238 dyload_lib().cuestDFMOIntegralsComputeWorkspaceQuery.expect(
1239 "cuEST function `cuestDFMOIntegralsComputeWorkspaceQuery` not found in the loaded library",
1240 )(
1241 handle,
1242 plan,
1243 parameters,
1244 variableBufferSize,
1245 temporaryWorkspaceDescriptor,
1246 numCoefficientMatrices,
1247 numLeftOrbitals,
1248 numRightOrbitals,
1249 leftCoefficientMatrices,
1250 rightCoefficientMatrices,
1251 outTensors,
1252 )
1253}
1254
1255#[doc = " @brief Create an atom grid object with specified parameters.\n @ingroup Grid\n\n @note The \\c radialWeights positivity and \\c numAngularPoints Lebedev-number requirements are not\n validated by this function; they are enforced when this atom grid is used to construct a\n \\c cuestMolecularGrid_t, where a violation is reported as \\c CUEST_STATUS_EXCEPTION.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] numRadialPoints Number of radial points. Must be greater than zero.\n @param[in] radialNodes Location of radial nodes from the atom center (size: \\c numRadialPoints) on the CPU. Must not be NULL.\n @param[in] radialWeights Pointer to array containing quadrature weights of a radial point (size: \\c numRadialPoints) on the CPU. Elements must be positive semidefinite. Must not be NULL.\n @param[in] numAngularPoints Pointer to array containing number of angular points associated with a radial point (size: \\c numRadialPoints) on the CPU. Values must be Lebedev numbers. Must not be NULL.\n @param[in] parameters Handle to \\c cuestAtomGridParameters_t. Must not be NULL.\n @param[out] outAtomGrid Pointer to output atom grid object; receives opaque handle on success. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the cuEST handle or parameters are not of the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numRadialPoints is zero;\n - \\c CUEST_STATUS_EXCEPTION for unexpected error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR for non-std exceptions."]
1256pub unsafe fn cuestAtomGridCreate(
1257 handle: cuestHandle_t,
1258 numRadialPoints: u64,
1259 radialNodes: *const f64,
1260 radialWeights: *const f64,
1261 numAngularPoints: *const u64,
1262 parameters: cuestAtomGridParameters_t,
1263 outAtomGrid: *mut cuestAtomGrid_t,
1264) -> cuestStatus_t {
1265 dyload_lib()
1266 .cuestAtomGridCreate
1267 .expect("cuEST function `cuestAtomGridCreate` not found in the loaded library")(
1268 handle,
1269 numRadialPoints,
1270 radialNodes,
1271 radialWeights,
1272 numAngularPoints,
1273 parameters,
1274 outAtomGrid,
1275 )
1276}
1277
1278#[doc = " @brief Destroy/free an atom grid object created with \\c cuestAtomGridCreate.\n @ingroup Grid\n\n Frees all memory associated with the atom grid. After destruction, the grid handle must not be used.\n\n @param[in] atomGrid Opaque atom grid handle to destroy. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c atomGrid is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if \\c atomGrid is not of type \\c cuestAtomGrid_t;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on error."]
1279pub unsafe fn cuestAtomGridDestroy(atomGrid: cuestAtomGrid_t) -> cuestStatus_t {
1280 dyload_lib()
1281 .cuestAtomGridDestroy
1282 .expect("cuEST function `cuestAtomGridDestroy` not found in the loaded library")(
1283 atomGrid
1284 )
1285}
1286
1287#[doc = " @brief Create a molecular grid object.\n @ingroup Grid\n\n The molecular grid comprises multiple atom grids each at an atom center.\n - All buffer pointers must be valid (not NULL).\n - Each atom grid, and each array entry, must be valid.\n - The persistent and temporary workspaces must be provided and preallocated.\n - The output handle is only valid after successful creation.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] numAtoms Total number of atoms; must be greater than zero.\n @param[in] atomGrid Array of atom grid handles (size: \\c numAtoms). CPU array, must not be NULL and no elements of the array may be NULL.\n @param[in] xyz Array of atomic Cartesian coordinates (size: \\c numAtoms * 3) on the CPU. Ordering of elements is row-major: \\f$ [x_0, y_0, z_0, ...] \\f$. Must not be NULL.\n @param[in] parameters Handle to \\c cuestMolecularGridParameters_t. Must not be NULL.\n @param[in] persistentWorkspace Pointer to preallocated workspace for persistent buffers. Must not be NULL.\n @param[in] temporaryWorkspace Pointer to preallocated workspace for temporary buffers. Must not be NULL.\n @param[out] outGrid Pointer for output molecular grid. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any pointer parameter is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the cuEST handle, parameters or atom grids are not of the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numAtoms is zero;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on error."]
1288pub unsafe fn cuestMolecularGridCreate(
1289 handle: cuestHandle_t,
1290 numAtoms: u64,
1291 atomGrid: *const cuestAtomGrid_t,
1292 xyz: *const f64,
1293 parameters: cuestMolecularGridParameters_t,
1294 persistentWorkspace: *mut cuestWorkspace_t,
1295 temporaryWorkspace: *mut cuestWorkspace_t,
1296 outGrid: *mut cuestMolecularGrid_t,
1297) -> cuestStatus_t {
1298 dyload_lib()
1299 .cuestMolecularGridCreate
1300 .expect("cuEST function `cuestMolecularGridCreate` not found in the loaded library")(
1301 handle,
1302 numAtoms,
1303 atomGrid,
1304 xyz,
1305 parameters,
1306 persistentWorkspace,
1307 temporaryWorkspace,
1308 outGrid,
1309 )
1310}
1311
1312#[doc = " @brief Query workspace requirements for creating a molecular grid object.\n @ingroup Grid\n\n This function simulates the allocation logic to determine necessary persistent and temporary buffer sizes.\n All buffer pointers and arrays must be valid.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] numAtoms Total number of atoms; must be greater than zero.\n @param[in] atomGrid Flat array of atom grid handles (size: \\c numAtoms). CPU array, must not be NULL and no elements of the array may be NULL.\n @param[in] xyz Array of atomic Cartesian coordinates (size: \\c numAtoms * 3) on the CPU. Ordering of elements is row-major: \\f$ [x_0, y_0, z_0, ...] \\f$. Must not be NULL.\n @param[in] parameters Handle to \\c cuestMolecularGridParameters_t. Must not be NULL.\n @param[out] persistentWorkspaceDescriptor Output descriptor for persistent buffer sizing. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary buffer sizing. Must not be NULL.\n @param outGrid Pointer for output molecular grid. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the cuEST handle, parameters or atom grids are not of the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numAtoms is zero;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR for other errors."]
1313pub unsafe fn cuestMolecularGridCreateWorkspaceQuery(
1314 handle: cuestHandle_t,
1315 numAtoms: u64,
1316 atomGrid: *const cuestAtomGrid_t,
1317 xyz: *const f64,
1318 parameters: cuestMolecularGridParameters_t,
1319 persistentWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1320 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1321 outGrid: *mut cuestMolecularGrid_t,
1322) -> cuestStatus_t {
1323 dyload_lib().cuestMolecularGridCreateWorkspaceQuery.expect(
1324 "cuEST function `cuestMolecularGridCreateWorkspaceQuery` not found in the loaded library",
1325 )(
1326 handle,
1327 numAtoms,
1328 atomGrid,
1329 xyz,
1330 parameters,
1331 persistentWorkspaceDescriptor,
1332 temporaryWorkspaceDescriptor,
1333 outGrid,
1334 )
1335}
1336
1337#[doc = " @brief Destroy/free a molecular grid object and all associated resources.\n @ingroup Grid\n\n After this function is called, the grid handle must not be used.\n\n @param[in] grid Molecular grid handle to destroy; must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c grid is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if \\c grid is not of type \\c cuestMolecularGrid_t;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR on error."]
1338pub unsafe fn cuestMolecularGridDestroy(grid: cuestMolecularGrid_t) -> cuestStatus_t {
1339 dyload_lib()
1340 .cuestMolecularGridDestroy
1341 .expect("cuEST function `cuestMolecularGridDestroy` not found in the loaded library")(
1342 grid
1343 )
1344}
1345
1346#[doc = " @brief Build a plan for exchange-correlation integral evaluation.\n @ingroup XCIntegralPlan\n\n All object handles, workspaces, and output pointers must be valid (not NULL).\n Workspace buffers must be preallocated with required sizes (see workspace query).\n\n \\verbatim embed:rst\n.. Note::\n- The number of atoms in the \\c basis must match the number of atoms in the \\c grid.\n\\endverbatim\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] basis AO basis set handle. Must not be NULL.\n @param[in] grid Molecular grid handle. Must not be NULL.\n @param[in] functional Specifies the XC functional.\n @param[in] parameters Plan parameter structure. Must not be NULL.\n @param[in] persistentWorkspace Preallocated workspace for persistent buffers. Must not be NULL.\n @param[in] temporaryWorkspace Preallocated workspace for temporary buffers. Must not be NULL.\n @param[out] outPlan Output pointer for the XC integral plan handle. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any pointer argument is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c functional does not exist;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1347pub unsafe fn cuestXCIntPlanCreate(
1348 handle: cuestHandle_t,
1349 basis: cuestAOBasis_t,
1350 grid: cuestMolecularGrid_t,
1351 functional: cuestXCIntPlanParametersFunctional_t,
1352 parameters: cuestXCIntPlanParameters_t,
1353 persistentWorkspace: *mut cuestWorkspace_t,
1354 temporaryWorkspace: *mut cuestWorkspace_t,
1355 outPlan: *mut cuestXCIntPlan_t,
1356) -> cuestStatus_t {
1357 dyload_lib()
1358 .cuestXCIntPlanCreate
1359 .expect("cuEST function `cuestXCIntPlanCreate` not found in the loaded library")(
1360 handle,
1361 basis,
1362 grid,
1363 functional,
1364 parameters,
1365 persistentWorkspace,
1366 temporaryWorkspace,
1367 outPlan,
1368 )
1369}
1370
1371#[doc = " @brief Query workspace requirements for creating an exchange-correlation integral plan.\n @ingroup XCIntegralPlan\n\n Determines persistent and temporary buffer sizes by simulating allocation logic.\n All handles and pointers must be valid (not NULL).\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] basis AO basis set handle. Must not be NULL.\n @param[in] grid Molecular grid handle. Must not be NULL.\n @param[in] functional Specifies the XC functional.\n @param[in] parameters Plan parameters handle. Must not be NULL.\n @param[out] persistentWorkspaceDescriptor Output descriptor for persistent buffer sizing. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary buffer sizing. Must not be NULL.\n @param outPlan Output pointer for the XC integral plan handle. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer argument is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c functional does not exist;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1372pub unsafe fn cuestXCIntPlanCreateWorkspaceQuery(
1373 handle: cuestHandle_t,
1374 basis: cuestAOBasis_t,
1375 grid: cuestMolecularGrid_t,
1376 functional: cuestXCIntPlanParametersFunctional_t,
1377 parameters: cuestXCIntPlanParameters_t,
1378 persistentWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1379 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1380 outPlan: *mut cuestXCIntPlan_t,
1381) -> cuestStatus_t {
1382 dyload_lib().cuestXCIntPlanCreateWorkspaceQuery.expect(
1383 "cuEST function `cuestXCIntPlanCreateWorkspaceQuery` not found in the loaded library",
1384 )(
1385 handle,
1386 basis,
1387 grid,
1388 functional,
1389 parameters,
1390 persistentWorkspaceDescriptor,
1391 temporaryWorkspaceDescriptor,
1392 outPlan,
1393 )
1394}
1395
1396#[doc = " @brief Destroy and release an exchange-correlation integral plan and its resources.\n @ingroup XCIntegralPlan\n\n The plan handle and its memory must not be used after destruction.\n\n @param[in] plan Plan handle to destroy. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c plan is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1397pub unsafe fn cuestXCIntPlanDestroy(plan: cuestXCIntPlan_t) -> cuestStatus_t {
1398 dyload_lib()
1399 .cuestXCIntPlanDestroy
1400 .expect("cuEST function `cuestXCIntPlanDestroy` not found in the loaded library")(plan)
1401}
1402
1403#[doc = " @brief Compute molecular integration grid point coordinates.\n @ingroup ExchangeCorrelationAdvanced\n\n This routine retrieves the Cartesian coordinates of each molecular grid point\n used for exchange–correlation (XC) integration. These are the grid points used\n by the corresponding XC integral plan.\n\n The resulting coordinates are written to a user-provided output buffer\n of shape (\\c npoint × 3), containing the x, y, z coordinates of each grid point.\n\n Temporary device workspace must be preallocated based on the size returned by\n \\c cuestXCIntegrationGridComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestXCIntegrationGridComputeParameters_t) Must not be NULL\n @param[in] temporaryWorkspace Preallocated GPU workspace buffer. Must not be NULL.\n @param[out] outGridPoints Output buffer for computed grid point coordinates (size: \\c npoint × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the handle or plan type is incorrect;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1404pub unsafe fn cuestXCIntegrationGridCompute(
1405 handle: cuestHandle_t,
1406 plan: cuestXCIntPlan_t,
1407 parameters: cuestXCIntegrationGridComputeParameters_t,
1408 temporaryWorkspace: *mut cuestWorkspace_t,
1409 outGridPoints: *mut f64,
1410) -> cuestStatus_t {
1411 dyload_lib()
1412 .cuestXCIntegrationGridCompute
1413 .expect("cuEST function `cuestXCIntegrationGridCompute` not found in the loaded library")(
1414 handle,
1415 plan,
1416 parameters,
1417 temporaryWorkspace,
1418 outGridPoints,
1419 )
1420}
1421
1422#[doc = " @brief Query temporary workspace requirements for grid coordinate computation.\n @ingroup ExchangeCorrelationAdvanced\n\n Determines the GPU memory workspace needed to generate the coordinates\n of molecular integration grid points defined by the provided XC integral plan.\n This function must be called before \\c cuestXCIntegrationGridCompute to ensure sufficient allocation.\n\n Only workspace sizes are computed; input and output pointers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestXCIntegrationGridComputeParameters_t) Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for required workspace sizes (in bytes). Must not be NULL.\n @param outGridPoints Output array for grid point coordinates. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if handles are of incorrect type;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1423pub unsafe fn cuestXCIntegrationGridComputeWorkspaceQuery(
1424 handle: cuestHandle_t,
1425 plan: cuestXCIntPlan_t,
1426 parameters: cuestXCIntegrationGridComputeParameters_t,
1427 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1428 outGridPoints: *mut f64,
1429) -> cuestStatus_t {
1430 dyload_lib().cuestXCIntegrationGridComputeWorkspaceQuery.expect("cuEST function `cuestXCIntegrationGridComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, outGridPoints)
1431}
1432
1433#[doc = " @brief Compute molecular integration weights for XC quadrature.\n @ingroup ExchangeCorrelationAdvanced\n\n This routine computes the integration weights associated with each grid point\n in the molecular integration grid used for exchange–correlation (XC) integration.\n The weights returned depend on the selected weight type, specified by \\c weightType.\n\n Supported weight types include:\n - \\c CUEST_XCINTEGRATIONWEIGHT_PARAMETERS_WEIGHTTYPE_TOTAL — total integration weight (angular x radial x Becke);\n - \\c CUEST_XCINTEGRATIONWEIGHT_PARAMETERS_WEIGHTTYPE_BECKE — Becke atomic partition weights;\n - \\c CUEST_XCINTEGRATIONWEIGHT_PARAMETERS_WEIGHTTYPE_QUADRATURE — quadrature-only weights (angular x radial).\n\n The result is written to \\c outGridWeights (size: \\c npoint × 1).\n Temporary workspace must be preallocated based on\n \\c cuestXCIntegrationWeightComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] weightType Weight type to return (total, Becke, quadrature).\n @param[in] parameters Compute parameters (\\c cuestXCIntegrationWeightComputeParameters_t) Must not be NULL\n @param[in] temporaryWorkspace Preallocated GPU workspace buffer for temporary data. Must not be NULL.\n @param[out] outGridWeights Output buffer for integration weights (size: \\c npoint × 1) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the handle or plan type is invalid;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c weightType is unrecognized;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1434pub unsafe fn cuestXCIntegrationWeightCompute(
1435 handle: cuestHandle_t,
1436 plan: cuestXCIntPlan_t,
1437 weightType: cuestXCIntegrationWeightComputeParametersWeightType_t,
1438 parameters: cuestXCIntegrationWeightComputeParameters_t,
1439 temporaryWorkspace: *mut cuestWorkspace_t,
1440 outGridWeights: *mut f64,
1441) -> cuestStatus_t {
1442 dyload_lib()
1443 .cuestXCIntegrationWeightCompute
1444 .expect("cuEST function `cuestXCIntegrationWeightCompute` not found in the loaded library")(
1445 handle,
1446 plan,
1447 weightType,
1448 parameters,
1449 temporaryWorkspace,
1450 outGridWeights,
1451 )
1452}
1453
1454#[doc = " @brief Query the temporary workspace required (in bytes) for computing XC integration weights.\n @ingroup ExchangeCorrelationAdvanced\n\n Determines GPU memory workspace requirements to compute integration weights\n on the molecular grid as defined by the provided XC integral plan. The required\n workspace depends on the grid structure and selected weight type.\n\n This query should be executed before calling \\c cuestXCIntegrationWeightCompute\n to ensure that sufficient device memory is available.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] weightType Weight type to return (total, Becke, quadrature).\n @param[in] parameters Compute parameters (\\c cuestXCIntegrationWeightComputeParameters_t) Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for required temporary workspace sizes (in bytes). Must not be NULL.\n @param outGridWeights Optional output buffer for computed weights. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the handle or plan type is incorrect;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c weightType is unsupported;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1455pub unsafe fn cuestXCIntegrationWeightComputeWorkspaceQuery(
1456 handle: cuestHandle_t,
1457 plan: cuestXCIntPlan_t,
1458 weightType: cuestXCIntegrationWeightComputeParametersWeightType_t,
1459 parameters: cuestXCIntegrationWeightComputeParameters_t,
1460 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1461 outGridWeights: *mut f64,
1462) -> cuestStatus_t {
1463 dyload_lib().cuestXCIntegrationWeightComputeWorkspaceQuery.expect("cuEST function `cuestXCIntegrationWeightComputeWorkspaceQuery` not found in the loaded library")(handle, plan, weightType, parameters, temporaryWorkspaceDescriptor, outGridWeights)
1464}
1465
1466#[doc = " @brief Compute the RKS XC potential (Vxc) matrix using the supplied XC integral plan and occupied molecular orbitals.\n @ingroup ExchangeCorrelation\n\n This routine computes the XC potential matrix (Vxc) from occupied molecular orbitals.\n This is the RKS interface that assumes the alpha and beta spin orbitals are identical. The user must\n provide occupied molecular orbitals (size nocc x nao) and a preallocated output buffer (size nao × nao).\n The orbital basis and integration grid used are passed via the \\c plan. All required temporary workspace\n must be allocated using the size returned by \\c cuestXCPotentialRKSComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n The cuestXCIntPlanParametersFunctional_t set during plan construction determines what XC potential is evaluated.\n @param[in] parameters Compute parameters (\\c cuestXCPotentialRKSComputeParameters_t) Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param[in] coefficientMatrix Input coefficient matrix (size: \\c numOccupied × nao) on the GPU. Must not be NULL.\n @param[out] outXCEnergy Output (double) for the computed XC energy (size: 1) on the CPU. Must not be NULL.\n This element is overwritten by the calculation results.\n @param[out] outXCPotentialMatrix Output buffer for computed XC potential matrix (size: nao × nao) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero;\n - \\c CUEST_STATUS_EXCEPTION if \\c cuestXCIntPlanParametersFunctional_t is \\c CUEST_XCINTPLAN_PARAMETERS_FUNCTIONAL_HF (set in the \\c cuestXCIntPlan_t);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1467pub unsafe fn cuestXCPotentialRKSCompute(
1468 handle: cuestHandle_t,
1469 plan: cuestXCIntPlan_t,
1470 parameters: cuestXCPotentialRKSComputeParameters_t,
1471 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1472 temporaryWorkspace: *mut cuestWorkspace_t,
1473 numOccupied: u64,
1474 coefficientMatrix: *const f64,
1475 outXCEnergy: *mut f64,
1476 outXCPotentialMatrix: *mut f64,
1477) -> cuestStatus_t {
1478 dyload_lib()
1479 .cuestXCPotentialRKSCompute
1480 .expect("cuEST function `cuestXCPotentialRKSCompute` not found in the loaded library")(
1481 handle,
1482 plan,
1483 parameters,
1484 variableBufferSize,
1485 temporaryWorkspace,
1486 numOccupied,
1487 coefficientMatrix,
1488 outXCEnergy,
1489 outXCPotentialMatrix,
1490 )
1491}
1492
1493#[doc = " @brief Query the temporary workspace required (in bytes) for an XC potential matrix computation.\n @ingroup ExchangeCorrelation\n\n This function returns the workspace needed (host/device) for a single computation,\n based on the provided plan and pair list. Only sizes are computed; output and orbital\n buffers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestXCPotentialRKSComputeParameters_t) Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param coefficientMatrix Input coefficient matrix. May be NULL.\n @param outXCEnergy Output (double) for the computed XC energy. May be NULL.\n @param outXCPotentialMatrix Output buffer for computed XC potential matrix. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero;\n - \\c CUEST_STATUS_EXCEPTION if \\c cuestXCIntPlanParametersFunctional_t is \\c CUEST_XCINTPLAN_PARAMETERS_FUNCTIONAL_HF (set in the \\c cuestXCIntPlan_t);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1494pub unsafe fn cuestXCPotentialRKSComputeWorkspaceQuery(
1495 handle: cuestHandle_t,
1496 plan: cuestXCIntPlan_t,
1497 parameters: cuestXCPotentialRKSComputeParameters_t,
1498 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1499 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1500 numOccupied: u64,
1501 coefficientMatrix: *const f64,
1502 outXCEnergy: *mut f64,
1503 outXCPotentialMatrix: *mut f64,
1504) -> cuestStatus_t {
1505 dyload_lib().cuestXCPotentialRKSComputeWorkspaceQuery.expect(
1506 "cuEST function `cuestXCPotentialRKSComputeWorkspaceQuery` not found in the loaded library",
1507 )(
1508 handle,
1509 plan,
1510 parameters,
1511 variableBufferSize,
1512 temporaryWorkspaceDescriptor,
1513 numOccupied,
1514 coefficientMatrix,
1515 outXCEnergy,
1516 outXCPotentialMatrix,
1517 )
1518}
1519
1520#[doc = " @brief Compute the UKS XC potential (Vxc) matrix using the supplied XC integral plan and occupied molecular orbitals.\n @ingroup ExchangeCorrelation\n\n This routine computes the UKS XC potential matrices (Vxc) from occupied molecular orbitals.\n This is the UKS interface that allows the alpha and beta spin orbitals to be different. The user must\n provide occupied molecular orbitals (size nocc x nao) and preallocated output buffers (size nao × nao).\n The orbital basis and integration grid used are passed via the \\c plan. All required temporary workspace\n must be allocated using the size returned by \\c cuestXCPotentialUKSComputeWorkspaceQuery.\n\n Alpha and beta coefficient matrices must always be provided with non-zero numbers of occupied orbitals.\n Cases without beta (or alpha) electrons (hydrogen atom, for example), can be handled by passing in a\n coefficient matrix containing only zeros.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n The \\c cuestXCIntPlanParametersFunctional_t set during plan construction determines what XC potential is evaluated.\n @param[in] parameters Compute parameters (\\c cuestXCPotentialUKSComputeParameters_t) Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupiedAlpha Number of alpha occupied orbitals (rows in alpha coefficient matrix); must be greater than zero.\n @param[in] numOccupiedBeta Number of beta occupied orbitals (rows in beta coefficient matrix); must be greater than zero.\n @param[in] coefficientMatrixAlpha Input alpha coefficient matrix (size: \\c numOccupiedAlpha × nao). Must not be NULL.\n @param[in] coefficientMatrixBeta Input beta coefficient matrix (size: \\c numOccupiedBeta × nao). Must not be NULL.\n @param[out] outXCEnergy Output (double) for the computed XC energy (size: 1) on the CPU. Must not be NULL.\n @param[out] outXCPotentialMatrixAlpha Output buffer for computed XC potential matrix (size: nao × nao) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n @param[out] outXCPotentialMatrixBeta Output buffer for computed XC potential matrix (size: nao × nao) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupiedAlpha or \\c numOccupiedBeta is zero;\n - \\c CUEST_STATUS_EXCEPTION if \\c cuestXCIntPlanParametersFunctional_t is \\c CUEST_XCINTPLAN_PARAMETERS_FUNCTIONAL_HF (set in the \\c cuestXCIntPlan_t);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1521pub unsafe fn cuestXCPotentialUKSCompute(
1522 handle: cuestHandle_t,
1523 plan: cuestXCIntPlan_t,
1524 parameters: cuestXCPotentialUKSComputeParameters_t,
1525 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1526 temporaryWorkspace: *mut cuestWorkspace_t,
1527 numOccupiedAlpha: u64,
1528 numOccupiedBeta: u64,
1529 coefficientMatrixAlpha: *const f64,
1530 coefficientMatrixBeta: *const f64,
1531 outXCEnergy: *mut f64,
1532 outXCPotentialMatrixAlpha: *mut f64,
1533 outXCPotentialMatrixBeta: *mut f64,
1534) -> cuestStatus_t {
1535 dyload_lib()
1536 .cuestXCPotentialUKSCompute
1537 .expect("cuEST function `cuestXCPotentialUKSCompute` not found in the loaded library")(
1538 handle,
1539 plan,
1540 parameters,
1541 variableBufferSize,
1542 temporaryWorkspace,
1543 numOccupiedAlpha,
1544 numOccupiedBeta,
1545 coefficientMatrixAlpha,
1546 coefficientMatrixBeta,
1547 outXCEnergy,
1548 outXCPotentialMatrixAlpha,
1549 outXCPotentialMatrixBeta,
1550 )
1551}
1552
1553#[doc = " @brief Query the temporary workspace required (in bytes) for an XC potential matrix computation.\n @ingroup ExchangeCorrelation\n\n This function returns the workspace needed (host/device) for a single computation,\n based on the provided plan and pair list. Only sizes are computed; output and orbital\n buffers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestXCPotentialUKSComputeParameters_t) Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] numOccupiedAlpha Number of alpha occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param[in] numOccupiedBeta Number of beta occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param coefficientMatrixAlpha Input alpha coefficient matrix. May be NULL.\n @param coefficientMatrixBeta Input beta coefficient matrix. May be NULL.\n @param outXCEnergy Output (double) for the computed XC energy. May be NULL.\n @param outXCPotentialMatrixAlpha Output buffer for computed alpha XC potential matrix. May be NULL.\n @param outXCPotentialMatrixBeta Output buffer for computed beta XC potential matrix. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupiedAlpha or \\c numOccupiedBeta is zero;\n - \\c CUEST_STATUS_EXCEPTION if \\c cuestXCIntPlanParametersFunctional_t is \\c CUEST_XCINTPLAN_PARAMETERS_FUNCTIONAL_HF (set in the \\c cuestXCIntPlan_t);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1554pub unsafe fn cuestXCPotentialUKSComputeWorkspaceQuery(
1555 handle: cuestHandle_t,
1556 plan: cuestXCIntPlan_t,
1557 parameters: cuestXCPotentialUKSComputeParameters_t,
1558 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1559 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1560 numOccupiedAlpha: u64,
1561 numOccupiedBeta: u64,
1562 coefficientMatrixAlpha: *const f64,
1563 coefficientMatrixBeta: *const f64,
1564 outXCEnergy: *mut f64,
1565 outXCPotentialMatrixAlpha: *mut f64,
1566 outXCPotentialMatrixBeta: *mut f64,
1567) -> cuestStatus_t {
1568 dyload_lib().cuestXCPotentialUKSComputeWorkspaceQuery.expect(
1569 "cuEST function `cuestXCPotentialUKSComputeWorkspaceQuery` not found in the loaded library",
1570 )(
1571 handle,
1572 plan,
1573 parameters,
1574 variableBufferSize,
1575 temporaryWorkspaceDescriptor,
1576 numOccupiedAlpha,
1577 numOccupiedBeta,
1578 coefficientMatrixAlpha,
1579 coefficientMatrixBeta,
1580 outXCEnergy,
1581 outXCPotentialMatrixAlpha,
1582 outXCPotentialMatrixBeta,
1583 )
1584}
1585
1586#[doc = " @brief Compute the electron density on the integration grid using the provided XC integral plan and molecular orbitals.\n @ingroup ExchangeCorrelationAdvanced\n\n This routine evaluates the electronic density (and its derivatives, when applicable) on the molecular integration grid.\n The computation depends on the chosen approximation level (LDA, GGA, or meta-GGA), which determines the number of\n quantities calculated per grid point. The density is computed from the occupied molecular orbitals.\n\n Each approximation produces an output array of shape (\\c npoint × ndim), where:\n - LDA: ndim = 1 (\\f$ \\rho \\f$);\n - GGA: ndim = 4 (\\f$ \\rho, \\nabla_{x}\\rho, \\nabla_{y}\\rho, \\nabla_{z}\\rho \\f$);\n - meta-GGA: ndim = 5 (\\f$ \\rho, \\nabla_{x}\\rho, \\nabla_{y}\\rho, \\nabla_{z}\\rho, \\tau \\f$).\n\n The returned density does not include integration weights. To obtain the total number of electrons, evaluate:\n \\f[ N_{elec} = \\sum_{P}^{\\rm npoint} w_{P} \\rho_{P} \\f]\n where, \\f$ w_{P} \\f$ is the total integration weight that can be obtained by calling \\c cuestXCIntegrationWeightCompute.\n\n All required workspace must first be allocated according to the size returned by\n \\c cuestXCDensityComputeWorkspaceQuery, which must be called before invoking this function.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] approximation Specifies the XC approximation: LDA, GGA, or meta-GGA.\n @param[in] parameters Compute parameters (\\c cuestXCDensityComputeParameters_t) Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Preallocated temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in \\c coefficientMatrix). Must be greater than zero.\n @param[in] coefficientMatrix Input orbital coefficient matrix (size: \\c numOccupied × nao) on the GPU. Must not be NULL.\n @param[out] outGridDensity Output buffer for computed density or density derivatives on the grid (size: \\c npoint × ndim) on the GPU. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are of incorrect type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero or \\c approximation is invalid;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1587pub unsafe fn cuestXCDensityCompute(
1588 handle: cuestHandle_t,
1589 plan: cuestXCIntPlan_t,
1590 approximation: cuestXCAdvancedComputeParametersApproximation_t,
1591 parameters: cuestXCDensityComputeParameters_t,
1592 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1593 temporaryWorkspace: *mut cuestWorkspace_t,
1594 numOccupied: u64,
1595 coefficientMatrix: *const f64,
1596 outGridDensity: *mut f64,
1597) -> cuestStatus_t {
1598 dyload_lib()
1599 .cuestXCDensityCompute
1600 .expect("cuEST function `cuestXCDensityCompute` not found in the loaded library")(
1601 handle,
1602 plan,
1603 approximation,
1604 parameters,
1605 variableBufferSize,
1606 temporaryWorkspace,
1607 numOccupied,
1608 coefficientMatrix,
1609 outGridDensity,
1610 )
1611}
1612
1613#[doc = " @brief Query the temporary workspace required (in bytes) for an XC density computation.\n @ingroup ExchangeCorrelationAdvanced\n\n Determines the GPU memory requirements for computing the electron density (and its derivatives)\n on the molecular grid using the provided XC integral plan and approximation type. Only memory\n requirements are estimated; no actual computation is performed. Input and output pointers may be NULL.\n\n This call must precede \\c cuestXCDensityCompute to ensure that sufficient temporary memory is available.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] approximation Specifies the XC approximation: LDA, GGA, or meta-GGA.\n @param[in] parameters Compute parameters (\\c cuestXCDensityComputeParameters_t) Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor with required workspace sizes (in bytes). Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in \\c coefficientMatrix). Must be greater than zero.\n @param coefficientMatrix Input orbital coefficient matrix. May be NULL.\n @param outGridDensity Output buffer for computed density values. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are of incorrect type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero or \\c approximation is invalid;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1614pub unsafe fn cuestXCDensityComputeWorkspaceQuery(
1615 handle: cuestHandle_t,
1616 plan: cuestXCIntPlan_t,
1617 approximation: cuestXCAdvancedComputeParametersApproximation_t,
1618 parameters: cuestXCDensityComputeParameters_t,
1619 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1620 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1621 numOccupied: u64,
1622 coefficientMatrix: *const f64,
1623 outGridDensity: *mut f64,
1624) -> cuestStatus_t {
1625 dyload_lib().cuestXCDensityComputeWorkspaceQuery.expect(
1626 "cuEST function `cuestXCDensityComputeWorkspaceQuery` not found in the loaded library",
1627 )(
1628 handle,
1629 plan,
1630 approximation,
1631 parameters,
1632 variableBufferSize,
1633 temporaryWorkspaceDescriptor,
1634 numOccupied,
1635 coefficientMatrix,
1636 outGridDensity,
1637 )
1638}
1639
1640#[doc = " @brief Compute the XC potential matrix (Vxc) from a precomputed XC potential on the integration grid.\n @ingroup ExchangeCorrelationAdvanced\n\n This routine constructs the exchange-correlation potential matrix in the AO basis from a grid representation\n of the XC potential. The input grid potential should correspond to the same grid and basis information\n specified by the provided XC integral plan. The dimensionality of the grid potential depends on the selected\n approximation (LDA, GGA, meta-GGA).\n\n Each approximation requires an input array of shape (\\c npoint × ndim) containing the XC potential\n components (derivatives of the XC energy density \\f$ f \\f$) ordered as:\n - LDA: ndim = 1 (\\f$ \\partial f / \\partial\\rho \\f$);\n - GGA: ndim = 4 (\\f$ \\partial f / \\partial\\rho,\\; 4 (\\partial f / \\partial\\gamma) \\nabla_{x}\\rho,\\; 4 (\\partial f / \\partial\\gamma) \\nabla_{y}\\rho,\\; 4 (\\partial f / \\partial\\gamma) \\nabla_{z}\\rho \\f$, where \\f$ \\gamma = |\\nabla\\rho|^{2} \\f$);\n - meta-GGA: ndim = 5 (the GGA components followed by \\f$ \\partial f / \\partial\\tau \\f$).\n\n Important: This function does not apply the integration weights to the user-supplied XC potential. The user must\n apply the total integration weights, which can be obtained by calling \\c cuestXCIntegrationWeightCompute.\n\n All required temporary workspace must first be allocated using the size returned by\n \\c cuestXCPotentialComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] approximation Specifies the XC approximation: LDA, GGA, or meta-GGA.\n @param[in] parameters Compute parameters (\\c cuestXCPotentialComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Preallocated temporary workspace buffer for this operation. Must not be NULL.\n @param[in] gridXCPotential Input XC potential on the grid (size: \\c npoint × ndim) on GPU. Must not be NULL.\n @param[out] outXCPotentialMatrix Output buffer for computed XC potential matrix (size: nao × nao) on GPU. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are of incorrect type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c approximation is invalid;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1641pub unsafe fn cuestXCPotentialCompute(
1642 handle: cuestHandle_t,
1643 plan: cuestXCIntPlan_t,
1644 approximation: cuestXCAdvancedComputeParametersApproximation_t,
1645 parameters: cuestXCPotentialComputeParameters_t,
1646 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1647 temporaryWorkspace: *mut cuestWorkspace_t,
1648 gridXCPotential: *const f64,
1649 outXCPotentialMatrix: *mut f64,
1650) -> cuestStatus_t {
1651 dyload_lib()
1652 .cuestXCPotentialCompute
1653 .expect("cuEST function `cuestXCPotentialCompute` not found in the loaded library")(
1654 handle,
1655 plan,
1656 approximation,
1657 parameters,
1658 variableBufferSize,
1659 temporaryWorkspace,
1660 gridXCPotential,
1661 outXCPotentialMatrix,
1662 )
1663}
1664
1665#[doc = " @brief Query the temporary workspace required (in bytes) for an XC potential matrix computation.\n @ingroup ExchangeCorrelationAdvanced\n\n This function returns the GPU workspace memory requirements for constructing\n the exchange-correlation (XC) potential matrix in the AO basis from a given XC potential on the grid.\n Only workspace sizes are computed; the input and output pointers may be NULL.\n\n This query must be executed prior to calling \\c cuestXCPotentialCompute.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] approximation Specifies the XC approximation: LDA, GGA, or meta-GGA.\n @param[in] parameters Compute parameters (\\c cuestXCPotentialComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for required temporary workspace sizes (in bytes). Must not be NULL.\n @param gridXCPotential Input XC potential on the grid. May be NULL.\n @param outXCPotentialMatrix Output buffer for computed XC potential matrix. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are of incorrect type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c approximation is invalid;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1666pub unsafe fn cuestXCPotentialComputeWorkspaceQuery(
1667 handle: cuestHandle_t,
1668 plan: cuestXCIntPlan_t,
1669 approximation: cuestXCAdvancedComputeParametersApproximation_t,
1670 parameters: cuestXCPotentialComputeParameters_t,
1671 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1672 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1673 gridXCPotential: *const f64,
1674 outXCPotentialMatrix: *mut f64,
1675) -> cuestStatus_t {
1676 dyload_lib().cuestXCPotentialComputeWorkspaceQuery.expect(
1677 "cuEST function `cuestXCPotentialComputeWorkspaceQuery` not found in the loaded library",
1678 )(
1679 handle,
1680 plan,
1681 approximation,
1682 parameters,
1683 variableBufferSize,
1684 temporaryWorkspaceDescriptor,
1685 gridXCPotential,
1686 outXCPotentialMatrix,
1687 )
1688}
1689
1690#[doc = " @brief Compute the nonsymmetric electron density on the integration grid using the provided XC integral plan and two sets of molecular orbitals.\n @ingroup ExchangeCorrelationAdvanced\n\n This routine evaluates the nonsymmetric electronic density (and its derivatives, when applicable) on the molecular\n integration grid. The nonsymmetric density is formed from a left and a right set of occupied molecular orbitals,\n both of size \\c numOccupied × nao. This is the generalization of \\c cuestXCDensityCompute, which uses the same\n coefficients for both the left and right.\n\n The output array has the same shape as \\c cuestXCDensityCompute for the chosen approximation (size: \\c npoint × ndim):\n - LDA: ndim = 1 (\\f$ \\rho \\f$);\n - GGA: ndim = 4 (\\f$ \\rho, \\nabla_{x}\\rho, \\nabla_{y}\\rho, \\nabla_{z}\\rho \\f$);\n - meta-GGA: ndim = 5 (\\f$ \\rho, \\nabla_{x}\\rho, \\nabla_{y}\\rho, \\nabla_{z}\\rho, \\tau \\f$).\n\n All required workspace must first be allocated according to the size returned by\n \\c cuestXCNonsymmetricDensityComputeWorkspaceQuery, which must be called before invoking this function.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] approximation Specifies the XC approximation: LDA, GGA, or meta-GGA.\n @param[in] parameters Compute parameters (\\c cuestXCNonsymmetricDensityComputeParameters_t). Must not be NULL.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Preallocated temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in each coefficient matrix). Must be greater than zero.\n @param[in] leftCoefficientMatrix Input left orbital coefficient matrix (size: \\c numOccupied × nao) on the GPU. Must not be NULL.\n @param[in] rightCoefficientMatrix Input right orbital coefficient matrix (size: \\c numOccupied × nao) on the GPU. Must not be NULL.\n @param[out] outGridDensity Output buffer for computed nonsymmetric density or density derivatives on the grid (size: \\c npoint × ndim) on the GPU. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are of incorrect type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero or \\c approximation is invalid;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1691pub unsafe fn cuestXCNonsymmetricDensityCompute(
1692 handle: cuestHandle_t,
1693 plan: cuestXCIntPlan_t,
1694 approximation: cuestXCAdvancedComputeParametersApproximation_t,
1695 parameters: cuestXCNonsymmetricDensityComputeParameters_t,
1696 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1697 temporaryWorkspace: *mut cuestWorkspace_t,
1698 numOccupied: u64,
1699 leftCoefficientMatrix: *const f64,
1700 rightCoefficientMatrix: *const f64,
1701 outGridDensity: *mut f64,
1702) -> cuestStatus_t {
1703 dyload_lib().cuestXCNonsymmetricDensityCompute.expect(
1704 "cuEST function `cuestXCNonsymmetricDensityCompute` not found in the loaded library",
1705 )(
1706 handle,
1707 plan,
1708 approximation,
1709 parameters,
1710 variableBufferSize,
1711 temporaryWorkspace,
1712 numOccupied,
1713 leftCoefficientMatrix,
1714 rightCoefficientMatrix,
1715 outGridDensity,
1716 )
1717}
1718
1719#[doc = " @brief Query the temporary workspace required (in bytes) for an XC nonsymmetric density computation.\n @ingroup ExchangeCorrelationAdvanced\n\n Determines the GPU memory requirements for computing the nonsymmetric electron density (and its derivatives)\n on the molecular grid using the provided XC integral plan and approximation type. Only memory\n requirements are estimated; no actual computation is performed. Input and output pointers may be NULL.\n\n This call must precede \\c cuestXCNonsymmetricDensityCompute to ensure that sufficient temporary memory is available.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] approximation Specifies the XC approximation: LDA, GGA, or meta-GGA.\n @param[in] parameters Compute parameters (\\c cuestXCNonsymmetricDensityComputeParameters_t). Must not be NULL.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor with required workspace sizes (in bytes). Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in each coefficient matrix). Must be greater than zero.\n @param leftCoefficientMatrix Input left orbital coefficient matrix. May be NULL.\n @param rightCoefficientMatrix Input right orbital coefficient matrix. May be NULL.\n @param outGridDensity Output buffer for computed nonsymmetric density values. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are of incorrect type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero or \\c approximation is invalid;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1720pub unsafe fn cuestXCNonsymmetricDensityComputeWorkspaceQuery(
1721 handle: cuestHandle_t,
1722 plan: cuestXCIntPlan_t,
1723 approximation: cuestXCAdvancedComputeParametersApproximation_t,
1724 parameters: cuestXCNonsymmetricDensityComputeParameters_t,
1725 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1726 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1727 numOccupied: u64,
1728 leftCoefficientMatrix: *const f64,
1729 rightCoefficientMatrix: *const f64,
1730 outGridDensity: *mut f64,
1731) -> cuestStatus_t {
1732 dyload_lib().cuestXCNonsymmetricDensityComputeWorkspaceQuery.expect("cuEST function `cuestXCNonsymmetricDensityComputeWorkspaceQuery` not found in the loaded library")(handle, plan, approximation, parameters, variableBufferSize, temporaryWorkspaceDescriptor, numOccupied, leftCoefficientMatrix, rightCoefficientMatrix, outGridDensity)
1733}
1734
1735#[doc = " @brief Compute the derivative of the RKS XC energy (Exc) using the supplied XC integral plan and occupied molecular orbitals.\n @ingroup ExchangeCorrelationGrad\n\n This routine computes the XC gradient from occupied molecular orbitals.\n This is the RKS interface that assumes the alpha and beta spin orbitals are identical. The user must\n provide occupied molecular orbitals (size nocc x nao) and a preallocated output buffer (size natom × 3).\n The orbital basis and integration grid used are passed via the \\c plan. All required temporary workspace\n must be allocated using the size returned by \\c cuestXCDerivativeRKSComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n The \\c cuestXCIntPlanParametersFunctional_t set during plan construction determines what XC gradient is evaluated.\n @param[in] parameters Compute parameters (\\c cuestXCDerivativeRKSComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param[in] coefficientMatrix Input coefficient matrix (size: \\c numOccupied × nao) on GPU. Must not be NULL.\n @param[out] outGradient Output buffer for computed XC gradient (size: natom × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero;\n - \\c CUEST_STATUS_EXCEPTION if \\c cuestXCIntPlanParametersFunctional_t is \\c CUEST_XCINTPLAN_PARAMETERS_FUNCTIONAL_HF (set in the \\c cuestXCIntPlan_t);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1736pub unsafe fn cuestXCDerivativeRKSCompute(
1737 handle: cuestHandle_t,
1738 plan: cuestXCIntPlan_t,
1739 parameters: cuestXCDerivativeRKSComputeParameters_t,
1740 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1741 temporaryWorkspace: *mut cuestWorkspace_t,
1742 numOccupied: u64,
1743 coefficientMatrix: *const f64,
1744 outGradient: *mut f64,
1745) -> cuestStatus_t {
1746 dyload_lib()
1747 .cuestXCDerivativeRKSCompute
1748 .expect("cuEST function `cuestXCDerivativeRKSCompute` not found in the loaded library")(
1749 handle,
1750 plan,
1751 parameters,
1752 variableBufferSize,
1753 temporaryWorkspace,
1754 numOccupied,
1755 coefficientMatrix,
1756 outGradient,
1757 )
1758}
1759
1760#[doc = " @brief Query the temporary workspace required (in bytes) for an XC derivative computation.\n @ingroup ExchangeCorrelationGrad\n\n This function returns the workspace needed (host/device) for a single computation,\n based on the provided plan. Only sizes are computed; output and orbital\n buffers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestXCDerivativeRKSComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param coefficientMatrix Input coefficient matrix. May be NULL.\n @param outGradient Output buffer for computed XC gradient. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero;\n - \\c CUEST_STATUS_EXCEPTION if \\c cuestXCIntPlanParametersFunctional_t is \\c CUEST_XCINTPLAN_PARAMETERS_FUNCTIONAL_HF (set in the \\c cuestXCIntPlan_t);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1761pub unsafe fn cuestXCDerivativeRKSComputeWorkspaceQuery(
1762 handle: cuestHandle_t,
1763 plan: cuestXCIntPlan_t,
1764 parameters: cuestXCDerivativeRKSComputeParameters_t,
1765 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1766 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1767 numOccupied: u64,
1768 coefficientMatrix: *const f64,
1769 outGradient: *mut f64,
1770) -> cuestStatus_t {
1771 dyload_lib().cuestXCDerivativeRKSComputeWorkspaceQuery.expect("cuEST function `cuestXCDerivativeRKSComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, variableBufferSize, temporaryWorkspaceDescriptor, numOccupied, coefficientMatrix, outGradient)
1772}
1773
1774#[doc = " @brief Compute the derivative of the UKS XC energy (Exc) using the supplied XC integral plan and occupied molecular orbitals.\n @ingroup ExchangeCorrelationGrad\n\n This routine computes the UKS XC gradient from occupied molecular orbitals.\n This is the UKS interface that allows the alpha and beta spin orbitals to be different. The user must\n provide occupied molecular orbitals (size nocc x nao) and preallocated output buffer (size natom × 3).\n The orbital basis and integration grid used are passed via the \\c plan. All required temporary workspace\n must be allocated using the size returned by \\c cuestXCDerivativeUKSComputeWorkspaceQuery.\n\n Alpha and beta coefficient matrices must always be provided with non-zero numbers of occupied orbitals.\n Cases without beta (or alpha) electrons (hydrogen atom, for example), can be handled by passing in a\n coefficient matrix containing only zeros.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n The \\c cuestXCIntPlanParametersFunctional_t set during plan construction determines what XC gradient is evaluated.\n @param[in] parameters Compute parameters (\\c cuestXCDerivativeUKSComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupiedAlpha Number of alpha occupied orbitals (rows in alpha coefficient matrix); must be greater than zero.\n @param[in] numOccupiedBeta Number of beta occupied orbitals (rows in beta coefficient matrix); must be greater than zero.\n @param[in] coefficientMatrixAlpha Input alpha coefficient matrix (size: \\c numOccupiedAlpha × nao) on GPU. Must not be NULL.\n @param[in] coefficientMatrixBeta Input beta coefficient matrix (size: \\c numOccupiedBeta × nao) on GPU. Must not be NULL.\n @param[out] outGradient Output buffer for computed XC gradient (size: natom × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupiedAlpha or \\c numOccupiedBeta is zero;\n - \\c CUEST_STATUS_EXCEPTION if \\c cuestXCIntPlanParametersFunctional_t is \\c CUEST_XCINTPLAN_PARAMETERS_FUNCTIONAL_HF (set in the \\c cuestXCIntPlan_t);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1775pub unsafe fn cuestXCDerivativeUKSCompute(
1776 handle: cuestHandle_t,
1777 plan: cuestXCIntPlan_t,
1778 parameters: cuestXCDerivativeUKSComputeParameters_t,
1779 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1780 temporaryWorkspace: *mut cuestWorkspace_t,
1781 numOccupiedAlpha: u64,
1782 numOccupiedBeta: u64,
1783 coefficientMatrixAlpha: *const f64,
1784 coefficientMatrixBeta: *const f64,
1785 outGradient: *mut f64,
1786) -> cuestStatus_t {
1787 dyload_lib()
1788 .cuestXCDerivativeUKSCompute
1789 .expect("cuEST function `cuestXCDerivativeUKSCompute` not found in the loaded library")(
1790 handle,
1791 plan,
1792 parameters,
1793 variableBufferSize,
1794 temporaryWorkspace,
1795 numOccupiedAlpha,
1796 numOccupiedBeta,
1797 coefficientMatrixAlpha,
1798 coefficientMatrixBeta,
1799 outGradient,
1800 )
1801}
1802
1803#[doc = " @brief Query the temporary workspace required (in bytes) for an XC derivative computation.\n @ingroup ExchangeCorrelationGrad\n\n This function returns the workspace needed (host/device) for a single computation,\n based on the provided plan. Only sizes are computed; output and orbital\n buffers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestXCDerivativeUKSComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] numOccupiedAlpha Number of alpha occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param[in] numOccupiedBeta Number of beta occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param coefficientMatrixAlpha Input alpha coefficient matrix. May be NULL.\n @param coefficientMatrixBeta Input beta coefficient matrix. May be NULL.\n @param outGradient Output buffer for computed XC gradient. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupiedAlpha or \\c numOccupiedBeta is zero;\n - \\c CUEST_STATUS_EXCEPTION if \\c cuestXCIntPlanParametersFunctional_t is \\c CUEST_XCINTPLAN_PARAMETERS_FUNCTIONAL_HF (set in the \\c cuestXCIntPlan_t);\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1804pub unsafe fn cuestXCDerivativeUKSComputeWorkspaceQuery(
1805 handle: cuestHandle_t,
1806 plan: cuestXCIntPlan_t,
1807 parameters: cuestXCDerivativeUKSComputeParameters_t,
1808 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1809 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1810 numOccupiedAlpha: u64,
1811 numOccupiedBeta: u64,
1812 coefficientMatrixAlpha: *const f64,
1813 coefficientMatrixBeta: *const f64,
1814 outGradient: *mut f64,
1815) -> cuestStatus_t {
1816 dyload_lib().cuestXCDerivativeUKSComputeWorkspaceQuery.expect("cuEST function `cuestXCDerivativeUKSComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, variableBufferSize, temporaryWorkspaceDescriptor, numOccupiedAlpha, numOccupiedBeta, coefficientMatrixAlpha, coefficientMatrixBeta, outGradient)
1817}
1818
1819#[doc = " @brief Compute the exchange-correlation (XC) derivative contributions for analytical gradients.\n @ingroup ExchangeCorrelationAdvanced\n\n This routine computes the gradient contributions of the exchange–correlation (XC) energy\n with respect to the atomic coordinates. It uses the provided XC potential on the molecular\n integration grid, the molecular orbital coefficients, and the XC integral plan.\n\n The form and dimensionality of the input \\c gridXCPotential depend on the chosen\n approximation type (LDA, GGA, or meta-GGA) - see \\c cuestXCPotentialCompute.\n All temporary workspace must be preallocated\n according to the size returned by \\c cuestXCDerivativeComputeWorkspaceQuery.\n\n Important: This function does not apply the integration weights to the user-supplied XC potential. The user must\n apply the total integration weights, which can be obtained by calling \\c cuestXCIntegrationWeightCompute.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] approximation Specifies the XC approximation: LDA, GGA, or meta-GGA.\n @param[in] parameters Compute parameters (\\c cuestXCDerivativeComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Preallocated temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals in the input coefficient matrix. Must be greater than zero.\n @param[in] coefficientMatrix Input orbital coefficient matrix (size: \\c numOccupied × nao) on GPU. Must not be NULL.\n @param[in] gridXCPotential Input grid exchange-correlation potential array (size: \\c npoint × ndim) on GPU. Must not be NULL.\n @param[out] outBasisGradient Output buffer for basis function center gradient contributions (size: natom × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n @param[out] outGridGradient Output buffer for grid point gradient contributions (size: npoint × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if handle types are incorrect;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero or approximation invalid;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise.\n\n In order to compute the derivative of the XC energy,\n \\f[ \\frac{\\rm d}{{\\rm d}R_A} E_{xc} = \\frac{\\rm d}{{\\rm d}R_A} \\sum_{P}^{\\rm npoint} w_{P} e_{xc,P} \\f]\n where \\f$ A \\f$ indexes atom centers and \\f$ P \\f$ are the grid points, there are two terms to evaluate.\n \\f[ \\frac{\\rm d}{{\\rm d}R_A} E_{xc} = \\sum_{P}^{\\rm npoint} \\frac{{\\rm d} w_{P}}{{\\rm d}R_A} e_{xc,P} + \\sum_{P}^{\\rm npoint} w_{P} \\frac{{\\rm d} e_{xc,P}}{{\\rm d}R_A} \\f]\n Contributions from the second term, \\f$ \\sum_{P}^{\\rm npoint} w_{P} \\frac{{\\rm d} e_{xc,P}}{{\\rm d}R_A} \\f$ are evaluated by this function. Specifically,\n this function computes \\c outBasisGradient computed as \\f$ \\sum_{P}^{\\rm npoint} w_{P} \\frac{\\partial e_{xc,P}}{\\partial R_A} \\f$, where \\f$ R_A \\f$ are the basis\n function centers (treated as separate from grid point centers). It also computes \\c outGridGradient as \\f$ \\sum_{P}^{\\rm npoint} w_{P} \\frac{\\partial e_{xc,P}}{\\partial R_Q} \\f$,\n where \\f$ R_Q \\f$ are the grid points. The \\c outBasisGradient contributed directly to the derivative of the XC energy. The \\c outGridGradient array should be included\n in a subsequent call to \\c cuestXCGridDerivativeCompute to assemble additional contributions to the gradient.\n"]
1820pub unsafe fn cuestXCDerivativeCompute(
1821 handle: cuestHandle_t,
1822 plan: cuestXCIntPlan_t,
1823 approximation: cuestXCAdvancedComputeParametersApproximation_t,
1824 parameters: cuestXCDerivativeComputeParameters_t,
1825 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1826 temporaryWorkspace: *mut cuestWorkspace_t,
1827 numOccupied: u64,
1828 coefficientMatrix: *const f64,
1829 gridXCPotential: *const f64,
1830 outBasisGradient: *mut f64,
1831 outGridGradient: *mut f64,
1832) -> cuestStatus_t {
1833 dyload_lib()
1834 .cuestXCDerivativeCompute
1835 .expect("cuEST function `cuestXCDerivativeCompute` not found in the loaded library")(
1836 handle,
1837 plan,
1838 approximation,
1839 parameters,
1840 variableBufferSize,
1841 temporaryWorkspace,
1842 numOccupied,
1843 coefficientMatrix,
1844 gridXCPotential,
1845 outBasisGradient,
1846 outGridGradient,
1847 )
1848}
1849
1850#[doc = " @brief Query the temporary workspace required (in bytes) for an XC derivative computation.\n @ingroup ExchangeCorrelationAdvanced\n\n Determines the required GPU workspace size to compute exchange–correlation (XC) energy gradient\n contributions. This query prepares for \\c cuestXCDerivativeCompute by reporting the necessary\n temporary memory allocation given the chosen approximation and molecular system.\n\n Only workspace sizes are computed; inputs/outputs may be NULL.\n The same \\c variableBufferSize descriptor must be reused for the corresponding compute call.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] approximation Specifies the XC approximation: LDA, GGA, or meta-GGA.\n @param[in] parameters Compute parameters (\\c cuestXCDerivativeComputeParameters_t). Must not be NULL\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Some static allocations are made outside of what is\n controlled by the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor with required workspace sizes (in bytes). Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals. Must be greater than zero.\n @param coefficientMatrix Input coefficient matrix. May be NULL.\n @param gridXCPotential Input grid XC potential array. May be NULL.\n @param outBasisGradient Output buffer for basis function center gradient contributions. May be NULL.\n @param outGridGradient Output buffer for grid point gradient contributions. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if handle types are incorrect;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero or approximation invalid;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1851pub unsafe fn cuestXCDerivativeComputeWorkspaceQuery(
1852 handle: cuestHandle_t,
1853 plan: cuestXCIntPlan_t,
1854 approximation: cuestXCAdvancedComputeParametersApproximation_t,
1855 parameters: cuestXCDerivativeComputeParameters_t,
1856 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1857 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1858 numOccupied: u64,
1859 coefficientMatrix: *const f64,
1860 gridXCPotential: *const f64,
1861 outBasisGradient: *mut f64,
1862 outGridGradient: *mut f64,
1863) -> cuestStatus_t {
1864 dyload_lib().cuestXCDerivativeComputeWorkspaceQuery.expect(
1865 "cuEST function `cuestXCDerivativeComputeWorkspaceQuery` not found in the loaded library",
1866 )(
1867 handle,
1868 plan,
1869 approximation,
1870 parameters,
1871 variableBufferSize,
1872 temporaryWorkspaceDescriptor,
1873 numOccupied,
1874 coefficientMatrix,
1875 gridXCPotential,
1876 outBasisGradient,
1877 outGridGradient,
1878 )
1879}
1880
1881#[doc = " @brief Compute total XC energy gradient from grid XC energy and its spatial derivatives.\n @ingroup ExchangeCorrelationAdvanced\n\n This routine combines grid-resolved XC energy densities and their spatial gradients\n to produce the total (molecular) XC gradient with respect to atomic coordinates.\n It serves as the final step in assembling analytical derivatives after the\n grid-level contributions have been computed.\n\n The operation uses the molecular grid and AO basis data embedded in the provided XC plan.\n All required workspace should be preallocated according to the size returned by\n \\c cuestXCGridDerivativeComputeWorkspaceQuery.\n\n Important: This function does apply integration weights to the user-supplied XC energy. The user must\n supply the bare \\f$ e_{xc,P} \\f$ array as shown in:\n \\f[ E_{xc} = \\sum_{P}^{\\rm npoint} w_{P} e_{xc,P} \\f]\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestXCGridDerivativeComputeParameters_t). Must not be NULL\n @param[in] temporaryWorkspace Preallocated GPU workspace buffer for temporary data. Must not be NULL.\n @param[in] gridXCEnergy Input grid XC energy density values (size: npoint × 1) on GPU. Must not be NULL.\n @param[in] gridGradient Input grid spatial gradient contributions (size: npoint × 3) on GPU. Must not be NULL.\n @param[out] outGradient Output total (atomic) gradient of XC energy (size: natom × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if handle types are incorrect;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise.\n\n This function is expected to be called after \\c cuestXCDerivativeCompute. The purpose of this function\n is to evaluate contributions to the XC gradient resulting from derivatives of the integration weight\n \\f$ \\sum_{P}^{\\rm npoint} \\frac{{\\rm d} w_{P}}{{\\rm d}R_A} e_{xc,P} \\f$ and to incorporate contributions\n from grid point motion: \\f$ \\sum_{P}^{\\rm npoint} w_{P} \\frac{\\partial e_{xc,P}}{\\partial R_Q} \\frac{\\partial R_Q}{\\partial R_A} \\f$.\n Here \\f$ R_Q \\f$ are the grid points and \\f$ R_A \\f$ are the atomic centers defining the grid.\n\n The sum of \\c outGradient computed by this routine and \\c outBasisGradient computed by \\c cuestXCDerivativeCompute (scaled appropriately)\n is the derivative of the XC energy: \\f$ \\frac{\\rm d}{{\\rm d}R_A} E_{xc} \\f$. In the case of UKS calculations, \\c cuestXCDerivativeCompute\n will need to be called twice, but \\c cuestXCGridDerivativeCompute only needs to be called once."]
1882pub unsafe fn cuestXCGridDerivativeCompute(
1883 handle: cuestHandle_t,
1884 plan: cuestXCIntPlan_t,
1885 parameters: cuestXCGridDerivativeComputeParameters_t,
1886 temporaryWorkspace: *mut cuestWorkspace_t,
1887 gridXCEnergy: *const f64,
1888 gridGradient: *const f64,
1889 outGradient: *mut f64,
1890) -> cuestStatus_t {
1891 dyload_lib()
1892 .cuestXCGridDerivativeCompute
1893 .expect("cuEST function `cuestXCGridDerivativeCompute` not found in the loaded library")(
1894 handle,
1895 plan,
1896 parameters,
1897 temporaryWorkspace,
1898 gridXCEnergy,
1899 gridGradient,
1900 outGradient,
1901 )
1902}
1903
1904#[doc = " @brief Query the temporary workspace required (in bytes) for an XC grid derivative computation.\n @ingroup ExchangeCorrelationAdvanced\n\n Estimates the GPU memory workspace required to compute the grid-based exchange–correlation (XC)\n gradient using molecular grid data. This function reports the necessary device buffer size\n for \\c cuestXCGridDerivativeCompute.\n\n Only workspace sizes are computed; input and output buffers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestXCGridDerivativeComputeParameters_t). Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor with required temporary workspace sizes (in bytes). Must not be NULL.\n @param gridXCEnergy Input grid XC energy density. May be NULL.\n @param gridGradient Input grid gradient contributions. May be NULL.\n @param outGradient Output total (atomic) gradient array. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if handle types are incorrect;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1905pub unsafe fn cuestXCGridDerivativeComputeWorkspaceQuery(
1906 handle: cuestHandle_t,
1907 plan: cuestXCIntPlan_t,
1908 parameters: cuestXCGridDerivativeComputeParameters_t,
1909 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1910 gridXCEnergy: *const f64,
1911 gridGradient: *const f64,
1912 outGradient: *mut f64,
1913) -> cuestStatus_t {
1914 dyload_lib().cuestXCGridDerivativeComputeWorkspaceQuery.expect("cuEST function `cuestXCGridDerivativeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, gridXCEnergy, gridGradient, outGradient)
1915}
1916
1917#[doc = " @brief Compute the nonsymmetric exchange-correlation (XC) derivative contributions for analytical gradients.\n @ingroup ExchangeCorrelationAdvanced\n\n This routine computes the gradient contributions of the exchange–correlation (XC) energy\n with respect to the atomic coordinates using a nonsymmetric density. It uses the provided XC\n potential on the molecular integration grid, a left and a right set of molecular orbital\n coefficients, and the XC integral plan. This is the generalization of \\c cuestXCDerivativeCompute,\n which uses the same coefficients for both left and right.\n\n The form and dimensionality of the input \\c gridXCPotential depend on the chosen\n approximation type (LDA, GGA, or meta-GGA) — see \\c cuestXCPotentialCompute.\n All temporary workspace must be preallocated according to the size returned by\n \\c cuestXCNonsymmetricDerivativeComputeWorkspaceQuery.\n\n Important: This function does not apply the integration weights to the user-supplied XC potential. The user must\n apply the total integration weights, which can be obtained by calling \\c cuestXCIntegrationWeightCompute.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] approximation Specifies the XC approximation: LDA, GGA, or meta-GGA.\n @param[in] parameters Compute parameters (\\c cuestXCNonsymmetricDerivativeComputeParameters_t). Must not be NULL.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Preallocated temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals in each coefficient matrix. Must be greater than zero.\n @param[in] leftCoefficientMatrix Input left orbital coefficient matrix (size: \\c numOccupied × nao) on GPU. Must not be NULL.\n @param[in] rightCoefficientMatrix Input right orbital coefficient matrix (size: \\c numOccupied × nao) on GPU. Must not be NULL.\n @param[in] gridXCPotential Input grid exchange-correlation potential array (size: \\c npoint × ndim) on GPU. Must not be NULL.\n @param[out] outBasisGradient Output buffer for basis function center gradient contributions (size: natom × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n @param[out] outGridGradient Output buffer for grid point gradient contributions (size: npoint × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if handle types are incorrect;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero or approximation invalid;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1918pub unsafe fn cuestXCNonsymmetricDerivativeCompute(
1919 handle: cuestHandle_t,
1920 plan: cuestXCIntPlan_t,
1921 approximation: cuestXCAdvancedComputeParametersApproximation_t,
1922 parameters: cuestXCNonsymmetricDerivativeComputeParameters_t,
1923 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1924 temporaryWorkspace: *mut cuestWorkspace_t,
1925 numOccupied: u64,
1926 leftCoefficientMatrix: *const f64,
1927 rightCoefficientMatrix: *const f64,
1928 gridXCPotential: *const f64,
1929 outBasisGradient: *mut f64,
1930 outGridGradient: *mut f64,
1931) -> cuestStatus_t {
1932 dyload_lib().cuestXCNonsymmetricDerivativeCompute.expect(
1933 "cuEST function `cuestXCNonsymmetricDerivativeCompute` not found in the loaded library",
1934 )(
1935 handle,
1936 plan,
1937 approximation,
1938 parameters,
1939 variableBufferSize,
1940 temporaryWorkspace,
1941 numOccupied,
1942 leftCoefficientMatrix,
1943 rightCoefficientMatrix,
1944 gridXCPotential,
1945 outBasisGradient,
1946 outGridGradient,
1947 )
1948}
1949
1950#[doc = " @brief Query the temporary workspace required (in bytes) for an XC nonsymmetric derivative computation.\n @ingroup ExchangeCorrelationAdvanced\n\n Determines the required GPU workspace size to compute nonsymmetric exchange–correlation (XC) energy gradient\n contributions. This query prepares for \\c cuestXCNonsymmetricDerivativeCompute by reporting the necessary\n temporary memory allocation given the chosen approximation and molecular system.\n\n Only workspace sizes are computed; inputs/outputs may be NULL.\n The same \\c variableBufferSize descriptor must be reused for the corresponding compute call.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] approximation Specifies the XC approximation: LDA, GGA, or meta-GGA.\n @param[in] parameters Compute parameters (\\c cuestXCNonsymmetricDerivativeComputeParameters_t). Must not be NULL.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor with required workspace sizes (in bytes). Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals. Must be greater than zero.\n @param leftCoefficientMatrix Input left coefficient matrix. May be NULL.\n @param rightCoefficientMatrix Input right coefficient matrix. May be NULL.\n @param gridXCPotential Input grid XC potential array. May be NULL.\n @param outBasisGradient Output buffer for basis function center gradient contributions. May be NULL.\n @param outGridGradient Output buffer for grid point gradient contributions. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if handle types are incorrect;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero or approximation invalid;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1951pub unsafe fn cuestXCNonsymmetricDerivativeComputeWorkspaceQuery(
1952 handle: cuestHandle_t,
1953 plan: cuestXCIntPlan_t,
1954 approximation: cuestXCAdvancedComputeParametersApproximation_t,
1955 parameters: cuestXCNonsymmetricDerivativeComputeParameters_t,
1956 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1957 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
1958 numOccupied: u64,
1959 leftCoefficientMatrix: *const f64,
1960 rightCoefficientMatrix: *const f64,
1961 gridXCPotential: *const f64,
1962 outBasisGradient: *mut f64,
1963 outGridGradient: *mut f64,
1964) -> cuestStatus_t {
1965 dyload_lib().cuestXCNonsymmetricDerivativeComputeWorkspaceQuery.expect("cuEST function `cuestXCNonsymmetricDerivativeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, approximation, parameters, variableBufferSize, temporaryWorkspaceDescriptor, numOccupied, leftCoefficientMatrix, rightCoefficientMatrix, gridXCPotential, outBasisGradient, outGridGradient)
1966}
1967
1968#[doc = " @brief Compute the nonlocal RKS XC potential (Vxc) matrix using the supplied XC integral plan and occupied molecular orbitals.\n @ingroup NonLocalCorrelation\n\n This routine computes the XC potential matrix (Vxc) from the occupied molecular orbitals.\n This is the RKS interface that assumes the alpha and beta spin densities are identical. The user must\n provide preallocated occupied molecular orbitals (size: nocc x nao)\n and a preallocated output buffer (size: nao × nao). The orbital basis and integration grid used are passed\n via the \\c plan . All required temporary workspace must be allocated using the size returned by\n \\c cuestNonlocalXCPotentialRKSComputeWorkspaceQuery.\n\n \\b Precision selection. This routine can use reduced-precision \"ffloat\" compute, selected through the\n compute parameters:\n - \\c CUEST_NONLOCALXCPOTENTIALRKSCOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t):\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is available and\n expected to provide a performance advantage on the present GPU architecture.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n The \\c cuestXCIntPlanParametersFunctional_t set during plan construction does not affect this compute routine.\n @param[in] parameters \\c cuestNonlocalXCPotentialRKSComputeParameters_t defines the details of the nonlocal XC functional.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param[in] coefficientMatrix Input coefficient matrix (size: \\c numOccupied × nao) on GPU. Must not be NULL.\n @param[out] outXCEnergy Output (double) for the computed XC energy (size: 1) on CPU. Must not be NULL.\n @param[out] outXCPotentialMatrix Output buffer for computed XC potential matrix (size: nao × nao) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero, or if a parameter value is invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1969pub unsafe fn cuestNonlocalXCPotentialRKSCompute(
1970 handle: cuestHandle_t,
1971 plan: cuestXCIntPlan_t,
1972 parameters: cuestNonlocalXCPotentialRKSComputeParameters_t,
1973 variableBufferSize: *const cuestWorkspaceDescriptor_t,
1974 temporaryWorkspace: *mut cuestWorkspace_t,
1975 numOccupied: u64,
1976 coefficientMatrix: *const f64,
1977 outXCEnergy: *mut f64,
1978 outXCPotentialMatrix: *mut f64,
1979) -> cuestStatus_t {
1980 dyload_lib().cuestNonlocalXCPotentialRKSCompute.expect(
1981 "cuEST function `cuestNonlocalXCPotentialRKSCompute` not found in the loaded library",
1982 )(
1983 handle,
1984 plan,
1985 parameters,
1986 variableBufferSize,
1987 temporaryWorkspace,
1988 numOccupied,
1989 coefficientMatrix,
1990 outXCEnergy,
1991 outXCPotentialMatrix,
1992 )
1993}
1994
1995#[doc = " @brief Query the temporary workspace required (in bytes) for a nonlocal XC potential matrix computation.\n @ingroup NonLocalCorrelation\n\n This function returns the workspace needed (host/device) for a single computation,\n based on the provided plan and pair list. Only sizes are computed; output and orbital\n buffers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters \\c cuestNonlocalXCPotentialRKSComputeParameters_t defines the details of the nonlocal XC functional.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param coefficientMatrix Input coefficient matrix. May be NULL.\n @param outXCEnergy Output (double) for the computed XC energy. May be NULL.\n @param outXCPotentialMatrix Output buffer for computed XC potential matrix. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero, or if a parameter value is invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
1996pub unsafe fn cuestNonlocalXCPotentialRKSComputeWorkspaceQuery(
1997 handle: cuestHandle_t,
1998 plan: cuestXCIntPlan_t,
1999 parameters: cuestNonlocalXCPotentialRKSComputeParameters_t,
2000 variableBufferSize: *const cuestWorkspaceDescriptor_t,
2001 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2002 numOccupied: u64,
2003 coefficientMatrix: *const f64,
2004 outXCEnergy: *mut f64,
2005 outXCPotentialMatrix: *mut f64,
2006) -> cuestStatus_t {
2007 dyload_lib().cuestNonlocalXCPotentialRKSComputeWorkspaceQuery.expect("cuEST function `cuestNonlocalXCPotentialRKSComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, variableBufferSize, temporaryWorkspaceDescriptor, numOccupied, coefficientMatrix, outXCEnergy, outXCPotentialMatrix)
2008}
2009
2010#[doc = " @brief Compute the nonlocal UKS XC potential (Vxc) matrix using the supplied XC integral plan and occupied molecular orbitals.\n @ingroup NonLocalCorrelation\n\n This routine computes the UKS XC potential matrix (Vxc) from occupied molecular orbitals.\n This is the UKS interface that allows the alpha and beta spin densities to be different. The user must\n provide preallocated occupied molecular orbitals (size: noccA x nao and noccB x nao)\n and preallocated output buffer (size: nao × nao). The orbital basis and integration grid used are passed\n via the \\c plan. All required temporary workspace must be allocated using the size returned by\n \\c cuestNonlocalXCPotentialUKSComputeWorkspaceQuery.\n\n Alpha and beta coefficient matrices must always be provided with non-zero numbers of occupied orbitals.\n Cases without beta (or alpha) electrons (hydrogen atom, for example), can be handled by passing in a\n coefficient matrix containing only zeros.\n\n \\b Precision selection. This routine can use reduced-precision \"ffloat\" compute, selected through the\n compute parameters:\n - \\c CUEST_NONLOCALXCPOTENTIALUKSCOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t):\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is available and\n expected to provide a performance advantage on the present GPU architecture.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n The \\c cuestXCIntPlanParametersFunctional_t set during plan construction does not affect this compute routine.\n @param[in] parameters \\c cuestNonlocalXCPotentialUKSComputeParameters_t defines the details of the nonlocal XC functional.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupiedAlpha Number of alpha occupied orbitals (rows in alpha coefficient matrix); must be greater than zero.\n @param[in] numOccupiedBeta Number of beta occupied orbitals (rows in beta coefficient matrix); must be greater than zero.\n @param[in] coefficientMatrixAlpha Input alpha coefficient matrix (size: \\c numOccupiedAlpha × nao) on GPU. Must not be NULL.\n @param[in] coefficientMatrixBeta Input beta coefficient matrix (size: \\c numOccupiedBeta × nao) on GPU. Must not be NULL.\n @param[out] outXCEnergy Output (double) for the computed XC energy (size: 1) on CPU. Must not be NULL.\n @param[out] outXCPotentialMatrix Output buffer for computed XC potential matrix (size: nao × nao) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupiedAlpha or \\c numOccupiedBeta is zero, or if a parameter value is invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2011pub unsafe fn cuestNonlocalXCPotentialUKSCompute(
2012 handle: cuestHandle_t,
2013 plan: cuestXCIntPlan_t,
2014 parameters: cuestNonlocalXCPotentialUKSComputeParameters_t,
2015 variableBufferSize: *const cuestWorkspaceDescriptor_t,
2016 temporaryWorkspace: *mut cuestWorkspace_t,
2017 numOccupiedAlpha: u64,
2018 numOccupiedBeta: u64,
2019 coefficientMatrixAlpha: *const f64,
2020 coefficientMatrixBeta: *const f64,
2021 outXCEnergy: *mut f64,
2022 outXCPotentialMatrix: *mut f64,
2023) -> cuestStatus_t {
2024 dyload_lib().cuestNonlocalXCPotentialUKSCompute.expect(
2025 "cuEST function `cuestNonlocalXCPotentialUKSCompute` not found in the loaded library",
2026 )(
2027 handle,
2028 plan,
2029 parameters,
2030 variableBufferSize,
2031 temporaryWorkspace,
2032 numOccupiedAlpha,
2033 numOccupiedBeta,
2034 coefficientMatrixAlpha,
2035 coefficientMatrixBeta,
2036 outXCEnergy,
2037 outXCPotentialMatrix,
2038 )
2039}
2040
2041#[doc = " @brief Query the temporary workspace required (in bytes) for a nonlocal XC potential matrix computation.\n @ingroup NonLocalCorrelation\n\n This function returns the workspace needed (host/device) for a single computation,\n based on the provided plan and pair list. Only sizes are computed; output and orbital\n buffers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters \\c cuestNonlocalXCPotentialUKSComputeParameters_t defines the details of the nonlocal XC functional.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] numOccupiedAlpha Number of alpha occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param[in] numOccupiedBeta Number of beta occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param coefficientMatrixAlpha Input alpha coefficient matrix. May be NULL.\n @param coefficientMatrixBeta Input beta coefficient matrix. May be NULL.\n @param outXCEnergy Output (double) for the computed XC energy. May be NULL.\n @param outXCPotentialMatrix Output buffer for computed XC potential matrix. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupiedAlpha or \\c numOccupiedBeta is zero, or if a parameter value is invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2042pub unsafe fn cuestNonlocalXCPotentialUKSComputeWorkspaceQuery(
2043 handle: cuestHandle_t,
2044 plan: cuestXCIntPlan_t,
2045 parameters: cuestNonlocalXCPotentialUKSComputeParameters_t,
2046 variableBufferSize: *const cuestWorkspaceDescriptor_t,
2047 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2048 numOccupiedAlpha: u64,
2049 numOccupiedBeta: u64,
2050 coefficientMatrixAlpha: *const f64,
2051 coefficientMatrixBeta: *const f64,
2052 outXCEnergy: *mut f64,
2053 outXCPotentialMatrix: *mut f64,
2054) -> cuestStatus_t {
2055 dyload_lib().cuestNonlocalXCPotentialUKSComputeWorkspaceQuery.expect("cuEST function `cuestNonlocalXCPotentialUKSComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, variableBufferSize, temporaryWorkspaceDescriptor, numOccupiedAlpha, numOccupiedBeta, coefficientMatrixAlpha, coefficientMatrixBeta, outXCEnergy, outXCPotentialMatrix)
2056}
2057
2058#[doc = " @brief Compute the derivative of the nonlocal RKS XC energy (Exc) using the supplied XC integral plan and occupied molecular orbitals.\n @ingroup NonLocalCorrelationGrad\n\n This routine computes the XC gradient from the occupied molecular orbitals.\n This is the RKS interface that assumes the alpha and beta spin densities are identical. The user must\n provide preallocated occupied molecular orbitals (size nocc x nao)\n and a preallocated output buffer (size natom × 3). The orbital basis and integration grid used are passed\n via the \\c plan . All required temporary workspace must be allocated using the size returned by\n \\c cuestNonlocalXCDerivativeRKSComputeWorkspaceQuery.\n\n \\b Precision selection. This routine can use reduced-precision \"ffloat\" compute, selected through the\n compute parameters:\n - \\c CUEST_NONLOCALXCDERIVATIVERKSCOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t):\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is available and\n expected to provide a performance advantage on the present GPU architecture.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n The \\c cuestXCIntPlanParametersFunctional_t set during plan construction does not affect this compute routine.\n @param[in] parameters \\c cuestNonlocalXCDerivativeRKSComputeParameters_t defines the details of the nonlocal XC functional.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param[in] coefficientMatrix Input coefficient matrix (size: \\c numOccupied × nao) on GPU. Must not be NULL.\n @param[out] outGradient Output buffer for computed XC gradient (size: natom × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero, or if a parameter value is invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2059pub unsafe fn cuestNonlocalXCDerivativeRKSCompute(
2060 handle: cuestHandle_t,
2061 plan: cuestXCIntPlan_t,
2062 parameters: cuestNonlocalXCDerivativeRKSComputeParameters_t,
2063 variableBufferSize: *const cuestWorkspaceDescriptor_t,
2064 temporaryWorkspace: *mut cuestWorkspace_t,
2065 numOccupied: u64,
2066 coefficientMatrix: *const f64,
2067 outGradient: *mut f64,
2068) -> cuestStatus_t {
2069 dyload_lib().cuestNonlocalXCDerivativeRKSCompute.expect(
2070 "cuEST function `cuestNonlocalXCDerivativeRKSCompute` not found in the loaded library",
2071 )(
2072 handle,
2073 plan,
2074 parameters,
2075 variableBufferSize,
2076 temporaryWorkspace,
2077 numOccupied,
2078 coefficientMatrix,
2079 outGradient,
2080 )
2081}
2082
2083#[doc = " @brief Query the temporary workspace required (in bytes) for a nonlocal XC derivative computation.\n @ingroup NonLocalCorrelationGrad\n\n This function returns the workspace needed (host/device) for a single computation,\n based on the provided plan. Only sizes are computed; output and orbital\n buffers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters \\c cuestNonlocalXCDerivativeRKSComputeParameters_t defines the details of the nonlocal XC functional.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] numOccupied Number of occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param coefficientMatrix Input coefficient matrix. May be NULL.\n @param outGradient Output buffer for computed XC gradient. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupied is zero, or if a parameter value is invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2084pub unsafe fn cuestNonlocalXCDerivativeRKSComputeWorkspaceQuery(
2085 handle: cuestHandle_t,
2086 plan: cuestXCIntPlan_t,
2087 parameters: cuestNonlocalXCDerivativeRKSComputeParameters_t,
2088 variableBufferSize: *const cuestWorkspaceDescriptor_t,
2089 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2090 numOccupied: u64,
2091 coefficientMatrix: *const f64,
2092 outGradient: *mut f64,
2093) -> cuestStatus_t {
2094 dyload_lib().cuestNonlocalXCDerivativeRKSComputeWorkspaceQuery.expect("cuEST function `cuestNonlocalXCDerivativeRKSComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, variableBufferSize, temporaryWorkspaceDescriptor, numOccupied, coefficientMatrix, outGradient)
2095}
2096
2097#[doc = " @brief Compute the derivative of the nonlocal UKS XC energy (Exc) using the supplied XC integral plan and occupied molecular orbitals.\n @ingroup NonLocalCorrelationGrad\n\n This routine computes the UKS nonlocal XC gradient from occupied molecular orbitals.\n This is the UKS interface that allows the alpha and beta spin densities to be different. The user must\n provide preallocated occupied molecular orbitals (size noccA x nao and noccB x nao)\n and preallocated output buffer (size natom × 3). The orbital basis and integration grid used are passed\n via the \\c plan . All required temporary workspace must be allocated using the size returned by\n \\c cuestNonlocalXCDerivativeUKSComputeWorkspaceQuery.\n\n Alpha and beta coefficient matrices must always be provided with non-zero numbers of occupied orbitals.\n Cases without beta (or alpha) electrons (hydrogen atom, for example), can be handled by passing in a\n coefficient matrix containing only zeros.\n\n \\b Precision selection. This routine can use reduced-precision \"ffloat\" compute, selected through the\n compute parameters:\n - \\c CUEST_NONLOCALXCDERIVATIVEUKSCOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t):\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is available and\n expected to provide a performance advantage on the present GPU architecture.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n The \\c cuestXCIntPlanParametersFunctional_t set during plan construction does not affect this compute routine.\n @param[in] parameters \\c cuestNonlocalXCDerivativeUKSComputeParameters_t defines the details of the nonlocal XC functional.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] numOccupiedAlpha Number of alpha occupied orbitals (rows in alpha coefficient matrix); must be greater than zero.\n @param[in] numOccupiedBeta Number of beta occupied orbitals (rows in beta coefficient matrix); must be greater than zero.\n @param[in] coefficientMatrixAlpha Input alpha coefficient matrix (size: \\c numOccupiedAlpha × nao) on GPU. Must not be NULL.\n @param[in] coefficientMatrixBeta Input beta coefficient matrix (size: \\c numOccupiedBeta × nao) on GPU. Must not be NULL.\n @param[out] outGradient Output buffer for computed XC gradient (size: natom × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupiedAlpha or \\c numOccupiedBeta is zero, or if a parameter value is invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2098pub unsafe fn cuestNonlocalXCDerivativeUKSCompute(
2099 handle: cuestHandle_t,
2100 plan: cuestXCIntPlan_t,
2101 parameters: cuestNonlocalXCDerivativeUKSComputeParameters_t,
2102 variableBufferSize: *const cuestWorkspaceDescriptor_t,
2103 temporaryWorkspace: *mut cuestWorkspace_t,
2104 numOccupiedAlpha: u64,
2105 numOccupiedBeta: u64,
2106 coefficientMatrixAlpha: *const f64,
2107 coefficientMatrixBeta: *const f64,
2108 outGradient: *mut f64,
2109) -> cuestStatus_t {
2110 dyload_lib().cuestNonlocalXCDerivativeUKSCompute.expect(
2111 "cuEST function `cuestNonlocalXCDerivativeUKSCompute` not found in the loaded library",
2112 )(
2113 handle,
2114 plan,
2115 parameters,
2116 variableBufferSize,
2117 temporaryWorkspace,
2118 numOccupiedAlpha,
2119 numOccupiedBeta,
2120 coefficientMatrixAlpha,
2121 coefficientMatrixBeta,
2122 outGradient,
2123 )
2124}
2125
2126#[doc = " @brief Query the temporary workspace required (in bytes) for a nonlocal XC derivative computation.\n @ingroup NonLocalCorrelationGrad\n\n This function returns the workspace needed (host/device) for a single computation,\n based on the provided plan. Only sizes are computed; output and orbital\n buffers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan XC integral plan (opaque handle) constructed with \\c cuestXCIntPlanCreate. Must not be NULL.\n @param[in] parameters \\c cuestNonlocalXCDerivativeUKSComputeParameters_t defines the details of the nonlocal XC functional.\n @param[in] variableBufferSize User-provided descriptor for the variable buffer size (host and device). Must not be NULL.\n 2 GB is a good default value for device memory. There are diminishing returns for very\n large values of the variableBufferSize. Host memory is currently unused.\n This value MUST remain unchanged between the WorkspaceQuery call and the Compute call.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param[in] numOccupiedAlpha Number of alpha occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param[in] numOccupiedBeta Number of beta occupied orbitals (rows in coefficient matrix); must be greater than zero.\n @param coefficientMatrixAlpha Input alpha coefficient matrix (size: \\c numOccupiedAlpha × nao) on GPU. May be NULL.\n @param coefficientMatrixBeta Input beta coefficient matrix (size: \\c numOccupiedBeta × nao) on GPU. May be NULL.\n @param outGradient Output buffer for computed XC gradient (size: natom × 3) on GPU. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c numOccupiedAlpha or \\c numOccupiedBeta is zero, or if a parameter value is invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2127pub unsafe fn cuestNonlocalXCDerivativeUKSComputeWorkspaceQuery(
2128 handle: cuestHandle_t,
2129 plan: cuestXCIntPlan_t,
2130 parameters: cuestNonlocalXCDerivativeUKSComputeParameters_t,
2131 variableBufferSize: *const cuestWorkspaceDescriptor_t,
2132 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2133 numOccupiedAlpha: u64,
2134 numOccupiedBeta: u64,
2135 coefficientMatrixAlpha: *const f64,
2136 coefficientMatrixBeta: *const f64,
2137 outGradient: *mut f64,
2138) -> cuestStatus_t {
2139 dyload_lib().cuestNonlocalXCDerivativeUKSComputeWorkspaceQuery.expect("cuEST function `cuestNonlocalXCDerivativeUKSComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, variableBufferSize, temporaryWorkspaceDescriptor, numOccupiedAlpha, numOccupiedBeta, coefficientMatrixAlpha, coefficientMatrixBeta, outGradient)
2140}
2141
2142#[doc = " @brief Build a PCM integral plan.\n @ingroup PCMIntegralPlan\n\n All object handles, workspaces, and output pointers must be valid (not NULL).\n Workspace buffers must be preallocated with required sizes (see workspace query).\n\n Note that for common applications of PCM the effectiveNuclearCharges are expected to be positive integers.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] intPlan One-electron integral plan handle of type \\c cuestOEIntPlan_t .\n The one-electron integral plan should be created with \\c cuestOEIntPlanCreate and\n must not be destroyed until after the final call to any PCM compute routines. Must not be NULL.\n @param[in] parameters PCM integral plan parameters structure. Must not be NULL.\n @param[in] persistentWorkspace Preallocated workspace for persistent buffers. Must not be NULL.\n @param[in] temporaryWorkspace Preallocated workspace for temporary buffers. Must not be NULL.\n @param[in] numAngularPointsPerAtom CPU array (size: number of atoms) of number of angular points per atom. Must not be NULL.\n @param[in] epsilon Dielectric constant. Must be strictly greater than 1.0.\n @param[in] zetas CPU array (size: number of atoms) with each element containing the optimized zeta\n coefficient for the number of angular points placed on that atom. Recommended values can be found in the API User Guide. All values must be positive.\n @param[in] atomicRadii CPU array (size: number of atoms) of atomic radii in bohr; all values must be positive. Must not be NULL.\n @param[in] effectiveNuclearCharges CPU array (size: number of atoms) of nuclear charges, adjusted for the presence of effective core potentials. Must not be NULL.\n @param[out] outPlan Output pointer for PCM plan handle. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any pointer argument is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c epsilon is less than or equal to 1.0, or if any of the \\c zetas or \\c atomicRadii values are invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2143pub unsafe fn cuestPCMIntPlanCreate(
2144 handle: cuestHandle_t,
2145 intPlan: cuestOEIntPlan_t,
2146 parameters: cuestPCMIntPlanParameters_t,
2147 persistentWorkspace: *mut cuestWorkspace_t,
2148 temporaryWorkspace: *mut cuestWorkspace_t,
2149 numAngularPointsPerAtom: *const u64,
2150 epsilon: f64,
2151 zetas: *const f64,
2152 atomicRadii: *const f64,
2153 effectiveNuclearCharges: *const f64,
2154 outPlan: *mut cuestPCMIntPlan_t,
2155) -> cuestStatus_t {
2156 dyload_lib()
2157 .cuestPCMIntPlanCreate
2158 .expect("cuEST function `cuestPCMIntPlanCreate` not found in the loaded library")(
2159 handle,
2160 intPlan,
2161 parameters,
2162 persistentWorkspace,
2163 temporaryWorkspace,
2164 numAngularPointsPerAtom,
2165 epsilon,
2166 zetas,
2167 atomicRadii,
2168 effectiveNuclearCharges,
2169 outPlan,
2170 )
2171}
2172
2173#[doc = " @brief Query workspace requirements for creating a PCM integral plan.\n @ingroup PCMIntegralPlan\n\n Determines persistent and temporary buffer sizes by simulating allocation logic.\n All handles and pointers must be valid (not NULL).\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] intPlan One-electron integral plan handle of type \\c cuestOEIntPlan_t .\n The one-electron integral plan should be created with \\c cuestOEIntPlanCreate and\n must not be destroyed until after the final call to any PCM compute routines. Must not be NULL.\n @param[in] parameters PCM integral plan parameters structure. Must not be NULL.\n @param[out] persistentWorkspaceDescriptor Descriptor for persistent workspace requirements. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Descriptor for temporary workspace requirements. Must not be NULL.\n @param[in] numAngularPointsPerAtom CPU array (size: number of atoms) of number of angular points per atom. Must not be NULL.\n @param[in] epsilon Dielectric constant. Must be strictly greater than 1.0.\n @param zetas CPU array with each element containing the optimized zeta coefficient for the number of angular points placed on that atom. May be NULL.\n @param atomicRadii CPU array of atomic radii in bohr. May be NULL.\n @param effectiveNuclearCharges CPU array of nuclear charges, adjusted for the presence of effective core potentials. May be NULL.\n @param outPlan Output pointer for PCM plan handle. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer argument is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c epsilon is less than or equal to 1.0;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2174pub unsafe fn cuestPCMIntPlanCreateWorkspaceQuery(
2175 handle: cuestHandle_t,
2176 intPlan: cuestOEIntPlan_t,
2177 parameters: cuestPCMIntPlanParameters_t,
2178 persistentWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2179 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2180 numAngularPointsPerAtom: *const u64,
2181 epsilon: f64,
2182 zetas: *const f64,
2183 atomicRadii: *const f64,
2184 effectiveNuclearCharges: *const f64,
2185 outPlan: *mut cuestPCMIntPlan_t,
2186) -> cuestStatus_t {
2187 dyload_lib().cuestPCMIntPlanCreateWorkspaceQuery.expect(
2188 "cuEST function `cuestPCMIntPlanCreateWorkspaceQuery` not found in the loaded library",
2189 )(
2190 handle,
2191 intPlan,
2192 parameters,
2193 persistentWorkspaceDescriptor,
2194 temporaryWorkspaceDescriptor,
2195 numAngularPointsPerAtom,
2196 epsilon,
2197 zetas,
2198 atomicRadii,
2199 effectiveNuclearCharges,
2200 outPlan,
2201 )
2202}
2203
2204#[doc = " @brief Destroy a PCM integral plan and release its resources.\n @ingroup PCMIntegralPlan\n\n Destroys the PCM integral plan and releases the resources it holds.\n All handles and pointers must be valid (not NULL).\n\n @param[in] plan PCM integral plan handle. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if the PCM integral plan handle is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the PCM integral plan handle is not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2205pub unsafe fn cuestPCMIntPlanDestroy(plan: cuestPCMIntPlan_t) -> cuestStatus_t {
2206 dyload_lib()
2207 .cuestPCMIntPlanDestroy
2208 .expect("cuEST function `cuestPCMIntPlanDestroy` not found in the loaded library")(plan)
2209}
2210
2211#[doc = " @brief Compute the PCM potential matrix using preconditioned conjugate gradient (PCG) to solve for the PCM charges.\n @ingroup PCM\n\n Guesses are obtained from the \\c inQ matrix, with the pre-allocated \\c outQ matrix used to return the converged charges.\n\n Convergence properties are controlled by configuring the \\c cuestPCMPotentialComputeParameters_t structure passed as the \\c parameters parameter.\n\n The required temporary workspace must be allocated using the sizes returned by \\c cuestPCMPotentialComputeWorkspaceQuery.\n The number of points, npoint, can be queried from the \\c cuestPCMIntPlan_t structure using the \\c CUEST_PCMINTPLAN_NUM_POINT query\n and is the sum of the \\c numAngularPointsPerAtom array used to create the plan.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_PCMPOTENTIALCOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_PCMPOTENTIALCOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is available and\n expected to provide a performance advantage on the present GPU architecture.\n - JIT-compiled kernels and ffloat compute may be combined. When JIT is enabled, ffloat compute can be used\n throughout the operation. When JIT is disabled, ffloat compute can be used only while solving for the\n PCM charges; the remainder of the operation always uses fp64 compute.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan PCM integral plan (opaque handle) constructed with \\c cuestPCMIntPlanCreate. Must not be NULL.\n @param[in] parameters PCM potential compute parameters (opaque handle) constructed with \\c cuestParametersCreate. Must not be NULL.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] densityMatrix Total (alpha + beta) AO basis density matrix (size: nao × nao) on the GPU. Must not be NULL.\n @param[in] inQ Input guess Q vector (size: npoint) on the GPU; user should initialize this array to zeros if no guess is available. Must not be NULL.\n @param[out] outQ Output Q matrix (size: npoint) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n @param[out] outPCMResults PCM results (opaque handle) constructed with \\c cuestResultsCreate. Must not be NULL.\n Elements contained in this handle are overwritten by the calculation results.\n @param[out] outPCMPotentialMatrix Output PCM potential matrix (size: nao × nao) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n Note that the return status is \\c CUEST_STATUS_SUCCESS even if the PCM charges did not converge within the maximum number of iterations provided by the \\c parameters.\n The caller should check the \\c converged member of the \\c outPCMResults handle to determine if the PCM charges converged.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success, including the case where the PCM charges did not converge within the maximum number of iterations provided by the \\c parameters;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if the \\c parameters are configured to have convergence threshold less than or equal to zero;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, or if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2212pub unsafe fn cuestPCMPotentialCompute(
2213 handle: cuestHandle_t,
2214 plan: cuestPCMIntPlan_t,
2215 parameters: cuestPCMPotentialComputeParameters_t,
2216 temporaryWorkspace: *mut cuestWorkspace_t,
2217 densityMatrix: *const f64,
2218 inQ: *const f64,
2219 outQ: *mut f64,
2220 outPCMResults: cuestPCMResults_t,
2221 outPCMPotentialMatrix: *mut f64,
2222) -> cuestStatus_t {
2223 dyload_lib()
2224 .cuestPCMPotentialCompute
2225 .expect("cuEST function `cuestPCMPotentialCompute` not found in the loaded library")(
2226 handle,
2227 plan,
2228 parameters,
2229 temporaryWorkspace,
2230 densityMatrix,
2231 inQ,
2232 outQ,
2233 outPCMResults,
2234 outPCMPotentialMatrix,
2235 )
2236}
2237
2238#[doc = " @brief Query the temporary workspace required for a PCM potential computation.\n @ingroup PCM\n\n This function calculates the memory required for a PCM potential computation,\n returning host/device workspace buffer sizes in the output descriptor. The user arrays \\c densityMatrix, \\c inQ, \\c outQ, \\c outPCMResults, and \\c outPCMPotentialMatrix may be NULL.\n All parameters and object handles must be valid.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_PCMPOTENTIALCOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_PCMPOTENTIALCOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is available and\n expected to provide a performance advantage on the present GPU architecture.\n - JIT-compiled kernels and ffloat compute may be combined. When JIT is enabled, ffloat compute can be used\n throughout the operation. When JIT is disabled, ffloat compute can be used only while solving for the\n PCM charges; the remainder of the operation always uses fp64 compute.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan PCM integral plan constructed with \\c cuestPCMIntPlanCreate. Must not be NULL.\n @param[in] parameters PCM potential compute parameters constructed with \\c cuestParametersCreate. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param densityMatrix Density matrix. May be NULL.\n @param inQ Input Q matrix. May be NULL.\n @param outQ Output Q matrix. May be NULL.\n @param outPCMResults PCM results constructed with \\c cuestResultsCreate. May be NULL.\n @param outPCMPotentialMatrix Output PCM potential matrix. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if the \\c parameters are configured to have convergence threshold less than or equal to zero;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, or if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2239pub unsafe fn cuestPCMPotentialComputeWorkspaceQuery(
2240 handle: cuestHandle_t,
2241 plan: cuestPCMIntPlan_t,
2242 parameters: cuestPCMPotentialComputeParameters_t,
2243 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2244 densityMatrix: *const f64,
2245 inQ: *const f64,
2246 outQ: *mut f64,
2247 outPCMResults: cuestPCMResults_t,
2248 outPCMPotentialMatrix: *mut f64,
2249) -> cuestStatus_t {
2250 dyload_lib().cuestPCMPotentialComputeWorkspaceQuery.expect(
2251 "cuEST function `cuestPCMPotentialComputeWorkspaceQuery` not found in the loaded library",
2252 )(
2253 handle,
2254 plan,
2255 parameters,
2256 temporaryWorkspaceDescriptor,
2257 densityMatrix,
2258 inQ,
2259 outQ,
2260 outPCMResults,
2261 outPCMPotentialMatrix,
2262 )
2263}
2264
2265#[doc = " @brief Compute the PCM nuclear gradient.\n @ingroup PCM\n\n This routine computes the derivative of the PCM energy with respect to nuclear coordinates.\n\n Converged surface charges are computed using a preconditioned conjugate gradient (PCG) solver.\n Convergence behavior is controlled by the \\c cuestPCMDerivativeComputeParameters_t structure that is packaged inside \\c parameters.\n Both maximum iterations and convergence threshold may be tuned based on the specific problem.\n\n The required temporary workspace must be allocated using the sizes returned by \\c cuestPCMDerivativeComputeWorkspaceQuery.\n The number of points, npoint, can be queried from the \\c cuestPCMIntPlan_t structure using the \\c CUEST_PCMINTPLAN_NUM_POINT query,\n and is the sum of the \\c numAngularPointsPerAtom array used to create the plan.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_PCMDERIVATIVECOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_PCMDERIVATIVECOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is available and\n expected to provide a performance advantage on the present GPU architecture.\n - JIT-compiled kernels and ffloat compute may be combined. When JIT is enabled, ffloat compute can be used\n throughout the operation. When JIT is disabled, ffloat compute can be used only while solving for the\n PCM charges; the remainder of the operation always uses fp64 compute.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan PCM integral plan (opaque handle) constructed with \\c cuestPCMIntPlanCreate. Must not be NULL.\n @param[in] parameters PCM derivative parameters (opaque handle) constructed with \\c cuestParametersCreate. Must not be NULL.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] densityMatrix Total (alpha + beta) AO basis density matrix (size: nao × nao) on the GPU. Must not be NULL.\n @param[in] inQ Input guess charges (size: npoint) on the GPU; user should initialize this array to zeros if no guess is available. Must not be NULL.\n @param[out] outQ Converged charges (size: npoint) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n @param[out] outPCMResults PCM results (opaque handle) constructed with \\c cuestResultsCreate. Must not be NULL.\n Elements contained in this handle are overwritten by the calculation results.\n @param[out] outPCMGradient Output PCM derivative (size: natoms × 3) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n It is important to note that the return status is \\c CUEST_STATUS_SUCCESS even if the PCM charges did not converge within the maximum number of iterations provided by \\c parameters.\n The caller should check the \\c converged member of the \\c outPCMResults handle to determine whether the PCM charges returned by \\c outQ are converged.\n\n In the case where \\c maxIterations==0 , no PCG updates of the charges are performed.\n The values provided in \\c inQ are used to evaluate the PCM gradient, and are copied to \\c outQ on return.\n In this mode, a residual is still evaluated and reported through \\c outPCMResults, but the charges themselves are not modified.\n\n Similarly, if the PCG procedure reaches the maximum number of iterations without satisfying the requested\n convergence threshold, the gradient is still computed using the resulting (partially converged) charges.\n It is the caller’s responsibility to inspect the convergence information in \\c outPCMResults and decide whether the result is acceptable.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success, including the case where the PCM charges did not converge within the maximum number of iterations provided by the \\c parameters;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type; including \\c parameters;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if the \\c parameters are configured to have convergence threshold less than or equal to zero;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, or if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2266pub unsafe fn cuestPCMDerivativeCompute(
2267 handle: cuestHandle_t,
2268 plan: cuestPCMIntPlan_t,
2269 parameters: cuestPCMDerivativeComputeParameters_t,
2270 temporaryWorkspace: *mut cuestWorkspace_t,
2271 densityMatrix: *const f64,
2272 inQ: *const f64,
2273 outQ: *mut f64,
2274 outPCMResults: cuestPCMResults_t,
2275 outPCMGradient: *mut f64,
2276) -> cuestStatus_t {
2277 dyload_lib()
2278 .cuestPCMDerivativeCompute
2279 .expect("cuEST function `cuestPCMDerivativeCompute` not found in the loaded library")(
2280 handle,
2281 plan,
2282 parameters,
2283 temporaryWorkspace,
2284 densityMatrix,
2285 inQ,
2286 outQ,
2287 outPCMResults,
2288 outPCMGradient,
2289 )
2290}
2291
2292#[doc = " @brief Query the temporary workspace required for a PCM gradient computation.\n @ingroup PCM\n\n Calculate the memory required for a PCM gradient computation, including the PCG solve for charges,\n returning host/device workspace buffer sizes in the output descriptor. The user arrays \\c densityMatrix, \\c inQ,\n \\c outQ, \\c outPCMResults, and \\c outPCMGradient may be NULL. All parameters and object handles must be valid.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_PCMDERIVATIVECOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_PCMDERIVATIVECOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is available and\n expected to provide a performance advantage on the present GPU architecture.\n - JIT-compiled kernels and ffloat compute may be combined. When JIT is enabled, ffloat compute can be used\n throughout the operation. When JIT is disabled, ffloat compute can be used only while solving for the\n PCM charges; the remainder of the operation always uses fp64 compute.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan PCM integral plan constructed with \\c cuestPCMIntPlanCreate. Must not be NULL.\n @param[in] parameters PCM derivative parameters constructed with \\c cuestParametersCreate. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param densityMatrix Density matrix. May be NULL.\n @param inQ Input Q vector. May be NULL.\n @param outQ Output Q vector. May be NULL.\n @param outPCMResults PCM results constructed with \\c cuestResultsCreate. May be NULL.\n @param outPCMGradient Output PCM nuclear gradient. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type; including \\c parameters;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if the \\c parameters are configured to have convergence threshold less than or equal to zero;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, or if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2293pub unsafe fn cuestPCMDerivativeComputeWorkspaceQuery(
2294 handle: cuestHandle_t,
2295 plan: cuestPCMIntPlan_t,
2296 parameters: cuestPCMDerivativeComputeParameters_t,
2297 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2298 densityMatrix: *const f64,
2299 inQ: *const f64,
2300 outQ: *mut f64,
2301 outPCMResults: cuestPCMResults_t,
2302 outPCMGradient: *mut f64,
2303) -> cuestStatus_t {
2304 dyload_lib().cuestPCMDerivativeComputeWorkspaceQuery.expect(
2305 "cuEST function `cuestPCMDerivativeComputeWorkspaceQuery` not found in the loaded library",
2306 )(
2307 handle,
2308 plan,
2309 parameters,
2310 temporaryWorkspaceDescriptor,
2311 densityMatrix,
2312 inQ,
2313 outQ,
2314 outPCMResults,
2315 outPCMGradient,
2316 )
2317}
2318
2319#[doc = " @brief Compute the PCM gradient with respect to the atomic (cavity) radii.\n @ingroup PCM\n\n This routine computes the derivative of the PCM energy with respect to each atomic cavity radius\n (the quantity needed by radius-rescaling solvent models such as DRACO), holding the electron density fixed.\n\n Converged surface charges are computed using a preconditioned conjugate gradient (PCG) solver.\n Convergence behavior is controlled by the \\c cuestPCMRadiiDerivativeComputeParameters_t structure that is packaged inside \\c parameters.\n Both maximum iterations and convergence threshold may be tuned based on the specific problem.\n\n The required temporary workspace must be allocated using the sizes returned by \\c cuestPCMRadiiDerivativeComputeWorkspaceQuery.\n The number of points, npoint, can be queried from the \\c cuestPCMIntPlan_t structure using the \\c CUEST_PCMINTPLAN_NUM_POINT query,\n and is the sum of the \\c numAngularPointsPerAtom array used to create the plan.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_PCMRADIIDERIVATIVECOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_PCMRADIIDERIVATIVECOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is available and\n expected to provide a performance advantage on the present GPU architecture.\n - JIT-compiled kernels and ffloat compute may be combined. When JIT is enabled, ffloat compute can be used\n throughout the operation. When JIT is disabled, ffloat compute can be used only while solving for the\n PCM charges; the remainder of the operation always uses fp64 compute.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan PCM integral plan (opaque handle) constructed with \\c cuestPCMIntPlanCreate. Must not be NULL.\n @param[in] parameters PCM radii derivative parameters (opaque handle) constructed with \\c cuestParametersCreate. Must not be NULL.\n @param[in] temporaryWorkspace Temporary workspace buffer for this operation. Must not be NULL.\n @param[in] densityMatrix Total (alpha + beta) AO basis density matrix (size: nao × nao) on the GPU. Must not be NULL.\n @param[in] inQ Input guess charges (size: npoint) on the GPU; user should initialize this array to zeros if no guess is available. Must not be NULL.\n @param[out] outQ Converged charges (size: npoint) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n @param[out] outPCMResults PCM results (opaque handle) constructed with \\c cuestResultsCreate. Must not be NULL.\n Elements contained in this handle are overwritten by the calculation results.\n @param[out] outPCMRadiiGradient Output PCM radii derivative (size: natoms) on the GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n It is important to note that the return status is \\c CUEST_STATUS_SUCCESS even if the PCM charges did not converge within the maximum number of iterations provided by \\c parameters.\n The caller should check the \\c converged member of the \\c outPCMResults handle to determine whether the PCM charges returned by \\c outQ are converged.\n\n In the case where \\c maxIterations==0 , no PCG updates of the charges are performed.\n The values provided in \\c inQ are used to evaluate the PCM radii gradient, and are copied to \\c outQ on return.\n In this mode, a residual is still evaluated and reported through \\c outPCMResults, but the charges themselves are not modified.\n\n Similarly, if the PCG procedure reaches the maximum number of iterations without satisfying the requested\n convergence threshold, the gradient is still computed using the resulting (partially converged) charges.\n It is the caller’s responsibility to inspect the convergence information in \\c outPCMResults and decide whether the result is acceptable.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success, including the case where the PCM charges did not converge within the maximum number of iterations provided by the \\c parameters;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type; including \\c parameters;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if the \\c parameters are configured to have convergence threshold less than or equal to zero;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, or if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2320pub unsafe fn cuestPCMRadiiDerivativeCompute(
2321 handle: cuestHandle_t,
2322 plan: cuestPCMIntPlan_t,
2323 parameters: cuestPCMRadiiDerivativeComputeParameters_t,
2324 temporaryWorkspace: *mut cuestWorkspace_t,
2325 densityMatrix: *const f64,
2326 inQ: *const f64,
2327 outQ: *mut f64,
2328 outPCMResults: cuestPCMResults_t,
2329 outPCMRadiiGradient: *mut f64,
2330) -> cuestStatus_t {
2331 dyload_lib()
2332 .cuestPCMRadiiDerivativeCompute
2333 .expect("cuEST function `cuestPCMRadiiDerivativeCompute` not found in the loaded library")(
2334 handle,
2335 plan,
2336 parameters,
2337 temporaryWorkspace,
2338 densityMatrix,
2339 inQ,
2340 outQ,
2341 outPCMResults,
2342 outPCMRadiiGradient,
2343 )
2344}
2345
2346#[doc = " @brief Query the temporary workspace required for a PCM radii gradient computation.\n @ingroup PCM\n\n Calculate the memory required for a PCM radii gradient computation, including the PCG solve for charges,\n returning host/device workspace buffer sizes in the output descriptor. The user arrays \\c densityMatrix, \\c inQ,\n \\c outQ, \\c outPCMResults, and \\c outPCMRadiiGradient may be NULL. All parameters and object handles must be valid.\n\n \\b Kernel and precision selection. This routine can use JIT-compiled kernels and/or reduced-precision\n \"ffloat\" compute, selected through the compute parameters:\n - \\c CUEST_PCMRADIIDERIVATIVECOMPUTE_PARAMETERS_JIT_USAGE_MODE (\\c cuestJITUsageMode_t): \\c CUEST_JIT_USAGE_MODE_ON\n uses JIT-compiled kernels, \\c CUEST_JIT_USAGE_MODE_OFF uses AOT-compiled kernels. JIT-compiled kernels\n are only available in the cuEST CUDA 13 package; the default is \\c CUEST_JIT_USAGE_MODE_ON in the\n cuEST CUDA 13 package and \\c CUEST_JIT_USAGE_MODE_OFF in the cuEST CUDA 12 package. Requesting\n \\c CUEST_JIT_USAGE_MODE_ON with the cuEST CUDA 12 package returns \\c CUEST_STATUS_INVALID_ARGUMENT.\n - \\c CUEST_PCMRADIIDERIVATIVECOMPUTE_PARAMETERS_FFLOAT_USAGE_MODE (\\c cuestFfloatUsageMode_t) selects the compute precision:\n \\c CUEST_FFLOAT_USAGE_MODE_ON requests ffloat compute, \\c CUEST_FFLOAT_USAGE_MODE_OFF requests fp64\n compute, and \\c CUEST_FFLOAT_USAGE_MODE_DEFAULT requests ffloat compute when it is available and\n expected to provide a performance advantage on the present GPU architecture.\n - JIT-compiled kernels and ffloat compute may be combined. When JIT is enabled, ffloat compute can be used\n throughout the operation. When JIT is disabled, ffloat compute can be used only while solving for the\n PCM charges; the remainder of the operation always uses fp64 compute.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan PCM integral plan constructed with \\c cuestPCMIntPlanCreate. Must not be NULL.\n @param[in] parameters PCM radii derivative parameters constructed with \\c cuestParametersCreate. Must not be NULL.\n @param[out] temporaryWorkspaceDescriptor Output descriptor for temporary workspace sizes. Must not be NULL.\n @param densityMatrix Density matrix. May be NULL.\n @param inQ Input Q vector. May be NULL.\n @param outQ Output Q vector. May be NULL.\n @param outPCMResults PCM results constructed with \\c cuestResultsCreate. May be NULL.\n @param outPCMRadiiGradient Output PCM radii gradient. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type; including \\c parameters;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if the \\c parameters are configured to have convergence threshold less than or equal to zero;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if a parameter value is invalid, or if JIT-compiled kernels are requested\n with the cuEST CUDA 12 package;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2347pub unsafe fn cuestPCMRadiiDerivativeComputeWorkspaceQuery(
2348 handle: cuestHandle_t,
2349 plan: cuestPCMIntPlan_t,
2350 parameters: cuestPCMRadiiDerivativeComputeParameters_t,
2351 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2352 densityMatrix: *const f64,
2353 inQ: *const f64,
2354 outQ: *mut f64,
2355 outPCMResults: cuestPCMResults_t,
2356 outPCMRadiiGradient: *mut f64,
2357) -> cuestStatus_t {
2358 dyload_lib().cuestPCMRadiiDerivativeComputeWorkspaceQuery.expect("cuEST function `cuestPCMRadiiDerivativeComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, densityMatrix, inQ, outQ, outPCMResults, outPCMRadiiGradient)
2359}
2360
2361#[doc = " @brief Compute PCM integration grid point coordinates.\n @ingroup PCMAdvanced\n @since v0.2.0\n\n This routine retrieves the Cartesian coordinates of each molecular grid point\n used to define the PCM cavity surface. These are the grid points used\n by the corresponding PCM integral plan.\n\n The resulting coordinates are written to a user-provided output buffer\n of shape (\\c npoint × 3), containing the x, y, z coordinates of each grid point.\n\n Temporary device workspace must be preallocated based on the size returned by\n \\c cuestPCMIntegrationGridComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan PCM integral plan (opaque handle) constructed with \\c cuestPCMIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestPCMIntegrationGridComputeParameters_t) Must not be NULL\n @param[in] temporaryWorkspace Preallocated GPU workspace buffer. Must not be NULL.\n @param[out] outGridPoints Output buffer for computed grid point coordinates (size: \\c npoint × 3) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the handle, plan, or parameters type is incorrect;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2362pub unsafe fn cuestPCMIntegrationGridCompute(
2363 handle: cuestHandle_t,
2364 plan: cuestPCMIntPlan_t,
2365 parameters: cuestPCMIntegrationGridComputeParameters_t,
2366 temporaryWorkspace: *mut cuestWorkspace_t,
2367 outGridPoints: *mut f64,
2368) -> cuestStatus_t {
2369 dyload_lib()
2370 .cuestPCMIntegrationGridCompute
2371 .expect("cuEST function `cuestPCMIntegrationGridCompute` not found in the loaded library")(
2372 handle,
2373 plan,
2374 parameters,
2375 temporaryWorkspace,
2376 outGridPoints,
2377 )
2378}
2379
2380#[doc = " @brief Query temporary workspace requirements for PCM grid coordinate computation.\n @ingroup PCMAdvanced\n @since v0.2.0\n\n Determines the GPU memory workspace needed to generate the coordinates\n of molecular integration grid points defined by the provided PCM integral plan.\n This function must be called before \\c cuestPCMIntegrationGridCompute to ensure sufficient allocation.\n\n Only workspace sizes are computed; input and output pointers may be NULL.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan PCM integral plan (opaque handle) constructed with \\c cuestPCMIntPlanCreate. Must not be NULL.\n @param[in] parameters Compute parameters (\\c cuestPCMIntegrationGridComputeParameters_t) Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for required workspace sizes (in bytes). Must not be NULL.\n @param outGridPoints Output array for grid point coordinates. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the handle, plan, or parameters type is incorrect;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2381pub unsafe fn cuestPCMIntegrationGridComputeWorkspaceQuery(
2382 handle: cuestHandle_t,
2383 plan: cuestPCMIntPlan_t,
2384 parameters: cuestPCMIntegrationGridComputeParameters_t,
2385 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2386 outGridPoints: *mut f64,
2387) -> cuestStatus_t {
2388 dyload_lib().cuestPCMIntegrationGridComputeWorkspaceQuery.expect("cuEST function `cuestPCMIntegrationGridComputeWorkspaceQuery` not found in the loaded library")(handle, plan, parameters, temporaryWorkspaceDescriptor, outGridPoints)
2389}
2390
2391#[doc = " @brief Compute molecular integration weights for PCM quadrature.\n @ingroup PCMAdvanced\n @since v0.2.0\n\n This routine computes the integration weights associated with each grid point\n in the molecular integration grid used for PCM integration.\n The weights returned depend on the selected weight type, specified by \\c weightType.\n\n Supported weighting schemes include:\n - \\c CUEST_PCMINTEGRATIONWEIGHT_PARAMETERS_WEIGHTTYPE_SWITCHING — value of the iSWIG switching function;\n - \\c CUEST_PCMINTEGRATIONWEIGHT_PARAMETERS_WEIGHTTYPE_ZETA — value of zeta at the grid point.\n\n The result is written to \\c outGridWeights (size: \\c npoint × 1).\n Temporary workspace must be preallocated based on\n \\c cuestPCMIntegrationWeightComputeWorkspaceQuery.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan PCM integral plan (opaque handle) constructed with \\c cuestPCMIntPlanCreate. Must not be NULL.\n @param[in] weightType Weight type to return (switching function value or zeta).\n @param[in] parameters Compute parameters (\\c cuestPCMIntegrationWeightComputeParameters_t) Must not be NULL\n @param[in] temporaryWorkspace Preallocated GPU workspace buffer for temporary data. Must not be NULL.\n @param[out] outGridWeights Output buffer for integration weights (size: \\c npoint × 1) on GPU. Must not be NULL.\n Elements of this array are overwritten by the calculation results.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the handle, plan, or parameters type is invalid;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c weightType is unrecognized;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2392pub unsafe fn cuestPCMIntegrationWeightCompute(
2393 handle: cuestHandle_t,
2394 plan: cuestPCMIntPlan_t,
2395 weightType: cuestPCMIntegrationWeightComputeParametersWeightType_t,
2396 parameters: cuestPCMIntegrationWeightComputeParameters_t,
2397 temporaryWorkspace: *mut cuestWorkspace_t,
2398 outGridWeights: *mut f64,
2399) -> cuestStatus_t {
2400 dyload_lib()
2401 .cuestPCMIntegrationWeightCompute
2402 .expect("cuEST function `cuestPCMIntegrationWeightCompute` not found in the loaded library")(
2403 handle,
2404 plan,
2405 weightType,
2406 parameters,
2407 temporaryWorkspace,
2408 outGridWeights,
2409 )
2410}
2411
2412#[doc = " @brief Query the temporary workspace required (in bytes) for computing PCM integration weights.\n @ingroup PCMAdvanced\n @since v0.2.0\n\n Determines GPU memory workspace requirements to compute integration weights\n on the molecular grid as defined by the provided PCM integral plan. The required\n workspace depends on the grid structure and selected weight type.\n\n This query should be executed before calling \\c cuestPCMIntegrationWeightCompute\n to ensure that sufficient device memory is available.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] plan PCM integral plan (opaque handle) constructed with \\c cuestPCMIntPlanCreate. Must not be NULL.\n @param[in] weightType Weight type to return (switching function value or zeta).\n @param[in] parameters Compute parameters (\\c cuestPCMIntegrationWeightComputeParameters_t) Must not be NULL\n @param[out] temporaryWorkspaceDescriptor Output descriptor for required temporary workspace sizes (in bytes). Must not be NULL.\n @param outGridWeights Optional output buffer for computed weights. May be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if the handle, plan, or parameters type is incorrect;\n - \\c CUEST_STATUS_INVALID_ARGUMENT if \\c weightType is unsupported;\n - \\c CUEST_STATUS_EXCEPTION on device or internal error;\n - \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2413pub unsafe fn cuestPCMIntegrationWeightComputeWorkspaceQuery(
2414 handle: cuestHandle_t,
2415 plan: cuestPCMIntPlan_t,
2416 weightType: cuestPCMIntegrationWeightComputeParametersWeightType_t,
2417 parameters: cuestPCMIntegrationWeightComputeParameters_t,
2418 temporaryWorkspaceDescriptor: *mut cuestWorkspaceDescriptor_t,
2419 outGridWeights: *mut f64,
2420) -> cuestStatus_t {
2421 dyload_lib().cuestPCMIntegrationWeightComputeWorkspaceQuery.expect("cuEST function `cuestPCMIntegrationWeightComputeWorkspaceQuery` not found in the loaded library")(handle, plan, weightType, parameters, temporaryWorkspaceDescriptor, outGridWeights)
2422}
2423
2424#[doc = " @brief Query an attribute of a cuEST opaque handle.\n @ingroup Query\n\n The result pointer \\c attributeValue must reference sufficient memory for the type matching the specified attribute.\n Note that char* attributes are allocated internally and must be freed by the caller using free(). This allocation\n only occurs when the function completes successfully (returns \\c CUEST_STATUS_SUCCESS). On any error status no\n allocation is made and \\c attributeValue is left unchanged — cuEST never writes to it on a failing path — so a\n caller that pre-initializes \\c attributeValue (e.g. to \\c NULL) can rely on that value afterward for a\n deterministic cleanup pattern, and there is nothing to free.\n\n @param[in] handle cuEST handle. Must not be NULL.\n @param[in] type enum indicating which type of object is being queried\n @param[in] object cuEST object to be queried (opaque handle). Must not be NULL.\n @param[in] attribute Attribute/property to query. (Should be an enum appropriate to the type of object.)\n @param[out] attributeValue Pointer to memory for result (type depends on attribute). Must not be NULL.\n @param[in] attributeValueSize Number of bytes in \\c attributeValue. Must match sizeof(type).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_INVALID_HANDLE if the cuEST handle is NULL;\n - \\c CUEST_STATUS_NULL_POINTER if \\c object or \\c attributeValue is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if \\c object is not of the specified \\c type;\n - \\c CUEST_STATUS_INVALID_SIZE if \\c attributeValueSize does not match \\c attribute type size;\n - \\c CUEST_STATUS_INVALID_ATTRIBUTE if \\c attribute is not recognized;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR for internal errors."]
2425pub unsafe fn cuestQuery(
2426 handle: cuestHandle_t,
2427 type_: cuestType_t,
2428 object: *const c_void,
2429 attribute: c_int,
2430 attributeValue: *mut c_void,
2431 attributeValueSize: usize,
2432) -> cuestStatus_t {
2433 dyload_lib().cuestQuery.expect("cuEST function `cuestQuery` not found in the loaded library")(
2434 handle,
2435 type_,
2436 object,
2437 attribute,
2438 attributeValue,
2439 attributeValueSize,
2440 )
2441}
2442
2443#[doc = " @brief Create a new cuEST results object of the specified type.\n @ingroup Results\n\n Allocates and initializes an opaque results object of the type specified by \\c resultsType.\n The created object is returned via \\c outResults and must be destroyed with \\c cuestResultsDestroy.\n\n @param[in] resultsType Type of results object to create (see \\c cuestResultsType_t).\n @param[out] outResults Pointer to receive allocated opaque results handle. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c outResults is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if \\c resultsType is invalid;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR for internal errors.\n\n @note On error, \\c *outResults is set to NULL."]
2444pub unsafe fn cuestResultsCreate(
2445 resultsType: cuestResultsType_t,
2446 outResults: *mut *mut c_void,
2447) -> cuestStatus_t {
2448 dyload_lib()
2449 .cuestResultsCreate
2450 .expect("cuEST function `cuestResultsCreate` not found in the loaded library")(
2451 resultsType,
2452 outResults,
2453 )
2454}
2455
2456#[doc = " @brief Destroy and free a cuEST results object of the specified type.\n @ingroup Results\n\n Properly deallocates and cleans up resources for a results handle created by \\c cuestResultsCreate.\n\n @param[in] resultsType Type of results object (must match creation).\n @param[in] results Opaque results handle to destroy; must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c results is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if \\c resultsType does not match the actual type of \\c results;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR for internal errors."]
2457pub unsafe fn cuestResultsDestroy(
2458 resultsType: cuestResultsType_t,
2459 results: *mut c_void,
2460) -> cuestStatus_t {
2461 dyload_lib()
2462 .cuestResultsDestroy
2463 .expect("cuEST function `cuestResultsDestroy` not found in the loaded library")(
2464 resultsType,
2465 results,
2466 )
2467}
2468
2469#[doc = " @brief Query the value of a given attribute from a cuEST results object.\n @ingroup Results\n\n Retrieves the value associated with an attribute for the given \\c results object. The type and meaning\n of \\c results and \\c resultValue depend on \\c resultsType. The result is placed in \\c resultValue, whose\n size must match the expected value size.\n\n @param[in] resultsType Type of results object being queried.\n @param[in] results Opaque handle of the results object (must not be NULL).\n @param[in] attribute Integer attribute identifier (cast to appropriate attribute enum internally).\n @param[out] resultValue Destination for the queried value (must not be NULL).\n @param[in] resultValueSize Size in bytes of \\c resultValue buffer (must match queried type).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if \\c results or \\c resultValue is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if \\c results is not of the specified \\c resultsType;\n - \\c CUEST_STATUS_INVALID_SIZE if \\c resultValueSize does not match attribute type size;\n - \\c CUEST_STATUS_INVALID_ATTRIBUTE if \\c attribute is not recognized;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR for internal errors."]
2470pub unsafe fn cuestResultsQuery(
2471 resultsType: cuestResultsType_t,
2472 results: *const c_void,
2473 attribute: c_int,
2474 resultValue: *mut c_void,
2475 resultValueSize: usize,
2476) -> cuestStatus_t {
2477 dyload_lib()
2478 .cuestResultsQuery
2479 .expect("cuEST function `cuestResultsQuery` not found in the loaded library")(
2480 resultsType,
2481 results,
2482 attribute,
2483 resultValue,
2484 resultValueSize,
2485 )
2486}
2487
2488#[doc = " @brief Create a new cuEST parameters object of the specified type.\n @ingroup Parameters\n\n Allocates and initializes an opaque parameter object of the type specified by \\c parameterType.\n The created object is returned via \\c outParameters and must be destroyed with \\c cuestParametersDestroy.\n\n @param[in] parameterType Type of parameters object to create (see \\c cuestParametersType_t).\n @param[out] outParameters Pointer to receive allocated opaque parameters handle. Must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if \\c parameterType is not a valid parameters type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2489pub unsafe fn cuestParametersCreate(
2490 parameterType: cuestParametersType_t,
2491 outParameters: *mut *mut c_void,
2492) -> cuestStatus_t {
2493 dyload_lib()
2494 .cuestParametersCreate
2495 .expect("cuEST function `cuestParametersCreate` not found in the loaded library")(
2496 parameterType,
2497 outParameters,
2498 )
2499}
2500
2501#[doc = " @brief Destroy and free a cuEST parameters object of the specified type.\n @ingroup Parameters\n\n Properly deallocates and cleans up resources for a parameters handle created by \\c cuestParametersCreate.\n\n @param[in] parameterType Type of parameters object (must match creation).\n @param[in] parameters Opaque parameters handle to destroy; must not be NULL.\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2502pub unsafe fn cuestParametersDestroy(
2503 parameterType: cuestParametersType_t,
2504 parameters: *mut c_void,
2505) -> cuestStatus_t {
2506 dyload_lib()
2507 .cuestParametersDestroy
2508 .expect("cuEST function `cuestParametersDestroy` not found in the loaded library")(
2509 parameterType,
2510 parameters,
2511 )
2512}
2513
2514#[doc = " @brief Query the value of a given attribute from a cuEST parameters object.\n @ingroup Parameters\n\n Retrieves the value associated with an attribute for the given \\c parameters object. The type and meaning\n of \\c attribute and \\c attributeValue depend on \\c parameterType. The result is placed in \\c attributeValue, whose\n size must match the expected value size.\n\n For string-valued attributes (e.g. \\c CUEST_HANDLE_PARAMETERS_JIT_CACHE_DIR, queried as a\n \\c char*), cuEST allocates the returned, NUL-terminated buffer with C's \\c malloc and the caller\n owns it: it must be released with C's native \\c free(). This allocation only occurs when the\n function completes successfully (returns \\c CUEST_STATUS_SUCCESS). On any error status no\n allocation is made and \\c attributeValue is left unchanged — cuEST never writes to it on a\n failing path — so a caller that pre-initializes \\c attributeValue (e.g. to \\c NULL) can rely on\n that value afterward for a deterministic cleanup pattern, and there is nothing to free.\n\n @param[in] parameterType Type of parameters object being queried.\n @param[in] parameters Opaque handle of the parameters object (must not be NULL).\n @param[in] attribute Integer attribute identifier (cast to appropriate attribute enum internally).\n @param[out] attributeValue Destination for the queried value (must not be NULL).\n @param[in] attributeValueSize Size in bytes of \\c attributeValue buffer (must match queried type).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_SIZE if \\c attributeValueSize does not match the attribute type size;\n - \\c CUEST_STATUS_INVALID_PARAMETER if the \\c attribute is not valid for the given \\c parameterType;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2515pub unsafe fn cuestParametersQuery(
2516 parameterType: cuestParametersType_t,
2517 parameters: *const c_void,
2518 attribute: c_int,
2519 attributeValue: *mut c_void,
2520 attributeValueSize: usize,
2521) -> cuestStatus_t {
2522 dyload_lib()
2523 .cuestParametersQuery
2524 .expect("cuEST function `cuestParametersQuery` not found in the loaded library")(
2525 parameterType,
2526 parameters,
2527 attribute,
2528 attributeValue,
2529 attributeValueSize,
2530 )
2531}
2532
2533#[doc = " @brief Configure the value of a given attribute for a cuEST parameters object.\n @ingroup Parameters\n\n Sets or updates the value of an attribute for the given \\c parameters object. The type and semantics\n of the \\c attribute and \\c attributeValue depend on \\c parameterType. The input value is provided as a pointer,\n and its size must match the expected storage for the attribute.\n\n @param[in] parameterType Type of parameters object to configure.\n @param[in,out] parameters Opaque handle to parameters object (must not be NULL).\n @param[in] attribute Integer attribute identifier (cast to appropriate attribute enum internally).\n @param[in] attributeValue Pointer to the new value (must not be NULL).\n @param[in] attributeValueSize Size in bytes of \\c attributeValue (must match attribute type).\n\n @return\n - \\c CUEST_STATUS_SUCCESS on success;\n - \\c CUEST_STATUS_NULL_POINTER if any required pointer is NULL;\n - \\c CUEST_STATUS_INVALID_TYPE if opaque handles are not the correct type;\n - \\c CUEST_STATUS_INVALID_SIZE if \\c attributeValueSize does not match the attribute type size;\n - \\c CUEST_STATUS_INVALID_PARAMETER if the \\c attribute is not valid for the given \\c parameterType;\n - \\c CUEST_STATUS_EXCEPTION or \\c CUEST_STATUS_UNKNOWN_ERROR otherwise."]
2534pub unsafe fn cuestParametersConfigure(
2535 parameterType: cuestParametersType_t,
2536 parameters: *mut c_void,
2537 attribute: c_int,
2538 attributeValue: *const c_void,
2539 attributeValueSize: usize,
2540) -> cuestStatus_t {
2541 dyload_lib()
2542 .cuestParametersConfigure
2543 .expect("cuEST function `cuestParametersConfigure` not found in the loaded library")(
2544 parameterType,
2545 parameters,
2546 attribute,
2547 attributeValue,
2548 attributeValueSize,
2549 )
2550}