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();
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;
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;
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);
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 //
433 SCFResults() = default;
434
435 /// construct from JSON
436 SCFResults(const nlohmann::json &j) { from_json(j); }
437
438 std::string key() const override { return model; }
439
440 nlohmann::json to_json() const override {
441 nlohmann::json j;
442
443 // Required alpha pieces
444 j["scf_eigenvalues_a"] = tensor_out<double>(aeps);
445 j["scf_fock_a"] = tensor_out<double>(afock);
446
447 // Optional beta pieces
448 set_if_exists(j, "scf_eigenvalues_b", beps, tensor_out<double>);
449 set_if_exists(j, "scf_fock_b", bfock, tensor_out<double>);
450
451 // Scalars / metadata
452 j["model"] = model;
453 j["scf_total_energy"] = scf_total_energy;
454
455 // Optional nested block
456 if (has_data(properties)) {
457 j["properties"] = properties.to_json();
458 }
459
460 j["molecule"] = scf_molecule.to_json();
461 j["is_opt"] = is_opt;
462 return j;
463 }
464
465 void from_json(const nlohmann::json &j) override {
466 // Alpha: treat as required but read defensively
467 if (j.contains("scf_eigenvalues_a"))
468 aeps = tensor_in<double>(j.at("scf_eigenvalues_a"));
469 else
470 aeps = {}; // or throw if truly required
471
472 if (j.contains("scf_fock_a"))
473 afock = tensor_in<double>(j.at("scf_fock_a"));
474 else
475 afock = {}; // or throw if truly required
476
477 // Beta: optional
478 get_if_exists(j, "scf_eigenvalues_b", beps, tensor_in<double>);
479 get_if_exists(j, "scf_fock_b", bfock, tensor_in<double>);
480
481 // Scalars / metadata
482 if (j.contains("model"))
483 model = j.value("model", std::string("scf"));
484 if (j.contains("scf_total_energy"))
485 scf_total_energy = j.value("scf_total_energy", 0.0);
486
487 // Nested properties: optional
488 if (j.contains("properties")) {
490 p.from_json(j.at("properties"));
491 if (has_data(p))
492 properties = std::move(p);
493 } else {
495 }
496 if (j.contains("molecule"))
497 scf_molecule.from_json(j.at("molecule"));
498 else
499 MADNESS_EXCEPTION("Missing molecule data", j);
500 is_opt = j.value("is_opt", false);
501 }
502};
503// Todo: Upgrade to new JSON style using optional everything below here --
504//
505// ---------------------------------------------------------------------------------
506//
507//
508// ---------------------------------------------------------------------------------
509class CISResults : public ResultsBase {
510public:
512 std::string irrep; // irreducible representation
513 double omega; // excitation energy in Hartree
514 double current_error; // error in the excitation energy
515 double oscillator_strength_length; // oscillator strength
516 double oscillator_strength_velocity; // oscillator strength
517 };
518 std::vector<excitation_info> excitations;
519 long nfreeze = -1;
520 std::string model = "unknown";
521
522 std::string key() const override { return model; }
523
524 CISResults() = default;
525
526 /// construct from JSON
527 CISResults(const nlohmann::json &j) {
528 if (j.count("excitations") > 0) {
529 for (const auto &ex : j["excitations"]) {
531 ei.irrep = ex.value("irrep", "");
532 ei.omega = ex.value("omega", 0.0);
533 ei.current_error = ex.value("current_error", 0.0);
534 ei.oscillator_strength_length =
535 ex.value("oscillator_strength_length", 0.0);
536 ei.oscillator_strength_velocity =
537 ex.value("oscillator_strength_velocity", 0.0);
538 excitations.push_back(ei);
539 }
540 }
541 nfreeze = j.value("nfreeze", -1);
542 model = j.value("model", "unknown");
543 }
544
545 /// constructor with nfreeze and model
546 CISResults(long nfreeze, const std::string &model)
547 : nfreeze(nfreeze), model(model) {}
548
549 void from_json(const nlohmann::json &j) override {
550 excitations.clear();
551 if (j.count("excitations") > 0) {
552 for (const auto &ex : j["excitations"]) {
554 ei.irrep = ex.value("irrep", "");
555 ei.omega = ex.value("omega", 0.0);
556 ei.current_error = ex.value("current_error", 0.0);
557 ei.oscillator_strength_length =
558 ex.value("oscillator_strength_length", 0.0);
559 ei.oscillator_strength_velocity =
560 ex.value("oscillator_strength_velocity", 0.0);
561 excitations.push_back(ei);
562 }
563 }
564 nfreeze = j.value("nfreeze", -1);
565 model = j.value("model", "unknown");
566 }
567
568 nlohmann::json to_json() const override {
569 nlohmann::json j;
570 for (const auto &ex : excitations) {
571 nlohmann::json ex_json;
572 ex_json["irrep"] = ex.irrep;
573 ex_json["omega"] = ex.omega;
574 ex_json["current_error"] = ex.current_error;
575 ex_json["oscillator_strength_length"] = ex.oscillator_strength_length;
576 ex_json["oscillator_strength_velocity"] = ex.oscillator_strength_velocity;
577 j["excitations"].push_back(ex_json);
578 }
579 j["nfreeze"] = nfreeze;
580 j["model"] = model;
581 return j;
582 }
583};
584
585class CC2Results : public CISResults {
586public:
587 CC2Results() : CISResults() { model = "mp2"; }
588
589 PropertyResults properties; // properties of the correlated calculation
591 0.0; // correlation energy of the correlated calculation
592 double total_energy = 0.0; // total energy of the correlated calculation
593 /// construct from JSON
594 CC2Results(const nlohmann::json &j) : CISResults(j) {
595 properties = PropertyResults(j.value("properties", nlohmann::json{}));
596 model = j.value("model", "mp2");
597 correlation_energy = j.value("correlation_energy", 0.0);
598 total_energy = j.value(model + "_total_energy", 0.0);
599 }
600
601 /// constructor with nfreeze and model
602 CC2Results(long nfreeze, const std::string &model)
604
605 void from_json(const nlohmann::json &j) override {
607 properties = PropertyResults(j.value("properties", nlohmann::json{}));
608 model = j.value("model", "mp2");
609 correlation_energy = j.value("correlation_energy", 0.0);
610 total_energy = j.value(model + "_total_energy", 0.0);
611 }
612
613 nlohmann::json to_json() const override {
614 nlohmann::json j;
616 j["properties"] = properties.to_json();
617 j["model"] = model;
618 j["correlation_energy"] = correlation_energy;
619 j[model + "_correlation_energy"] = correlation_energy;
620 j[model + "_total_energy"] = total_energy;
621 return j;
622 }
623
624 CC2Results &set_energies(const double scf_energy, const double corr_energy) {
625 this->correlation_energy = corr_energy;
626 this->total_energy = scf_energy + corr_energy;
627 return *this;
628 }
629
630 /// setters with chaining
633 return *this;
634 }
636 this->total_energy = total_energy;
637 return *this;
638 }
641 return *this;
642 }
643 CC2Results &set_model(const std::string &model) {
644 this->model = model;
645 return *this;
646 }
647};
648
649class ZnemoResults : public SCFResults {
650public:
651 double B = 0.0; // B value for the Znemo calculation
652
653 ZnemoResults() = default;
654 /// construct from JSON
655 ZnemoResults(const nlohmann::json &j) : SCFResults(j) {
656 B = j.value("B", 0.0);
657 }
658
659 void from_json(const nlohmann::json &j) override {
661 B = j.value("B", 0.0);
662 }
663
664 nlohmann::json to_json() const override {
665 nlohmann::json j;
667 j["B"] = B;
668 return j;
669 }
670};
671
672class OEPResults : public SCFResults {
673public:
674 double drho = 0.0; // delta rho =difference to reference (=HF?) density
675 double devir14 = 0.0; // diagnostic parameter
676 double devir17 = 0.0; // diagnostic parameter
677 double Ex_vir = 0.0; // local exchange energy
678 double Ex_conv = 0.0; //
679 double Ex_HF = 0.0; // HF exchange energy
680 double E_kin_HF = 0.0;
681 double E_kin_KS = 0.0; // kinetic energy of the KS reference
682 double Econv = 0.0; // final energy using conventional method
683
684 OEPResults() = default;
685
686 void from_json(const nlohmann::json &j) override {
688 model = j.value("model", "oaep");
689 drho = j.value("drho", 0.0);
690 devir14 = j.value("devir14", 0.0);
691 devir17 = j.value("devir17", 0.0);
692 Ex_vir = j.value("Ex_vir", 0.0);
693 Ex_conv = j.value("Ex_conv", 0.0);
694 Ex_HF = j.value("Ex_HF", 0.0);
695 E_kin_HF = j.value("E_kin_HF", 0.0);
696 E_kin_KS = j.value("E_kin_KS", 0.0);
697 Econv = j.value("Econv", 0.0);
698 }
699
700 /// construct from JSON
701 explicit OEPResults(const nlohmann::json &j) : SCFResults(j) {
702 model = j.value("model", "oaep");
703 drho = j.value("drho", 0.0);
704 devir14 = j.value("dvir14", 0.0);
705 devir17 = j.value("dvir17", 0.0);
706 Ex_vir = j.value("Ex_vir", 0.0);
707 Ex_conv = j.value("Ex_conv", 0.0);
708 Ex_HF = j.value("Ex_HF", 0.0);
709 E_kin_HF = j.value("E_kin_HF", 0.0);
710 E_kin_KS = j.value("E_kin_KS", 0.0);
711 Econv = j.value("Econv", 0.0);
712 }
713
714 nlohmann::json to_json() const override {
715 nlohmann::json j;
717 j["model"] = model;
718 j["drho"] = drho;
719 j["devir14"] = devir14;
720 j["devir17"] = devir17;
721 j["Ex_vir"] = Ex_vir;
722 j["Ex_conv"] = Ex_conv;
723 j["Ex_HF"] = Ex_HF;
724 j["E_kin_HF"] = E_kin_HF;
725 j["E_kin_KS"] = E_kin_KS;
726 j["Econv"] = Econv;
727 return j;
728 }
729};
730
733
734} // namespace madness
735#endif // RESULTS_H
Definition test_ar.cc:141
simple class for testing the solver
Definition derivatives.cc:60
Definition Results.h:585
void from_json(const nlohmann::json &j) override
Definition Results.h:605
CC2Results & set_energies(const double scf_energy, const double corr_energy)
Definition Results.h:624
CC2Results & set_properties(const PropertyResults &props)
Definition Results.h:639
CC2Results(const nlohmann::json &j)
construct from JSON
Definition Results.h:594
CC2Results & set_total_energy(const double total_energy)
Definition Results.h:635
CC2Results(long nfreeze, const std::string &model)
constructor with nfreeze and model
Definition Results.h:602
CC2Results & set_model(const std::string &model)
Definition Results.h:643
double correlation_energy
Definition Results.h:590
CC2Results & set_correlation_energy(const double corr_energy)
setters with chaining
Definition Results.h:631
CC2Results()
Definition Results.h:587
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:613
PropertyResults properties
Definition Results.h:589
double total_energy
Definition Results.h:592
Definition Results.h:509
std::vector< excitation_info > excitations
Definition Results.h:518
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:568
CISResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:527
std::string model
Definition Results.h:520
std::string key() const override
Definition Results.h:522
void from_json(const nlohmann::json &j) override
Definition Results.h:549
long nfreeze
Definition Results.h:519
CISResults(long nfreeze, const std::string &model)
constructor with nfreeze and model
Definition Results.h:546
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:672
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:714
double Ex_vir
Definition Results.h:677
double devir14
Definition Results.h:675
double Econv
Definition Results.h:682
double Ex_HF
Definition Results.h:679
void from_json(const nlohmann::json &j) override
Definition Results.h:686
double drho
Definition Results.h:674
OEPResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:701
double E_kin_KS
Definition Results.h:681
double Ex_conv
Definition Results.h:678
double E_kin_HF
Definition Results.h:680
double devir17
Definition Results.h:676
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
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:440
std::string model
Definition Results.h:429
Tensor< double > aeps
Definition Results.h:421
void from_json(const nlohmann::json &j) override
Definition Results.h:465
double scf_total_energy
Definition Results.h:430
SCFResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:436
PropertyResults properties
Definition Results.h:432
Tensor< double > afock
Definition Results.h:422
bool is_opt
Definition Results.h:427
std::string key() const override
Definition Results.h:438
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:1419
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:649
void from_json(const nlohmann::json &j) override
Definition Results.h:659
nlohmann::json to_json() const override
serialize the results to a JSON object
Definition Results.h:664
double B
Definition Results.h:651
ZnemoResults(const nlohmann::json &j)
construct from JSON
Definition Results.h:655
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 DFParameters.h:10
nlohmann::json tensor_out(const Tensor< T > &t)
Definition Results.h:46
std::tuple< SCFResults, PropertyResults, ConvergenceResults, OptimizationResults > SCFResultsTuple
Definition Results.h:732
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
static XNonlinearSolver< std::vector< Function< T, NDIM > >, T, vector_function_allocator< T, NDIM > > nonlinear_vector_solver(World &world, const long nvec)
Definition nonlinsol.h:371
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 thresh
Definition rk.cc:45
Definition Results.h:511
double oscillator_strength_length
Definition Results.h:515
double omega
Definition Results.h:513
double oscillator_strength_velocity
Definition Results.h:516
std::string irrep
Definition Results.h:512
double current_error
Definition Results.h:514
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