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
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 {
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"])
313 }
314 if (j.contains("polarizability_derivatives_normal_modes")) {
316 for (const auto &pd : j["polarizability_derivatives_normal_modes"])
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(
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 /// atomic charges and spin populations by scheme (SCF::population_analysis)
372 std::optional<nlohmann::json> populations;
373
374 PropertyResults() = default;
375
376 /// construct from JSON
377 PropertyResults(const nlohmann::json &j) {
378 energy = j.value("energy", 0.0);
379 if (j.count("dipole") == 1)
380 dipole = tensor_from_json<double>(j["dipole"]);
381 if (j.count("gradient") == 1)
382 gradient = tensor_from_json<double>(j["gradient"]);
383 if (j.count("populations") == 1)
384 populations = j["populations"];
385 }
386
387 std::string key() const override { return "properties"; }
388
389 nlohmann::json to_json() const override {
390 nlohmann::json j;
391 j["energy"] = energy;
394 if (vibrations && vibrations->has_data())
395 j["vibrations"] = vibrations->to_json();
396 if (populations)
397 j["populations"] = *populations;
398 return j;
399 } // from json PropertyResults
400
401 void from_json(const nlohmann::json &j) override {
402 // robust reads (won’t throw if missing)
403 if (j.contains("energy"))
404 energy = j.value("energy", 0.0);
407
408 // nested section
409 if (j.contains("vibrations")) {
411 vib.from_json(j.at("vibrations"));
412 if (vib.has_data())
413 vibrations = std::move(vib);
414 }
415 if (j.contains("populations"))
416 populations = j.at("populations");
417 }
418};
419
420// If you keep PropertyResults from earlier, give it:
421inline bool has_data(const PropertyResults &p) {
422 return p.energy != 0.0 || p.dipole || p.gradient ||
423 (p.vibrations && p.vibrations->has_data()) || p.populations;
424}
425
426class SCFResults : public ResultsBase {
427public:
428 // Required alpha (for RHF/ ROHF/ UHF UKS we alsways expect alpha)
432 // optional beta (only for UHF/ UKS)
433 std::optional<Tensor<double>> beps;
434 std::optional<Tensor<double>> bfock;
435 bool is_opt = false;
436
437 std::string model = "scf"; // model used for the SCF calculation
438 double scf_total_energy = 0.0; // total energy of the SCF calculation
439 // empirical dispersion (DFT-D3) contribution already contained in
440 // scf_total_energy; 0.0 when no correction was applied
442 bool uses_dftd3 = false;
443 bool uses_pcm = false;
444 bool uses_libxc = false;
445 //
447 SCFResults() = default;
448
449 /// construct from JSON
450 SCFResults(const nlohmann::json &j) { from_json(j); }
451
452 std::string key() const override { return model; }
453
454 nlohmann::json to_json() const override {
455 nlohmann::json j;
456
457 // Required alpha pieces
458 j["scf_eigenvalues_a"] = tensor_out<double>(aeps);
459 j["scf_fock_a"] = tensor_out<double>(afock);
460
461 // Optional beta pieces
462 set_if_exists(j, "scf_eigenvalues_b", beps, tensor_out<double>);
463 set_if_exists(j, "scf_fock_b", bfock, tensor_out<double>);
464
465 // Scalars / metadata
466 j["model"] = model;
467 j["scf_total_energy"] = scf_total_energy;
468 j["scf_dispersion_correction_energy"] = scf_dispersion_correction_energy;
469 j["citations"] = {{"dftd3", uses_dftd3},
470 {"pcm", uses_pcm},
471 {"libxc", uses_libxc}};
472
473 // Optional nested block
474 if (has_data(properties)) {
475 j["properties"] = properties.to_json();
476 }
477
478 j["molecule"] = scf_molecule.to_json();
479 j["is_opt"] = is_opt;
480 return j;
481 }
482
483 void from_json(const nlohmann::json &j) override {
484 // Alpha: treat as required but read defensively
485 if (j.contains("scf_eigenvalues_a"))
486 aeps = tensor_in<double>(j.at("scf_eigenvalues_a"));
487 else
488 aeps = {}; // or throw if truly required
489
490 if (j.contains("scf_fock_a"))
491 afock = tensor_in<double>(j.at("scf_fock_a"));
492 else
493 afock = {}; // or throw if truly required
494
495 // Beta: optional
496 get_if_exists(j, "scf_eigenvalues_b", beps, tensor_in<double>);
497 get_if_exists(j, "scf_fock_b", bfock, tensor_in<double>);
498
499 // Scalars / metadata
500 if (j.contains("model"))
501 model = j.value("model", std::string("scf"));
502 if (j.contains("scf_total_energy"))
503 scf_total_energy = j.value("scf_total_energy", 0.0);
505 j.value("scf_dispersion_correction_energy", 0.0);
506 if (j.contains("citations") && j["citations"].is_object()) {
507 const auto &c = j["citations"];
508 uses_dftd3 = c.value("dftd3", false);
509 uses_pcm = c.value("pcm", false);
510 uses_libxc = c.value("libxc", false);
511 }
512
513 // Nested properties: optional
514 if (j.contains("properties")) {
516 p.from_json(j.at("properties"));
517 if (has_data(p))
518 properties = std::move(p);
519 } else {
521 }
522 if (j.contains("molecule"))
523 scf_molecule.from_json(j.at("molecule"));
524 else
525 MADNESS_EXCEPTION("Missing molecule data", j);
526 is_opt = j.value("is_opt", false);
527 }
528};
529// Todo: Upgrade to new JSON style using optional everything below here --
530//
531// ---------------------------------------------------------------------------------
532//
533//
534// ---------------------------------------------------------------------------------
535class CISResults : public ResultsBase {
536public:
538 std::string irrep; // irreducible representation
539 double omega; // excitation energy in Hartree
540 double current_error; // error in the excitation energy
541 double oscillator_strength_length; // oscillator strength
542 double oscillator_strength_velocity; // oscillator strength
543 };
544 std::vector<excitation_info> excitations;
545 long nfreeze = -1;
546 std::string model = "unknown";
547
548 std::string key() const override { return model; }
549
550 CISResults() = default;
551
552 /// construct from JSON
553 CISResults(const nlohmann::json &j) {
554 if (j.count("excitations") > 0) {
555 for (const auto &ex : j["excitations"]) {
557 ei.irrep = ex.value("irrep", "");
558 ei.omega = ex.value("omega", 0.0);
559 ei.current_error = ex.value("current_error", 0.0);
561 ex.value("oscillator_strength_length", 0.0);
563 ex.value("oscillator_strength_velocity", 0.0);
564 excitations.push_back(ei);
565 }
566 }
567 nfreeze = j.value("nfreeze", -1);
568 model = j.value("model", "unknown");
569 }
570
571 /// constructor with nfreeze and model
572 CISResults(long nfreeze, const std::string &model)
573 : nfreeze(nfreeze), model(model) {}
574
575 void from_json(const nlohmann::json &j) override {
576 excitations.clear();
577 if (j.count("excitations") > 0) {
578 for (const auto &ex : j["excitations"]) {
580 ei.irrep = ex.value("irrep", "");
581 ei.omega = ex.value("omega", 0.0);
582 ei.current_error = ex.value("current_error", 0.0);
584 ex.value("oscillator_strength_length", 0.0);
586 ex.value("oscillator_strength_velocity", 0.0);
587 excitations.push_back(ei);
588 }
589 }
590 nfreeze = j.value("nfreeze", -1);
591 model = j.value("model", "unknown");
592 }
593
594 nlohmann::json to_json() const override {
595 nlohmann::json j;
596 for (const auto &ex : excitations) {
597 nlohmann::json ex_json;
598 ex_json["irrep"] = ex.irrep;
599 ex_json["omega"] = ex.omega;
600 ex_json["current_error"] = ex.current_error;
601 ex_json["oscillator_strength_length"] = ex.oscillator_strength_length;
602 ex_json["oscillator_strength_velocity"] = ex.oscillator_strength_velocity;
603 j["excitations"].push_back(ex_json);
604 }
605 j["nfreeze"] = nfreeze;
606 j["model"] = model;
607 return j;
608 }
609};
610
611class CC2Results : public CISResults {
612public:
613 CC2Results() : CISResults() { model = "mp2"; }
614
615 PropertyResults properties; // properties of the correlated calculation
617 0.0; // correlation energy of the correlated calculation
618 double total_energy = 0.0; // total energy of the correlated calculation
619 /// construct from JSON
620 CC2Results(const nlohmann::json &j) : CISResults(j) {
621 properties = PropertyResults(j.value("properties", nlohmann::json{}));
622 model = j.value("model", "mp2");
623 correlation_energy = j.value("correlation_energy", 0.0);
624 total_energy = j.value(model + "_total_energy", 0.0);
625 }
626
627 /// constructor with nfreeze and model
628 CC2Results(long nfreeze, const std::string &model)
630
631 void from_json(const nlohmann::json &j) override {
633 properties = PropertyResults(j.value("properties", nlohmann::json{}));
634 model = j.value("model", "mp2");
635 correlation_energy = j.value("correlation_energy", 0.0);
636 total_energy = j.value(model + "_total_energy", 0.0);
637 }
638
639 nlohmann::json to_json() const override {
640 nlohmann::json j;
642 j["properties"] = properties.to_json();
643 j["model"] = model;
644 j["correlation_energy"] = correlation_energy;
645 j[model + "_correlation_energy"] = correlation_energy;
646 j[model + "_total_energy"] = total_energy;
647 return j;
648 }
649
650 CC2Results &set_energies(const double scf_energy, const double corr_energy) {
651 this->correlation_energy = corr_energy;
652 this->total_energy = scf_energy + corr_energy;
653 return *this;
654 }
655
656 /// setters with chaining
657 CC2Results &set_correlation_energy(const double corr_energy) {
658 correlation_energy = corr_energy;
659 return *this;
660 }
662 this->total_energy = total_energy;
663 return *this;
664 }
666 properties = props;
667 return *this;
668 }
669 CC2Results &set_model(const std::string &model) {
670 this->model = model;
671 return *this;
672 }
673};
674
675class ZnemoResults : public SCFResults {
676public:
677 double B = 0.0; // B value for the Znemo calculation
678
679 ZnemoResults() = default;
680 /// construct from JSON
681 ZnemoResults(const nlohmann::json &j) : SCFResults(j) {
682 B = j.value("B", 0.0);
683 }
684
685 void from_json(const nlohmann::json &j) override {
687 B = j.value("B", 0.0);
688 }
689
690 nlohmann::json to_json() const override {
691 nlohmann::json j;
693 j["B"] = B;
694 return j;
695 }
696};
697
698class OEPResults : public SCFResults {
699public:
700 double drho = 0.0; // delta rho =difference to reference (=HF?) density
701 double devir14 = 0.0; // diagnostic parameter
702 double devir17 = 0.0; // diagnostic parameter
703 double Ex_vir = 0.0; // local exchange energy
704 double Ex_conv = 0.0; //
705 double Ex_HF = 0.0; // HF exchange energy
706 double E_kin_HF = 0.0;
707 double E_kin_KS = 0.0; // kinetic energy of the KS reference
708 double Econv = 0.0; // final energy using conventional method
709
710 OEPResults() = default;
711
712 void from_json(const nlohmann::json &j) override {
714 model = j.value("model", "oaep");
715 drho = j.value("drho", 0.0);
716 devir14 = j.value("devir14", 0.0);
717 devir17 = j.value("devir17", 0.0);
718 Ex_vir = j.value("Ex_vir", 0.0);
719 Ex_conv = j.value("Ex_conv", 0.0);
720 Ex_HF = j.value("Ex_HF", 0.0);
721 E_kin_HF = j.value("E_kin_HF", 0.0);
722 E_kin_KS = j.value("E_kin_KS", 0.0);
723 Econv = j.value("Econv", 0.0);
724 }
725
726 /// construct from JSON
727 explicit OEPResults(const nlohmann::json &j) : SCFResults(j) {
728 model = j.value("model", "oaep");
729 drho = j.value("drho", 0.0);
730 devir14 = j.value("dvir14", 0.0);
731 devir17 = j.value("dvir17", 0.0);
732 Ex_vir = j.value("Ex_vir", 0.0);
733 Ex_conv = j.value("Ex_conv", 0.0);
734 Ex_HF = j.value("Ex_HF", 0.0);
735 E_kin_HF = j.value("E_kin_HF", 0.0);
736 E_kin_KS = j.value("E_kin_KS", 0.0);
737 Econv = j.value("Econv", 0.0);
738 }
739
740 nlohmann::json to_json() const override {
741 nlohmann::json j;
743 j["model"] = model;
744 j["drho"] = drho;
745 j["devir14"] = devir14;
746 j["devir17"] = devir17;
747 j["Ex_vir"] = Ex_vir;
748 j["Ex_conv"] = Ex_conv;
749 j["Ex_HF"] = Ex_HF;
750 j["E_kin_HF"] = E_kin_HF;
751 j["E_kin_KS"] = E_kin_KS;
752 j["Econv"] = Econv;
753 return j;
754 }
755};
756
759
760} // namespace madness
761#endif // RESULTS_H
simple class for testing the solver
Definition derivatives.cc:60
void from_json(const nlohmann::json &j) override
Definition Results.h:631
CC2Results & set_energies(const double scf_energy, const double corr_energy)
Definition Results.h:650
CC2Results & set_properties(const PropertyResults &props)
Definition Results.h:665
CC2Results(const nlohmann::json &j)
construct from JSON
Definition Results.h:620
CC2Results & set_total_energy(const double total_energy)
Definition Results.h:661
CC2Results(long nfreeze, const std::string &model)
constructor with nfreeze and model
Definition Results.h:628
CC2Results & set_model(const std::string &model)
Definition Results.h:669
double correlation_energy
Definition Results.h:616
CC2Results & set_correlation_energy(const double corr_energy)
setters with chaining
Definition Results.h:657
CC2Results()
Definition Results.h:613
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:639
PropertyResults properties
Definition Results.h:615
double total_energy
Definition Results.h:618
std::vector< excitation_info > excitations
Definition Results.h:544
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:594
CISResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:553
std::string model
Definition Results.h:546
std::string key() const override
Definition Results.h:548
void from_json(const nlohmann::json &j) override
Definition Results.h:575
long nfreeze
Definition Results.h:545
CISResults(long nfreeze, const std::string &model)
constructor with nfreeze and model
Definition Results.h:572
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
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
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:740
double Ex_vir
Definition Results.h:703
double devir14
Definition Results.h:701
double Econv
Definition Results.h:708
double Ex_HF
Definition Results.h:705
void from_json(const nlohmann::json &j) override
Definition Results.h:712
double drho
Definition Results.h:700
OEPResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:727
double E_kin_KS
Definition Results.h:707
double Ex_conv
Definition Results.h:704
double E_kin_HF
Definition Results.h:706
double devir17
Definition Results.h:702
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:387
PropertyResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:377
std::optional< nlohmann::json > populations
atomic charges and spin populations by scheme (SCF::population_analysis)
Definition Results.h:372
std::optional< VibrationalResults > vibrations
Definition Results.h:369
void from_json(const nlohmann::json &j) override
Definition Results.h:401
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:389
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
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:426
std::optional< Tensor< double > > bfock
Definition Results.h:434
Molecule scf_molecule
Definition Results.h:431
double scf_dispersion_correction_energy
Definition Results.h:441
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:454
std::string model
Definition Results.h:437
Tensor< double > aeps
Definition Results.h:429
bool uses_dftd3
Definition Results.h:442
void from_json(const nlohmann::json &j) override
Definition Results.h:483
double scf_total_energy
Definition Results.h:438
SCFResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:450
PropertyResults properties
Definition Results.h:446
bool uses_pcm
Definition Results.h:443
Tensor< double > afock
Definition Results.h:430
bool is_opt
Definition Results.h:435
std::string key() const override
Definition Results.h:452
bool uses_libxc
Definition Results.h:444
std::optional< Tensor< double > > beps
Definition Results.h:433
A tensor is a multidimensional array.
Definition tensor.h:313
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
void from_json(const nlohmann::json &j) override
Definition Results.h:685
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:690
double B
Definition Results.h:677
ZnemoResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:681
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
double FunctionDefaults< NDIM >::thresh
Definition mraimpl.h:3879
nlohmann::json tensor_out(const Tensor< T > &t)
Definition Results.h:46
std::tuple< SCFResults, PropertyResults, ConvergenceResults, OptimizationResults > SCFResultsTuple
Definition Results.h:757
bool has_data(const PropertyResults &p)
Definition Results.h:421
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
Definition Results.h:537
double oscillator_strength_length
Definition Results.h:541
double omega
Definition Results.h:539
double oscillator_strength_velocity
Definition Results.h:542
std::string irrep
Definition Results.h:538
double current_error
Definition Results.h:540
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