ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
TuningLogger.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef ESPRESSO_SRC_CORE_P3M_TUNING_LOGGER_HPP
23#define ESPRESSO_SRC_CORE_P3M_TUNING_LOGGER_HPP
24
25#include "config/config.hpp"
26
27#if defined(P3M) || defined(DP3M)
28
29#include <utils/Vector.hpp>
30
31#include <cstdio>
32#include <string>
33
35public:
36 enum class Mode { Coulomb, Dipolar };
37 TuningLogger(bool verbose, std::string name, Mode mode)
38 : m_verbose{verbose}, m_name{std::move(name)}, m_mode{mode} {}
39
40 void log_tuning_start() const {
41 if (m_verbose) {
42 std::printf("mesh cao r_cut_iL alpha_L err "
43 "rs_err ks_err time [ms]\n");
44 }
45 }
46
47 template <typename... Types>
48 void log_success(double time, Types... parameter_set) const {
49 if (m_verbose) {
50 row(parameter_set...);
51 std::printf(" %-8.2f\n", time);
52 }
53 }
54
55 template <typename... Types>
56 void log_skip(std::string reason, Types... parameter_set) const {
57 if (m_verbose) {
58 row(parameter_set...);
59 std::printf(" %s\n", reason.c_str());
60 }
61 }
62
63 void log_cao_too_large(int mesh, int cao) const {
64 if (m_verbose) {
65 std::printf("%-4d %-3d cao too large for this mesh\n", mesh, cao);
66 }
67 }
68
69 void tuning_goals(double accuracy, double prefactor, double box_l,
70 int n_particles, double sum_prop) const {
71 if (m_verbose) {
72 std::string particle_trait;
73 std::string particle_property;
74 switch (m_mode) {
75 case Mode::Coulomb:
76 particle_trait = "charged";
77 particle_property = "Sum[q_i^2]";
78 break;
79 case Mode::Dipolar:
80 particle_trait = "magnetic";
81 particle_property = "Sum[mu_i^2]";
82 break;
83 }
84 std::printf("%s tune parameters: Accuracy goal = %.5e prefactor = %.5e\n"
85 "System: box_l = %.5e # %s part = %d %s = %.5e\n",
86 m_name.c_str(), accuracy, prefactor, box_l,
87 particle_trait.c_str(), n_particles,
88 particle_property.c_str(), sum_prop);
89 }
90 }
91
92 void tuning_results(Utils::Vector3i const &mesh, int cao, double r_cut_iL,
93 double alpha_L, double accuracy, double time) const {
94 if (m_verbose) {
95 std::printf(
96 "\nresulting parameters: mesh: (%d, %d, %d), cao: %d, r_cut_iL: %.4e,"
97 "\n alpha_L: %.4e, accuracy: %.4e, time: %.2f\n",
98 mesh[0], mesh[1], mesh[2], cao, r_cut_iL, alpha_L, accuracy, time);
99 }
100 }
101
102 void report_fixed_cao(int cao) const {
103 if (m_verbose) {
104 std::printf("fixed cao %d\n", cao);
105 }
106 }
107
108 void report_fixed_r_cut_iL(double r_cut_iL) const {
109 if (m_verbose) {
110 std::printf("fixed r_cut_iL %f\n", r_cut_iL);
111 }
112 }
113
114 void report_fixed_mesh(Utils::Vector3i const &mesh) const {
115 if (m_verbose) {
116 std::printf("fixed mesh (%d, %d, %d)\n", mesh[0], mesh[1], mesh[2]);
117 }
118 }
119
120 auto get_name() const { return m_name; }
121
122private:
123 bool m_verbose;
124 std::string m_name;
125 Mode m_mode;
126
127 void row(int mesh, int cao, double r_cut_iL, double alpha_L, double accuracy,
128 double rs_err, double ks_err) const {
129 std::printf("%-4d %-3d %.5e %.5e %.3e %.3e %.3e", mesh, cao, r_cut_iL,
130 alpha_L, accuracy, rs_err, ks_err);
131 }
132};
133
134#endif // P3M or DP3M
135
136#endif
Vector implementation and trait types for boost qvm interoperability.
TuningLogger(bool verbose, std::string name, Mode mode)
void tuning_goals(double accuracy, double prefactor, double box_l, int n_particles, double sum_prop) const
void log_tuning_start() const
void report_fixed_mesh(Utils::Vector3i const &mesh) const
void log_cao_too_large(int mesh, int cao) const
void log_skip(std::string reason, Types... parameter_set) const
void report_fixed_cao(int cao) const
auto get_name() const
void tuning_results(Utils::Vector3i const &mesh, int cao, double r_cut_iL, double alpha_L, double accuracy, double time) const
void log_success(double time, Types... parameter_set) const
void report_fixed_r_cut_iL(double r_cut_iL) const
This file contains the defaults for ESPResSo.