MADNESS 0.10.1
Results.h
Go to the documentation of this file.
1//
2// Created by Florian Bischoff on 08.07.25.
3//
4
5#ifndef RESULTS_H
6#define RESULTS_H
7
8#include <madness/constants.h>
11#include <nlohmann/json.hpp>
12#include <madness/tensor/tensor_json.hpp>
13#include <optional>
14#include <string>
15#include <unordered_map>
16
17//* base and derived classes for holding results of a calculation
18namespace madness {
19
21
22public:
23 ResultsBase() = default;
24
25 virtual ~ResultsBase() = default;
26 /// serialize the results to a JSON object
27 [[nodiscard]] virtual nlohmann::json to_json() const = 0;
28 virtual void from_json(const nlohmann::json &j) = 0;
29 [[nodiscard]] virtual std::string key() const = 0;
30};
31
32//--tiny helpers
33template <class T, class F>
34inline void set_if_exists(nlohmann::json &j, const std::string &key,
35 const std::optional<T> &opt, F &&to_json_fn) {
36 if (opt)
37 j[key] = to_json_fn(*opt);
38}
39template <class T, class F>
40inline void get_if_exists(const nlohmann::json &j, const std::string &key,
41 std::optional<T> &opt, F &&from_json_fn) {
42 if (j.contains(key))
43 opt = from_json_fn(j[key]);
44}
45
46template <class T> inline nlohmann::json tensor_out(const Tensor<T> &t) {
47 return tensor_to_json(t);
48}
49template <class T> inline Tensor<T> tensor_in(const nlohmann::json &j) {
50 return tensor_from_json<T>(j);
51}
52
53/// holds metadata of the calculation
54
55/// create right before the calculation starts, stop() must be called after the
56/// calculation is finished
58public:
59 explicit MetaDataResults(World &world) {
61 mpi_size = world.size();
62 }
63
64 double time_begin = 0.0;
65 double time_end = 0.0;
66 std::string finished_at;
67 std::string git_hash;
68 int mpi_size = -1;
69 std::string host;
70 int nthreads = -1;
71
72 [[nodiscard]] std::string key() const override { return "metadata"; }
73
74 void stop() {
77 }
78
79 [[nodiscard]] nlohmann::json to_json() const override {
80 nlohmann::json j;
81 // compute timing on-the-fly unless they have been set
82 if (time_end == 0.0) {
83 j["elapsed_time"] = wall_time() - time_begin;
84 j["finished_at"] = time_tag();
85 } else {
86 j["elapsed_time"] = time_end - time_begin;
87 j["finished_at"] = finished_at;
88 }
89 j["git_hash"] = git_hash;
90 j["host"] = std::string(HOST_SYSTEM);
91 j["nthreads"] = ThreadPool::size();
92 j["mpi_size"] = mpi_size;
93 return j;
94 }
95
96private:
97 /// borrowed from Adrian's MolDFTLib
98 std::string time_tag() const {
99 auto print_time = std::chrono::system_clock::now();
100 auto in_time_t = std::chrono::system_clock::to_time_t(print_time);
101 std::stringstream ss;
102 ss << std::put_time(std::localtime(&in_time_t), "%Y-%m-%d %X");
103 return ss.str();
104 }
105};
106
107/// holds convergence results of the calculation
109public:
110 double converged_for_thresh = 1.e10;
111 double converged_for_dconv = 1.e10;
113
114 /// construct from JSON
115 explicit ConvergenceResults(const nlohmann::json &j) {
116 converged_for_thresh = j.value("converged_for_thresh", 1.e10);
117 converged_for_dconv = j.value("converged_for_dconv", 1.e10);
118 }
119
120 /// assignment operator from JSON
121 ConvergenceResults &operator=(const nlohmann::json &j) {
122 converged_for_thresh = j.value("converged_for_thresh", 1.e10);
123 converged_for_dconv = j.value("converged_for_dconv", 1.e10);
124 return *this;
125 }
126
127 [[nodiscard]] std::string key() const override { return "convergence"; }
128
133
135 converged_for_dconv = dconv;
136 return *this;
137 }
138
139 [[nodiscard]] nlohmann::json to_json() const override {
140 nlohmann::json j;
141 j["converged_for_thresh"] = converged_for_thresh;
142 j["converged_for_dconv"] = converged_for_dconv;
143 return j;
144 }
145 void from_json(const nlohmann::json &j) override {
146 converged_for_thresh = j.value("converged_for_thresh", 1.e10);
147 converged_for_dconv = j.value("converged_for_dconv", 1.e10);
148 }
149};
150
152public:
153 int nsteps = 0;
154 double final_energy = 0.0;
155 double max_gradient = 0.0;
156 double rms_gradient = 0.0;
157 double max_step = 0.0;
158 double rms_step = 0.0;
160
162
163 /// construct from JSON
164 OptimizationResults(const nlohmann::json &j) {
165 nsteps = j.value("nsteps", 0);
166 final_energy = j.value("final_energy", 0.0);
167 max_gradient = j.value("max_gradient", 0.0);
168 max_step = j.value("max_step", 0.0);
169 if (j.contains("final_geometry"))
170 final_geometry.from_json(j.at("final_geometry"));
171 }
172
173 std::string key() const override { return "optimization"; }
174
175 [[nodiscard]] nlohmann::json to_json() const override {
176 nlohmann::json j;
177 j["nsteps"] = nsteps;
178 j["final_energy"] = final_energy;
179 j["max_gradient"] = max_gradient;
180 j["max_step"] = max_step;
181 j["final_geometry"] = final_geometry.to_json();
182 return j;
183 } // from json OptimizationResults
184
185 void from_json(const nlohmann::json &j) override {
186 // robust reads (won’t throw if missing)
187 nsteps = j.value("nsteps", 0);
188 final_energy = j.value("final_energy", 0.0);
189 max_gradient = j.value("max_gradient", 0.0);
190 max_step = j.value("max_step", 0.0);
191 if (j.contains("final_geometry"))
192 final_geometry.from_json(j.at("final_geometry"));
193 }
194};
195
197public:
198 std::optional<Tensor<double>> hessian;
199 std::optional<Tensor<double>>
200 frequencies; // (vibrational frequencies in a.u.)
201 std::optional<Tensor<double>> intensities; //(IR intensities in km/mol)
202 std::optional<Tensor<double>> reducedmass; //(reduced
203 std::optional<Tensor<double>> normalmodes; //(normal modes)
204 std::optional<Tensor<double>> normalmodes_atomic; //(normal modes in atomic
205 // coordinates)
206 //
207 static constexpr double au2invm =
208 constants::au2invcm; // conversion factor from Hartree to cm^-1
210 VibrationalResults(const nlohmann::json &/*j*/) {}
211
212 [[nodiscard]] bool has_data() const {
214 }
215
216 [[nodiscard]] std::string key() const override { return "vibrations"; }
217
218 nlohmann::json to_json() const override {
219 nlohmann::json j;
220
221 set_if_exists(j, "hessian", hessian, tensor_out<double>);
222 set_if_exists(j, "frequencies", frequencies, tensor_out<double>);
223 set_if_exists(j, "intensities", intensities, tensor_out<double>);
224 set_if_exists(j, "reducedmass", reducedmass, tensor_out<double>);
225 set_if_exists(j, "normalmodes", normalmodes, tensor_out<double>);
226
227 j["au2invcm"] = constants::au2invcm;
228
229 set_if_exists(j, "normalmodes_atomic", normalmodes_atomic, tensor_out<double>);
230
231 return j;
232 }
233
234 void from_json(const nlohmann::json &j) override {
235 get_if_exists(j, "hessian", hessian, tensor_in<double>);
236 get_if_exists(j, "frequencies", frequencies, tensor_in<double>);
237 get_if_exists(j, "intensities", intensities, tensor_in<double>);
238 get_if_exists(j, "reducedmass", reducedmass, tensor_in<double>);
239 get_if_exists(j, "normalmodes", normalmodes, tensor_in<double>);
240 get_if_exists(j, "normalmodes_atomic", normalmodes_atomic, tensor_in<double>);
241 }
242};
243
244// A Raman calculation results in Raman Intensities for each normal mode
245// computed at a given polarization frequency
246//
247class RamanResults : public ResultsBase {
248public:
249 std::string key() const override { return "raman"; }
250 RamanResults() = default;
251
252 std::vector<double> polarization_frequencies; // Polarization frequencies
253 std::vector<double> vibrational_frequencies; // Vibrational frequencies cm^-1
254 Tensor<double> normal_modes; // Deriv. of alpha
255 std::vector<Tensor<double>> polarizability_derivatives;
256 std::vector<Tensor<double>> polarizability_derivatives_normal_modes;
257
259 int mode; // 1..M
260 double freq_cm1; // vibrational frequency (cm^-1)
261 // Provide either all five values, or just alpha2/beta2 and let the
262 // printer compute the rest.
263 double alpha2; // Alpha**2 (a'²)
264 double beta2; // Beta(a)**2 (γ'²-like invariant in your convention)
265 std::optional<double> pol_int; // Pol.Int. (45*α'² + 4*β'²), optional
266 std::optional<double> depol_int; // Depol.Int. (3*β'²), optional
267 std::optional<double>
268 dep_ratio; // Dep. Ratio (3β'²) / (45α'² + 4β'²), optional
269 };
270
271 void to_json(const RamanModeRow &row, nlohmann::json &j) const {
272 j["mode"] = row.mode;
273 j["freq_cm1"] = row.freq_cm1;
274 j["alpha2"] = row.alpha2;
275 j["beta2"] = row.beta2;
276 if (row.pol_int)
277 j["pol_int"] = *(row.pol_int);
278 if (row.depol_int)
279 j["depol_int"] = *(row.depol_int);
280 if (row.dep_ratio)
281 j["dep_ratio"] = *(row.dep_ratio);
282 }
283 void from_json(const nlohmann::json &j, RamanModeRow &row) const {
284 row.mode = j.at("mode").get<int>();
285 row.freq_cm1 = j.at("freq_cm1").get<double>();
286 row.alpha2 = j.at("alpha2").get<double>();
287 row.beta2 = j.at("beta2").get<double>();
288 if (j.contains("pol_int"))
289 row.pol_int = j.at("pol_int").get<double>();
290 if (j.contains("depol_int"))
291 row.depol_int = j.at("depol_int").get<double>();
292 if (j.contains("dep_ratio"))
293 row.dep_ratio = j.at("dep_ratio").get<double>();
294 }
295 // Raman spectra result at frequency
296 // beta2
297 std::map<double, std::vector<RamanModeRow>> raman_spectra;
298
299 // map frequency to each modes pol_int, depol_int, depol_ratio, and 'alpha2',
300 // 'beta2',mode_frequency
301
302 void from_json(const nlohmann::json &j) override {
303 if (j.contains("polarization_frequencies"))
305 j.at("polarization_frequencies").get<std::vector<double>>();
306 if (j.contains("vibrational_frequencies"))
308 j.at("vibrational_frequencies").get<std::vector<double>>();
309 if (j.contains("polarizability_derivatives")) {
311 for (const auto &pd : j["polarizability_derivatives"])
312 polarizability_derivatives.push_back(tensor_in<double>(pd));
313 }
314 if (j.contains("polarizability_derivatives_normal_modes")) {
316 for (const auto &pd : j["polarizability_derivatives_normal_modes"])
318 tensor_in<double>(pd));
319 }
320 if (j.contains("raman_spectra")) {
321 raman_spectra.clear();
322 for (const auto &item : j["raman_spectra"].items()) {
323 double freq = std::stod(item.key());
324 std::vector<RamanModeRow> spectrum;
325 for (const auto &mode_json : item.value()) {
326 RamanModeRow row;
327 from_json(mode_json, row);
328 spectrum.push_back(row);
329 }
330 raman_spectra[freq] = spectrum;
331 }
332 }
333 }
334
335 nlohmann::json to_json() const override {
336 nlohmann::json j;
337 j["polarization_frequencies"] = polarization_frequencies;
338 j["vibrational_frequencies"] = vibrational_frequencies;
339 j["polarizability_derivatives"] = nlohmann::json::array();
340 for (const auto &pd : polarizability_derivatives)
341 j["polarizability_derivatives"].push_back(tensor_out<double>(pd));
342 j["polarizability_derivatives_normal_modes"] = nlohmann::json::array();
343 for (const auto &pd : polarizability_derivatives_normal_modes)
344 j["polarizability_derivatives_normal_modes"].push_back(
345 tensor_out<double>(pd));
346 j["raman_spectra"] = nlohmann::json::object();
347 for (const auto &item : raman_spectra) {
348 nlohmann::json spectrum_json = nlohmann::json::array();
349 for (const auto &mode_data : item.second) {
350 nlohmann::json mode_json;
351 to_json(mode_data, mode_json);
352 spectrum_json.push_back(mode_json);
353 }
354 j["raman_spectra"][std::to_string(item.first)] = spectrum_json;
355 }
356 // j["intensities_raman"] = intensities_raman;
357 // j["intensities_depolarization"] = intensities_depolarization;
358 // j["depolarization_ratios"] = depolarization_ratios;
359 return j;
360 }
361};
362
364public:
365 double energy = 0.0;
366
367 std::optional<Tensor<double>> dipole;
368 std::optional<Tensor<double>> gradient;
369 std::optional<VibrationalResults> vibrations;
370 std::optional<RamanResults> raman;
371
372 PropertyResults() = default;
373
374 /// construct from JSON
375 PropertyResults(const nlohmann::json &j) {
376 energy = j.value("energy", 0.0);
377 if (j.count("dipole") == 1)
378 dipole = tensor_from_json<double>(j["dipole"]);
379 if (j.count("gradient") == 1)
380 gradient = tensor_from_json<double>(j["gradient"]);
381 }
382
383 std::string key() const override { return "properties"; }
384
385 nlohmann::json to_json() const override {
386 nlohmann::json j;
387 j["energy"] = energy;
388 set_if_exists(j, "dipole", dipole, tensor_out<double>);
389 set_if_exists(j, "gradient", gradient, tensor_out<double>);
390 if (vibrations && vibrations->has_data())
391 j["vibrations"] = vibrations->to_json();
392 return j;
393 } // from json PropertyResults
394
395 void from_json(const nlohmann::json &j) override {
396 // robust reads (won’t throw if missing)
397 if (j.contains("energy"))
398 energy = j.value("energy", 0.0);
399 get_if_exists(j, "dipole", dipole, tensor_in<double>);
400 get_if_exists(j, "gradient", gradient, tensor_in<double>);
401
402 // nested section
403 if (j.contains("vibrations")) {
405 vib.from_json(j.at("vibrations"));
406 if (vib.has_data())
407 vibrations = std::move(vib);
408 }
409 }
410};
411
412// If you keep PropertyResults from earlier, give it:
413inline bool has_data(const PropertyResults &p) {
414 return p.energy != 0.0 || p.dipole || p.gradient ||
415 (p.vibrations && p.vibrations->has_data());
416}
417
418class SCFResults : public ResultsBase {
419public:
420 // Required alpha (for RHF/ ROHF/ UHF UKS we alsways expect alpha)
424 // optional beta (only for UHF/ UKS)
425 std::optional<Tensor<double>> beps;
426 std::optional<Tensor<double>> bfock;
427 bool is_opt = false;
428
429 std::string model = "scf"; // model used for the SCF calculation
430 double scf_total_energy = 0.0; // total energy of the SCF calculation
431 // empirical dispersion (DFT-D3) contribution already contained in
432 // scf_total_energy; 0.0 when no correction was applied
434 bool uses_dftd3 = false;
435 bool uses_pcm = false;
436 bool uses_libxc = false;
437 //
439 SCFResults() = default;
440
441 /// construct from JSON
442 SCFResults(const nlohmann::json &j) { from_json(j); }
443
444 std::string key() const override { return model; }
445
446 nlohmann::json to_json() const override {
447 nlohmann::json j;
448
449 // Required alpha pieces
450 j["scf_eigenvalues_a"] = tensor_out<double>(aeps);
451 j["scf_fock_a"] = tensor_out<double>(afock);
452
453 // Optional beta pieces
454 set_if_exists(j, "scf_eigenvalues_b", beps, tensor_out<double>);
455 set_if_exists(j, "scf_fock_b", bfock, tensor_out<double>);
456
457 // Scalars / metadata
458 j["model"] = model;
459 j["scf_total_energy"] = scf_total_energy;
460 j["scf_dispersion_correction_energy"] = scf_dispersion_correction_energy;
461 j["citations"] = {{"dftd3", uses_dftd3},
462 {"pcm", uses_pcm},
463 {"libxc", uses_libxc}};
464
465 // Optional nested block
466 if (has_data(properties)) {
467 j["properties"] = properties.to_json();
468 }
469
470 j["molecule"] = scf_molecule.to_json();
471 j["is_opt"] = is_opt;
472 return j;
473 }
474
475 void from_json(const nlohmann::json &j) override {
476 // Alpha: treat as required but read defensively
477 if (j.contains("scf_eigenvalues_a"))
478 aeps = tensor_in<double>(j.at("scf_eigenvalues_a"));
479 else
480 aeps = {}; // or throw if truly required
481
482 if (j.contains("scf_fock_a"))
483 afock = tensor_in<double>(j.at("scf_fock_a"));
484 else
485 afock = {}; // or throw if truly required
486
487 // Beta: optional
488 get_if_exists(j, "scf_eigenvalues_b", beps, tensor_in<double>);
489 get_if_exists(j, "scf_fock_b", bfock, tensor_in<double>);
490
491 // Scalars / metadata
492 if (j.contains("model"))
493 model = j.value("model", std::string("scf"));
494 if (j.contains("scf_total_energy"))
495 scf_total_energy = j.value("scf_total_energy", 0.0);
497 j.value("scf_dispersion_correction_energy", 0.0);
498 if (j.contains("citations") && j["citations"].is_object()) {
499 const auto &c = j["citations"];
500 uses_dftd3 = c.value("dftd3", false);
501 uses_pcm = c.value("pcm", false);
502 uses_libxc = c.value("libxc", false);
503 }
504
505 // Nested properties: optional
506 if (j.contains("properties")) {
508 p.from_json(j.at("properties"));
509 if (has_data(p))
510 properties = std::move(p);
511 } else {
513 }
514 if (j.contains("molecule"))
515 scf_molecule.from_json(j.at("molecule"));
516 else
517 MADNESS_EXCEPTION("Missing molecule data", j);
518 is_opt = j.value("is_opt", false);
519 }
520};
521// Todo: Upgrade to new JSON style using optional everything below here --
522//
523// ---------------------------------------------------------------------------------
524//
525//
526// ---------------------------------------------------------------------------------
527class CISResults : public ResultsBase {
528public:
530 std::string irrep; // irreducible representation
531 double omega; // excitation energy in Hartree
532 double current_error; // error in the excitation energy
533 double oscillator_strength_length; // oscillator strength
534 double oscillator_strength_velocity; // oscillator strength
535 };
536 std::vector<excitation_info> excitations;
537 long nfreeze = -1;
538 std::string model = "unknown";
539
540 std::string key() const override { return model; }
541
542 CISResults() = default;
543
544 /// construct from JSON
545 CISResults(const nlohmann::json &j) {
546 if (j.count("excitations") > 0) {
547 for (const auto &ex : j["excitations"]) {
549 ei.irrep = ex.value("irrep", "");
550 ei.omega = ex.value("omega", 0.0);
551 ei.current_error = ex.value("current_error", 0.0);
553 ex.value("oscillator_strength_length", 0.0);
555 ex.value("oscillator_strength_velocity", 0.0);
556 excitations.push_back(ei);
557 }
558 }
559 nfreeze = j.value("nfreeze", -1);
560 model = j.value("model", "unknown");
561 }
562
563 /// constructor with nfreeze and model
564 CISResults(long nfreeze, const std::string &model)
565 : nfreeze(nfreeze), model(model) {}
566
567 void from_json(const nlohmann::json &j) override {
568 excitations.clear();
569 if (j.count("excitations") > 0) {
570 for (const auto &ex : j["excitations"]) {
572 ei.irrep = ex.value("irrep", "");
573 ei.omega = ex.value("omega", 0.0);
574 ei.current_error = ex.value("current_error", 0.0);
576 ex.value("oscillator_strength_length", 0.0);
578 ex.value("oscillator_strength_velocity", 0.0);
579 excitations.push_back(ei);
580 }
581 }
582 nfreeze = j.value("nfreeze", -1);
583 model = j.value("model", "unknown");
584 }
585
586 nlohmann::json to_json() const override {
587 nlohmann::json j;
588 for (const auto &ex : excitations) {
589 nlohmann::json ex_json;
590 ex_json["irrep"] = ex.irrep;
591 ex_json["omega"] = ex.omega;
592 ex_json["current_error"] = ex.current_error;
593 ex_json["oscillator_strength_length"] = ex.oscillator_strength_length;
594 ex_json["oscillator_strength_velocity"] = ex.oscillator_strength_velocity;
595 j["excitations"].push_back(ex_json);
596 }
597 j["nfreeze"] = nfreeze;
598 j["model"] = model;
599 return j;
600 }
601};
602
603class CC2Results : public CISResults {
604public:
605 CC2Results() : CISResults() { model = "mp2"; }
606
607 PropertyResults properties; // properties of the correlated calculation
609 0.0; // correlation energy of the correlated calculation
610 double total_energy = 0.0; // total energy of the correlated calculation
611 /// construct from JSON
612 CC2Results(const nlohmann::json &j) : CISResults(j) {
613 properties = PropertyResults(j.value("properties", nlohmann::json{}));
614 model = j.value("model", "mp2");
615 correlation_energy = j.value("correlation_energy", 0.0);
616 total_energy = j.value(model + "_total_energy", 0.0);
617 }
618
619 /// constructor with nfreeze and model
620 CC2Results(long nfreeze, const std::string &model)
622
623 void from_json(const nlohmann::json &j) override {
625 properties = PropertyResults(j.value("properties", nlohmann::json{}));
626 model = j.value("model", "mp2");
627 correlation_energy = j.value("correlation_energy", 0.0);
628 total_energy = j.value(model + "_total_energy", 0.0);
629 }
630
631 nlohmann::json to_json() const override {
632 nlohmann::json j;
634 j["properties"] = properties.to_json();
635 j["model"] = model;
636 j["correlation_energy"] = correlation_energy;
637 j[model + "_correlation_energy"] = correlation_energy;
638 j[model + "_total_energy"] = total_energy;
639 return j;
640 }
641
642 CC2Results &set_energies(const double scf_energy, const double corr_energy) {
643 this->correlation_energy = corr_energy;
644 this->total_energy = scf_energy + corr_energy;
645 return *this;
646 }
647
648 /// setters with chaining
649 CC2Results &set_correlation_energy(const double corr_energy) {
650 correlation_energy = corr_energy;
651 return *this;
652 }
654 this->total_energy = total_energy;
655 return *this;
656 }
658 properties = props;
659 return *this;
660 }
661 CC2Results &set_model(const std::string &model) {
662 this->model = model;
663 return *this;
664 }
665};
666
667class ZnemoResults : public SCFResults {
668public:
669 double B = 0.0; // B value for the Znemo calculation
670
671 ZnemoResults() = default;
672 /// construct from JSON
673 ZnemoResults(const nlohmann::json &j) : SCFResults(j) {
674 B = j.value("B", 0.0);
675 }
676
677 void from_json(const nlohmann::json &j) override {
679 B = j.value("B", 0.0);
680 }
681
682 nlohmann::json to_json() const override {
683 nlohmann::json j;
685 j["B"] = B;
686 return j;
687 }
688};
689
690class OEPResults : public SCFResults {
691public:
692 double drho = 0.0; // delta rho =difference to reference (=HF?) density
693 double devir14 = 0.0; // diagnostic parameter
694 double devir17 = 0.0; // diagnostic parameter
695 double Ex_vir = 0.0; // local exchange energy
696 double Ex_conv = 0.0; //
697 double Ex_HF = 0.0; // HF exchange energy
698 double E_kin_HF = 0.0;
699 double E_kin_KS = 0.0; // kinetic energy of the KS reference
700 double Econv = 0.0; // final energy using conventional method
701
702 OEPResults() = default;
703
704 void from_json(const nlohmann::json &j) override {
706 model = j.value("model", "oaep");
707 drho = j.value("drho", 0.0);
708 devir14 = j.value("devir14", 0.0);
709 devir17 = j.value("devir17", 0.0);
710 Ex_vir = j.value("Ex_vir", 0.0);
711 Ex_conv = j.value("Ex_conv", 0.0);
712 Ex_HF = j.value("Ex_HF", 0.0);
713 E_kin_HF = j.value("E_kin_HF", 0.0);
714 E_kin_KS = j.value("E_kin_KS", 0.0);
715 Econv = j.value("Econv", 0.0);
716 }
717
718 /// construct from JSON
719 explicit OEPResults(const nlohmann::json &j) : SCFResults(j) {
720 model = j.value("model", "oaep");
721 drho = j.value("drho", 0.0);
722 devir14 = j.value("dvir14", 0.0);
723 devir17 = j.value("dvir17", 0.0);
724 Ex_vir = j.value("Ex_vir", 0.0);
725 Ex_conv = j.value("Ex_conv", 0.0);
726 Ex_HF = j.value("Ex_HF", 0.0);
727 E_kin_HF = j.value("E_kin_HF", 0.0);
728 E_kin_KS = j.value("E_kin_KS", 0.0);
729 Econv = j.value("Econv", 0.0);
730 }
731
732 nlohmann::json to_json() const override {
733 nlohmann::json j;
735 j["model"] = model;
736 j["drho"] = drho;
737 j["devir14"] = devir14;
738 j["devir17"] = devir17;
739 j["Ex_vir"] = Ex_vir;
740 j["Ex_conv"] = Ex_conv;
741 j["Ex_HF"] = Ex_HF;
742 j["E_kin_HF"] = E_kin_HF;
743 j["E_kin_KS"] = E_kin_KS;
744 j["Econv"] = Econv;
745 return j;
746 }
747};
748
751
752} // namespace madness
753#endif // RESULTS_H
Definition test_ar.cc:141
simple class for testing the solver
Definition derivatives.cc:60
Definition Results.h:603
void from_json(const nlohmann::json &j) override
Definition Results.h:623
CC2Results & set_energies(const double scf_energy, const double corr_energy)
Definition Results.h:642
CC2Results & set_properties(const PropertyResults &props)
Definition Results.h:657
CC2Results(const nlohmann::json &j)
construct from JSON
Definition Results.h:612
CC2Results & set_total_energy(const double total_energy)
Definition Results.h:653
CC2Results(long nfreeze, const std::string &model)
constructor with nfreeze and model
Definition Results.h:620
CC2Results & set_model(const std::string &model)
Definition Results.h:661
double correlation_energy
Definition Results.h:608
CC2Results & set_correlation_energy(const double corr_energy)
setters with chaining
Definition Results.h:649
CC2Results()
Definition Results.h:605
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:631
PropertyResults properties
Definition Results.h:607
double total_energy
Definition Results.h:610
Definition Results.h:527
std::vector< excitation_info > excitations
Definition Results.h:536
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:586
CISResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:545
std::string model
Definition Results.h:538
std::string key() const override
Definition Results.h:540
void from_json(const nlohmann::json &j) override
Definition Results.h:567
long nfreeze
Definition Results.h:537
CISResults(long nfreeze, const std::string &model)
constructor with nfreeze and model
Definition Results.h:564
holds convergence results of the calculation
Definition Results.h:108
double converged_for_thresh
Definition Results.h:110
void from_json(const nlohmann::json &j) override
Definition Results.h:145
ConvergenceResults & set_converged_dconv(double dconv)
Definition Results.h:134
std::string key() const override
Definition Results.h:127
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:139
ConvergenceResults & set_converged_thresh(double thresh)
Definition Results.h:129
ConvergenceResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:115
double converged_for_dconv
Definition Results.h:111
ConvergenceResults & operator=(const nlohmann::json &j)
assignment operator from JSON
Definition Results.h:121
holds metadata of the calculation
Definition Results.h:57
MetaDataResults(World &world)
Definition Results.h:59
std::string git_hash
Definition Results.h:67
int mpi_size
Definition Results.h:68
std::string finished_at
Definition Results.h:66
int nthreads
Definition Results.h:70
std::string time_tag() const
borrowed from Adrian's MolDFTLib
Definition Results.h:98
double time_begin
Definition Results.h:64
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:79
void stop()
Definition Results.h:74
std::string host
Definition Results.h:69
double time_end
Definition Results.h:65
std::string key() const override
Definition Results.h:72
Definition molecule.h:129
json to_json() const
Definition molecule.cc:512
void from_json(const json &mol_json)
Definition molecule.cc:537
Definition Results.h:690
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:732
double Ex_vir
Definition Results.h:695
double devir14
Definition Results.h:693
double Econv
Definition Results.h:700
double Ex_HF
Definition Results.h:697
void from_json(const nlohmann::json &j) override
Definition Results.h:704
double drho
Definition Results.h:692
OEPResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:719
double E_kin_KS
Definition Results.h:699
double Ex_conv
Definition Results.h:696
double E_kin_HF
Definition Results.h:698
double devir17
Definition Results.h:694
Definition Results.h:151
int nsteps
Definition Results.h:153
OptimizationResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:164
std::string key() const override
Definition Results.h:173
double max_step
Definition Results.h:157
double max_gradient
Definition Results.h:155
madness::Molecule final_geometry
Definition Results.h:159
void from_json(const nlohmann::json &j) override
Definition Results.h:185
double rms_gradient
Definition Results.h:156
double final_energy
Definition Results.h:154
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:175
double rms_step
Definition Results.h:158
Definition Results.h:363
std::optional< Tensor< double > > dipole
Definition Results.h:367
std::string key() const override
Definition Results.h:383
PropertyResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:375
std::optional< VibrationalResults > vibrations
Definition Results.h:369
void from_json(const nlohmann::json &j) override
Definition Results.h:395
std::optional< Tensor< double > > gradient
Definition Results.h:368
double energy
Definition Results.h:365
std::optional< RamanResults > raman
Definition Results.h:370
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:385
Definition Results.h:247
void from_json(const nlohmann::json &j, RamanModeRow &row) const
Definition Results.h:283
void to_json(const RamanModeRow &row, nlohmann::json &j) const
Definition Results.h:271
std::map< double, std::vector< RamanModeRow > > raman_spectra
Definition Results.h:297
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:335
std::vector< double > polarization_frequencies
Definition Results.h:252
Tensor< double > normal_modes
Definition Results.h:254
std::vector< Tensor< double > > polarizability_derivatives
Definition Results.h:255
std::vector< Tensor< double > > polarizability_derivatives_normal_modes
Definition Results.h:256
std::vector< double > vibrational_frequencies
Definition Results.h:253
void from_json(const nlohmann::json &j) override
Definition Results.h:302
std::string key() const override
Definition Results.h:249
Definition Results.h:20
virtual std::string key() const =0
virtual ~ResultsBase()=default
virtual nlohmann::json to_json() const =0
serialize the results to a JSON object
virtual void from_json(const nlohmann::json &j)=0
Definition Results.h:418
std::optional< Tensor< double > > bfock
Definition Results.h:426
Molecule scf_molecule
Definition Results.h:423
double scf_dispersion_correction_energy
Definition Results.h:433
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:446
std::string model
Definition Results.h:429
Tensor< double > aeps
Definition Results.h:421
bool uses_dftd3
Definition Results.h:434
void from_json(const nlohmann::json &j) override
Definition Results.h:475
double scf_total_energy
Definition Results.h:430
SCFResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:442
PropertyResults properties
Definition Results.h:438
bool uses_pcm
Definition Results.h:435
Tensor< double > afock
Definition Results.h:422
bool is_opt
Definition Results.h:427
std::string key() const override
Definition Results.h:444
bool uses_libxc
Definition Results.h:436
std::optional< Tensor< double > > beps
Definition Results.h:425
A tensor is a multidimensional array.
Definition tensor.h:318
static std::size_t size()
Returns the number of threads in the pool.
Definition thread.h:1460
Definition Results.h:196
std::optional< Tensor< double > > intensities
Definition Results.h:201
std::string key() const override
Definition Results.h:216
std::optional< Tensor< double > > frequencies
Definition Results.h:200
void from_json(const nlohmann::json &j) override
Definition Results.h:234
bool has_data() const
Definition Results.h:212
std::optional< Tensor< double > > reducedmass
Definition Results.h:202
std::optional< Tensor< double > > normalmodes_atomic
Definition Results.h:204
std::optional< Tensor< double > > normalmodes
Definition Results.h:203
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:218
std::optional< Tensor< double > > hessian
Definition Results.h:198
VibrationalResults(const nlohmann::json &)
Definition Results.h:210
static constexpr double au2invm
Definition Results.h:207
A parallel world class.
Definition world.h:134
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:354
Definition Results.h:667
void from_json(const nlohmann::json &j) override
Definition Results.h:677
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:682
double B
Definition Results.h:669
ZnemoResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:673
Defines common mathematical and physical constants.
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
Defines madness::MadnessException for exception handling.
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
constexpr double au2invcm
conversion from atomic units in reciprocal centimeter
Definition constants.h:272
Namespace for all elements and tools of MADNESS.
Definition DFConvergence.h:9
nlohmann::json tensor_out(const Tensor< T > &t)
Definition Results.h:46
std::tuple< SCFResults, PropertyResults, ConvergenceResults, OptimizationResults > SCFResultsTuple
Definition Results.h:750
bool has_data(const PropertyResults &p)
Definition Results.h:413
double wall_time()
Returns the wall time in seconds relative to an arbitrary origin.
Definition timers.cc:48
Tensor< T > tensor_in(const nlohmann::json &j)
Definition Results.h:49
void get_if_exists(const nlohmann::json &j, const std::string &key, std::optional< T > &opt, F &&from_json_fn)
Definition Results.h:40
void set_if_exists(nlohmann::json &j, const std::string &key, const std::optional< T > &opt, F &&to_json_fn)
Definition Results.h:34
static const double c
Definition relops.cc:10
static const double thresh
Definition rk.cc:45
Definition Results.h:529
double oscillator_strength_length
Definition Results.h:533
double omega
Definition Results.h:531
double oscillator_strength_velocity
Definition Results.h:534
std::string irrep
Definition Results.h:530
double current_error
Definition Results.h:532
Definition Results.h:258
std::optional< double > depol_int
Definition Results.h:266
std::optional< double > pol_int
Definition Results.h:265
double alpha2
Definition Results.h:263
int mode
Definition Results.h:259
std::optional< double > dep_ratio
Definition Results.h:268
double beta2
Definition Results.h:264
double freq_cm1
Definition Results.h:260
vector< FLOAT > opt(const vector< FLOAT > &x, const vector< FLOAT > &f, const vector< FLOAT > &w, const vector< FLOAT > &guess, int maxiter)
Definition y.cc:486