Skip to main content

DFTD4Param

Struct DFTD4Param 

Source
pub struct DFTD4Param { /* private fields */ }
Expand description

Basic struct for damping parameters, representing a parametrization of a DFT-D4 method.

The damping parameters contained in the object are immutable. To change the parametrization, a new object must be created. Furthermore, the object is opaque to the user and the contained data cannot be accessed directly.

Implementations§

Source§

impl DFTD4Param

Source

pub fn new_rational_damping( s6: f64, s8: f64, s9: f64, a1: f64, a2: f64, alp: f64, ) -> Self

Create new damping parameters.

The parameters are:

  • s6 - Scaling factor for C6 contribution
  • s8 - Scaling factor for C8 contribution
  • s9 - Scaling factor for C9 contribution
  • a1 - Scaling factor for critical radii
  • a2 - Offset distance in Bohr for critical radii
Source

pub fn new_rational_damping_f( s6: f64, s8: f64, s9: f64, a1: f64, a2: f64, alp: f64, ) -> Result<Self, DFTD4Error>

Crate new damping parameters (failable).

Source

pub fn load_rational_damping(name: &str, atm: bool) -> Self

Load damping parameters from internal storage.

  • name - name of the xc-functional
  • atm - use three-body specific parametrization
Examples found in repository?
examples/test_interface.rs (line 122)
95fn test_blypd4() {
96    // Use BLYP-D4 for a mindless molecule
97    let thr = 1.0e-7;
98
99    let numbers = vec![1, 1, 6, 5, 1, 15, 8, 17, 13, 15, 5, 1, 9, 15, 1, 15];
100    #[rustfmt::skip]
101    let positions = vec![
102         2.79274810283778,  3.82998228828316, -2.79287054959216,
103        -1.43447454186833,  0.43418729987882,  5.53854345129809,
104        -3.26268343665218, -2.50644032426151, -1.56631149351046,
105         2.14548759959147, -0.88798018953965, -2.24592534506187,
106        -4.30233097423181, -3.93631518670031, -0.48930754109119,
107         0.06107643564880, -3.82467931731366, -2.22333344469482,
108         0.41168550401858,  0.58105573172764,  5.56854609916143,
109         4.41363836635653,  3.92515871809283,  2.57961724984000,
110         1.33707758998700,  1.40194471661647,  1.97530004949523,
111         3.08342709834868,  1.72520024666801, -4.42666116106828,
112        -3.02346932078505,  0.04438199934191, -0.27636197425010,
113         1.11508390868455, -0.97617412809198,  6.25462847718180,
114         0.61938955433011,  2.17903547389232, -6.21279842416963,
115        -2.67491681346835,  3.00175899761859,  1.05038813614845,
116        -4.13181080289514, -2.34226739863660, -3.44356159392859,
117         2.85007173009739, -2.64884892757600,  0.71010806424206,
118    ];
119
120    let model = DFTD4Model::new(&numbers, &positions, None, None, None);
121
122    let param = DFTD4Param::load_rational_damping("blyp", true);
123    let res = model.get_dispersion(&param, false);
124
125    assert_abs_diff_eq!(res.energy, -0.06991716314879085, epsilon = thr);
126
127    let res = model.get_dispersion(&param, true);
128
129    assert_abs_diff_eq!(res.energy, -0.06991716314879085, epsilon = thr);
130}
131
132#[cfg(feature = "api-v4_0")]
133fn test_tpssd4s() {
134    // Use TPSS-D4S for a mindless molecule
135    let thr = 1.0e-7;
136
137    let numbers = vec![1, 1, 6, 5, 1, 15, 8, 17, 13, 15, 5, 1, 9, 15, 1, 15];
138    #[rustfmt::skip]
139    let positions = vec![
140         2.79274810283778,  3.82998228828316, -2.79287054959216,
141        -1.43447454186833,  0.43418729987882,  5.53854345129809,
142        -3.26268343665218, -2.50644032426151, -1.56631149351046,
143         2.14548759959147, -0.88798018953965, -2.24592534506187,
144        -4.30233097423181, -3.93631518670031, -0.48930754109119,
145         0.06107643564880, -3.82467931731366, -2.22333344469482,
146         0.41168550401858,  0.58105573172764,  5.56854609916143,
147         4.41363836635653,  3.92515871809283,  2.57961724984000,
148         1.33707758998700,  1.40194471661647,  1.97530004949523,
149         3.08342709834868,  1.72520024666801, -4.42666116106828,
150        -3.02346932078505,  0.04438199934191, -0.27636197425010,
151         1.11508390868455, -0.97617412809198,  6.25462847718180,
152         0.61938955433011,  2.17903547389232, -6.21279842416963,
153        -2.67491681346835,  3.00175899761859,  1.05038813614845,
154        -4.13181080289514, -2.34226739863660, -3.44356159392859,
155         2.85007173009739, -2.64884892757600,  0.71010806424206,
156    ];
157
158    let model = DFTD4Model::new_d4s(&numbers, &positions, None, None, None);
159
160    let param = DFTD4Param::load_rational_damping("tpss", true);
161    let res = model.get_dispersion(&param, false);
162
163    assert_abs_diff_eq!(res.energy, -0.046233140236052253, epsilon = thr);
164
165    let res = model.get_dispersion(&param, true);
166
167    assert_abs_diff_eq!(res.energy, -0.046233140236052253, epsilon = thr);
168}
169
170fn test_pbed4() {
171    // Use PBE-D4 for a mindless molecule
172    let thr = 1.0e-7;
173
174    let numbers = vec![1, 9, 15, 13, 1, 1, 13, 5, 3, 15, 8, 1, 1, 5, 16, 1];
175    #[rustfmt::skip]
176    let positions = vec![
177        -2.14132037405479, -1.34402701877044, -2.32492500904728,
178         4.46671289205392, -2.04800110524830,  0.44422406067087,
179        -4.92212517643478, -1.73734240529793,  0.96890323821450,
180        -1.30966093045696, -0.52977363497805,  3.44453452239668,
181        -4.34208759006189, -4.30470270977329,  0.39887431726215,
182         0.61788392767516,  2.62484136683297, -3.28228926932647,
183         4.23562873444840, -1.68839322682951, -3.53824299552792,
184         2.23130060612446,  1.93579813100155, -1.80384647554323,
185        -2.32285463652832,  2.90603947535842, -1.39684847191937,
186         2.34557941578250,  2.86074312333371,  1.82827238641666,
187        -3.66431367659153, -0.42910188232667, -1.81957402856634,
188        -0.34927881505446, -1.75988134003940,  5.98017466326572,
189         0.29500802281217, -2.00226104143537,  0.53023447931897,
190         2.10449364205058, -0.56741404446633,  0.30975625014335,
191        -1.59355304432499,  3.69176153150419,  2.87878226787916,
192         4.34858700256050,  2.39171478113440, -2.61802993563738,
193    ];
194
195    let model = DFTD4Model::new(&numbers, &positions, None, None, None);
196
197    let param = DFTD4Param::load_rational_damping("pbe", true);
198    let res = model.get_dispersion(&param, false);
199
200    assert_abs_diff_eq!(res.energy, -0.028415184156428127, epsilon = thr);
201
202    let res = model.get_dispersion(&param, true);
203
204    assert_abs_diff_eq!(res.energy, -0.028415184156428127, epsilon = thr);
205}
206
207#[cfg(feature = "api-v3_1")]
208fn test_r2scan3c() {
209    // Use r2SCAN-3c for a mindless molecule (custom D4 model)
210    let thr = 1.0e-8;
211
212    let numbers = vec![1, 9, 15, 13, 1, 1, 13, 5, 3, 15, 8, 1, 1, 5, 16, 1];
213    #[rustfmt::skip]
214    let positions = vec![
215        -2.14132037405479, -1.34402701877044, -2.32492500904728,
216         4.46671289205392, -2.04800110524830,  0.44422406067087,
217        -4.92212517643478, -1.73734240529793,  0.96890323821450,
218        -1.30966093045696, -0.52977363497805,  3.44453452239668,
219        -4.34208759006189, -4.30470270977329,  0.39887431726215,
220         0.61788392767516,  2.62484136683297, -3.28228926932647,
221         4.23562873444840, -1.68839322682951, -3.53824299552792,
222         2.23130060612446,  1.93579813100155, -1.80384647554323,
223        -2.32285463652832,  2.90603947535842, -1.39684847191937,
224         2.34557941578250,  2.86074312333371,  1.82827238641666,
225        -3.66431367659153, -0.42910188232667, -1.81957402856634,
226        -0.34927881505446, -1.75988134003940,  5.98017466326572,
227         0.29500802281217, -2.00226104143537,  0.53023447931897,
228         2.10449364205058, -0.56741404446633,  0.30975625014335,
229        -1.59355304432499,  3.69176153150419,  2.87878226787916,
230         4.34858700256050,  2.39171478113440, -2.61802993563738,
231    ];
232
233    // Python test uses custom D4 model with ga=2.0, gc=1.0
234    let model = DFTD4Model::custom_d4(&numbers, &positions, 2.0, 1.0, 6.0, None, None, None);
235
236    let param = DFTD4RationalDampingParamBuilder::default()
237        .s8(0.0)
238        .a1(0.42)
239        .a2(5.65)
240        .s9(2.0)
241        .build()
242        .unwrap()
243        .new_param();
244    let res = model.get_dispersion(&param, false);
245
246    assert_abs_diff_eq!(res.energy, -0.008016697276824889, epsilon = thr);
247
248    let res = model.get_dispersion(&param, true);
249
250    assert_abs_diff_eq!(res.energy, -0.008016697276824889, epsilon = thr);
251}
252
253#[cfg(feature = "api-v3_2")]
254fn test_pair_resolved() {
255    // Calculate pairwise resolved dispersion energy for a molecule
256    let thr = 1.0e-8;
257
258    let numbers = vec![16, 16, 16, 16, 16, 16, 16, 16];
259    #[rustfmt::skip]
260    let positions = vec![
261        -4.15128787379191,  1.71951973863958, -0.93066267097296,
262        -4.15128787379191, -1.71951973863958,  0.93066267097296,
263        -1.71951973863958, -4.15128787379191, -0.93066267097296,
264         1.71951973863958, -4.15128787379191,  0.93066267097296,
265         4.15128787379191, -1.71951973863958, -0.93066267097296,
266         4.15128787379191,  1.71951973863958,  0.93066267097296,
267         1.71951973863958,  4.15128787379191, -0.93066267097296,
268        -1.71951973863958,  4.15128787379191,  0.93066267097296,
269    ];
270    #[rustfmt::skip]
271    let pair_disp2 = vec![
272        -0.00000000e-0, -5.80599854e-4, -4.74689854e-4, -2.11149449e-4, -1.63163128e-4, -2.11149449e-4, -4.74689854e-4, -5.80599854e-4,
273        -5.80599854e-4, -0.00000000e-0, -5.80599854e-4, -4.74689854e-4, -2.11149449e-4, -1.63163128e-4, -2.11149449e-4, -4.74689854e-4,
274        -4.74689854e-4, -5.80599854e-4, -0.00000000e-0, -5.80599854e-4, -4.74689854e-4, -2.11149449e-4, -1.63163128e-4, -2.11149449e-4,
275        -2.11149449e-4, -4.74689854e-4, -5.80599854e-4, -0.00000000e-0, -5.80599854e-4, -4.74689854e-4, -2.11149449e-4, -1.63163128e-4,
276        -1.63163128e-4, -2.11149449e-4, -4.74689854e-4, -5.80599854e-4, -0.00000000e-0, -5.80599854e-4, -4.74689854e-4, -2.11149449e-4,
277        -2.11149449e-4, -1.63163128e-4, -2.11149449e-4, -4.74689854e-4, -5.80599854e-4, -0.00000000e-0, -5.80599854e-4, -4.74689854e-4,
278        -4.74689854e-4, -2.11149449e-4, -1.63163128e-4, -2.11149449e-4, -4.74689854e-4, -5.80599854e-4, -0.00000000e-0, -5.80599854e-4,
279        -5.80599854e-4, -4.74689854e-4, -2.11149449e-4, -1.63163128e-4, -2.11149449e-4, -4.74689854e-4, -5.80599854e-4, -0.00000000e-0,
280    ];
281    #[rustfmt::skip]
282    let pair_disp3 = vec![
283        0.00000000e-0, 3.39353850e-7, 8.74462839e-7, 1.17634100e-6, 9.86937310e-7, 1.17634100e-6, 8.74462839e-7, 3.39353850e-7,
284        3.39353850e-7, 0.00000000e-0, 3.39353850e-7, 8.74462839e-7, 1.17634100e-6, 9.86937310e-7, 1.17634100e-6, 8.74462839e-7,
285        8.74462839e-7, 3.39353850e-7, 0.00000000e-0, 3.39353850e-7, 8.74462839e-7, 1.17634100e-6, 9.86937310e-7, 1.17634100e-6,
286        1.17634100e-6, 8.74462839e-7, 3.39353850e-7, 0.00000000e-0, 3.39353850e-7, 8.74462839e-7, 1.17634100e-6, 9.86937310e-7,
287        9.86937310e-7, 1.17634100e-6, 8.74462839e-7, 3.39353850e-7, 0.00000000e-0, 3.39353850e-7, 8.74462839e-7, 1.17634100e-6,
288        1.17634100e-6, 9.86937310e-7, 1.17634100e-6, 8.74462839e-7, 3.39353850e-7, 0.00000000e-0, 3.39353850e-7, 8.74462839e-7,
289        8.74462839e-7, 1.17634100e-6, 9.86937310e-7, 1.17634100e-6, 8.74462839e-7, 3.39353850e-7, 0.00000000e-0, 3.39353850e-7,
290        3.39353850e-7, 8.74462839e-7, 1.17634100e-6, 9.86937310e-7, 1.17634100e-6, 8.74462839e-7, 3.39353850e-7, 0.00000000e-0,
291    ];
292
293    let model = DFTD4Model::new(&numbers, &positions, None, None, None);
294
295    let param = DFTD4RationalDampingParamBuilder::default()
296        .s8(1.20065498)
297        .a1(0.40085597)
298        .a2(5.02928789)
299        .build()
300        .unwrap()
301        .new_param();
302    let res = model.get_pairwise_dispersion(&param);
303
304    for (a, b) in res.pair_energy2.iter().zip(pair_disp2.iter()) {
305        assert_abs_diff_eq!(a, b, epsilon = thr);
306    }
307
308    for (a, b) in res.pair_energy3.iter().zip(pair_disp3.iter()) {
309        assert_abs_diff_eq!(a, b, epsilon = thr);
310    }
311}
312
313#[cfg(feature = "api-v3_1")]
314fn test_properties() {
315    // Calculate dispersion related properties for a molecule
316    let thr = 1.0e-7;
317
318    let numbers = vec![7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
319    #[rustfmt::skip]
320    let positions = vec![
321        1.97420621099560, 1.97415497783241, 1.97424596974304,
322        6.82182427659395, 2.87346383480995, 7.72099517560089,
323        7.72104957181201, 6.82177051521773, 2.87336561318016,
324        2.87343220660781, 7.72108897828386, 6.82187093171878,
325        3.51863272100286, 2.63865333484548, 1.00652979981286,
326        2.63877594964754, 1.00647313885594, 3.51882748086447,
327        1.00639728563189, 3.51850454450845, 2.63869202592387,
328        8.36624975982697, 2.20896711017229, 8.68870955681018,
329        7.48639684558259, 3.84114715917956, 6.17640982573725,
330        5.85401675167715, 1.32911569888797, 7.05654606696031,
331        7.05646299938990, 5.85409590282274, 1.32879923864813,
332        8.68882633853582, 8.36611541129785, 2.20894120662207,
333        3.84121223226912, 6.17673669892998, 7.48629723649480,
334        1.32897854262127, 7.05658604099926, 5.85414031368096,
335        2.20884896069885, 8.68875820985799, 8.36643568423387,
336        6.17659142004652, 7.48627051643848, 3.84109594690835,
337    ];
338    #[rustfmt::skip]
339    let lattice = vec![
340        9.69523775911749, 0.0, 0.0,
341        0.0, 9.69523775911749, 0.0,
342        0.0, 0.0, 9.69523775911749,
343    ];
344    #[rustfmt::skip]
345    let cn = [
346        2.5775156287150218,
347        2.5775155620078536,
348        2.5775157938667150,
349        2.5775157704485387,
350        0.8591731475439074,
351        0.8591680526841657,
352        0.8591744284869478,
353        0.8591732359038715,
354        0.8591678667769283,
355        0.8591744593270527,
356        0.8591684383407867,
357        0.8591754863625011,
358        0.8591751690053771,
359        0.8591719636497469,
360        0.8591686377934131,
361        0.8591718691634261,
362    ];
363    #[rustfmt::skip]
364    let charges = [
365        -0.86974543285813199,
366        -0.86974501326130316,
367        -0.86974658178316333,
368        -0.86974643466661739,
369         0.28992010784471012,
370         0.28989847135893759,
371         0.28992738637932841,
372         0.28992042841052362,
373         0.28989746859382759,
374         0.28992753735979965,
375         0.28990032127437559,
376         0.28993196014690176,
377         0.28993044356403513,
378         0.28991421277784613,
379         0.28990119160907674,
380         0.28991393324985348,
381    ];
382    #[rustfmt::skip]
383    let alpha = [
384        9.9853045768095097,
385        9.9853025181287016,
386        9.9853102162086920,
387        9.9853094944097140,
388        1.3513315505023076,
389        1.3513939255952379,
390        1.3513106323935196,
391        1.3513306244831862,
392        1.3513968091133417,
393        1.3513101978580895,
394        1.3513885997538553,
395        1.3512974505020905,
396        1.3513018164322617,
397        1.3513485145877058,
398        1.3513860914395939,
399        1.3513493246534483,
400    ];
401
402    let model = DFTD4Model::new(&numbers, &positions, None, Some(&lattice), None);
403
404    let res = model.get_properties();
405
406    for (a, b) in res.cn.iter().zip(cn.iter()) {
407        assert_abs_diff_eq!(a, b, epsilon = thr);
408    }
409
410    for (a, b) in res.charges.iter().zip(charges.iter()) {
411        assert_abs_diff_eq!(a, b, epsilon = thr);
412    }
413
414    for (a, b) in res.alpha.iter().zip(alpha.iter()) {
415        assert_abs_diff_eq!(a, b, epsilon = thr);
416    }
417}
418
419fn test_error_model() {
420    // Test loading an unknown method produces an error
421    let param = DFTD4Param::load_rational_damping_f("UNKNOWN_METHOD", false);
422    assert!(param.is_err_and(|e| e.to_string().contains("not known")));
423}
424
425#[cfg(feature = "api-v4_2")]
426fn test_smooth_realspace_cutoff() {
427    // Check smooth cutoff support changes dispersion energy
428    let numbers = vec![6, 6, 6, 1, 1, 1, 1];
429    #[rustfmt::skip]
430    let positions = vec![
431        0.00000000000000,  0.00000000000000, -1.79755622305860,
432        0.00000000000000,  0.00000000000000,  0.95338756106749,
433        0.00000000000000,  0.00000000000000,  3.22281255790261,
434       -0.96412815539807, -1.66991895015711, -2.53624948351102,
435       -0.96412815539807,  1.66991895015711, -2.53624948351102,
436        1.92825631079613,  0.00000000000000, -2.53624948351102,
437        0.00000000000000,  0.00000000000000,  5.23010455462158,
438    ];
439
440    let param = DFTD4Param::load_rational_damping("pbe", false);
441
442    // Get reference energy with default cutoffs
443    let mut model = DFTD4Model::new(&numbers, &positions, None, None, None);
444    let ref_energy = model.get_dispersion(&param, false).energy;
445
446    // Set tight cutoffs with smoothing, should change the energy
447    model.set_realspace_cutoff_smooth(4.0, 4.0, 30.0, 2.0, 2.0);
448    let res_energy = model.get_dispersion(&param, false).energy;
449
450    assert_ne!(ref_energy, res_energy);
451}
More examples
Hide additional examples
examples/energy_r2scan.rs (line 33)
3fn main_test() {
4    // atom indices
5    let numbers = vec![6, 6, 6, 6, 6, 6, 53, 1, 1, 1, 1, 1, 16, 1, 6, 1, 1, 1];
6    // geometry in angstrom
7    #[rustfmt::skip]
8    let positions = vec![
9        -0.755422531,  -0.796459123,  -1.023590391,
10         0.634274834,  -0.880017014,  -1.075233285,
11         1.406955202,   0.199695367,  -0.653144334,
12         0.798863737,   1.361204515,  -0.180597909,
13        -0.593166787,   1.434312023,  -0.133597923,
14        -1.376239198,   0.359205222,  -0.553258516,
15        -1.514344238,   3.173268101,   0.573601106,
16         1.110906949,  -1.778801728,  -1.440619836,
17         1.399172302,   2.197767355,   0.147412751,
18         2.486417780,   0.142466525,  -0.689380574,
19        -2.454252250,   0.422581120,  -0.512807958,
20        -1.362353593,  -1.630564523,  -1.348743149,
21        -3.112683203,   6.289227834,   1.226984439,
22        -4.328789697,   5.797771251,   0.973373089,
23        -2.689135032,   6.703163830,  -0.489062886,
24        -1.684433029,   7.115457372,  -0.460265708,
25        -2.683867206,   5.816530502,  -1.115183775,
26        -3.365330613,   7.451201412,  -0.890098894,
27    ];
28    // convert angstrom to bohr
29    let positions = positions.iter().map(|&x| x / 0.52917721067).collect::<Vec<f64>>();
30    // generate DFTD4 model
31    let model = DFTD4Model::new(&numbers, &positions, None, None, None);
32    // retrive the DFTD4 parameters
33    let param = DFTD4Param::load_rational_damping("r2SCAN", true);
34    // obtain the dispersion energy without gradient and sigma
35    let (energy, _, _) = model.get_dispersion(&param, false).into();
36
37    println!("Dispersion energy: {}", energy);
38    let energy_ref = -0.005001101058518388;
39    assert!((energy - energy_ref).abs() < 1e-9);
40}
examples/gradient_b97m.rs (line 32)
3fn main_test() {
4    // atom indices
5    let numbers = vec![1, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 35, 6, 9, 9, 9];
6    // geometry in angstrom
7    #[rustfmt::skip]
8    let positions = vec![
9        0.002144194,   0.361043475,   0.029799709,
10        0.015020592,   0.274789738,   1.107648016,
11        1.227632658,   0.296655040,   1.794629427,
12        1.243958826,   0.183702791,   3.183703934,
13        0.047958213,   0.048915002,   3.886484583,
14       -1.165135654,   0.026954348,   3.200213281,
15       -1.181832083,   0.139828643,   1.810376587,
16        2.155807907,   0.399177037,   1.249441585,
17        2.184979344,   0.198598553,   3.716170761,
18        0.060934662,  -0.040672756,   4.964014252,
19       -2.093220602,  -0.078628959,   3.745125056,
20       -2.122845437,   0.123257119,   1.277645797,
21       -0.268325907,  -3.194209024,   1.994458950,
22        0.049999933,  -5.089197474,   1.929391171,
23        0.078949601,  -5.512441335,   0.671851563,
24        1.211983937,  -5.383996300,   2.498664481,
25       -0.909987405,  -5.743747328,   2.570721738,
26    ];
27    // convert angstrom to bohr
28    let positions = positions.iter().map(|&x| x / 0.52917721067).collect::<Vec<f64>>();
29    // generate DFTD4 model
30    let model = DFTD4Model::new(&numbers, &positions, None, None, None);
31    // retrive the DFTD4 parameters
32    let param = DFTD4Param::load_rational_damping("b97m", true);
33    // obtain the dispersion energy and gradient, without sigma
34    let (energy, gradient, _) = model.get_dispersion(&param, true).into();
35    let gradient = gradient.unwrap();
36    println!("Dispersion energy: {}", energy);
37    println!("Dispersion gradient:");
38    gradient.chunks(3).for_each(|chunk| println!("{:16.9?}", chunk));
39
40    #[rustfmt::skip]
41    let gradient_ref = vec![
42         2.98598566e-06,  5.58662750e-05, -2.26040542e-04,
43         1.75816159e-05,  3.76346114e-04, -5.59737686e-04,
44         5.30037419e-04,  3.39528029e-04, -2.58687563e-04,
45         5.28657666e-04,  2.71291979e-04,  3.25797992e-04,
46         2.86698935e-05,  2.42198161e-04,  6.35784343e-04,
47        -4.99037369e-04,  2.74343468e-04,  3.55926359e-04,
48        -5.08919994e-04,  3.36480299e-04, -2.53165937e-04,
49         1.90422032e-04,  3.91738111e-05, -1.05867702e-04,
50         1.88137796e-04,  1.62741316e-05,  1.07526135e-04,
51         6.73432246e-06,  2.93353505e-06,  2.23028509e-04,
52        -1.97182105e-04,  1.82664904e-05,  1.26683921e-04,
53        -2.07136902e-04,  4.89015922e-05, -1.12337721e-04,
54        -2.01762905e-04, -1.23133705e-03, -2.26387771e-04,
55         7.59912392e-06, -1.01235495e-04, -7.86554908e-06,
56         3.02563455e-05, -2.19783887e-04, -2.31677736e-04,
57         2.31670341e-04, -2.08064229e-04,  9.53780006e-05,
58        -1.48713265e-04, -2.61183219e-04,  1.11642946e-04,
59    ];
60
61    let l2_diff =
62        gradient.iter().zip(gradient_ref.iter()).map(|(x, y)| (x - y).powi(2)).sum::<f64>().sqrt();
63    println!("L2 difference: {:16.8e}", l2_diff);
64    assert!(l2_diff < 1e-9);
65}
Source

pub fn load_rational_damping_f( name: &str, atm: bool, ) -> Result<Self, DFTD4Error>

Load damping parameters from internal storage (failable).

Examples found in repository?
examples/test_interface.rs (line 421)
419fn test_error_model() {
420    // Test loading an unknown method produces an error
421    let param = DFTD4Param::load_rational_damping_f("UNKNOWN_METHOD", false);
422    assert!(param.is_err_and(|e| e.to_string().contains("not known")));
423}

Trait Implementations§

Source§

impl Drop for DFTD4Param

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.