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