54 const std::string shooting_label =
"shooting";
55 const std::string perturbative_label =
"perturbative";
72 double time_in_ms{0.};
77 using Profiler_data = std::map<std::string, std::vector<Profiler_result> >;
82 "Usage: quartic_tabulate [OPTION] <dim> <min_alpha> <max_alpha> <alpha_step>\n\n" 83 "Calculate action for one-dimensional quartic potentials with alpha\n" 84 "varying between the given minimum and maximum values.\n\n" 85 "Example: quartic_tabulate 4 0.51 0.74 0.1\n\n" 87 " -a, --all-methods print results for all algorithms\n" 88 " -h, --help print this help message\n" 89 " -p, --perturbative use the perturbative algorithm\n" 90 " -v, --verbose produce verbose output" 94 bool starts_with(
const std::string& option,
const std::string& prefix)
96 return !option.compare(0, prefix.size(), prefix);
102 const auto n_positional_args = args.size();
104 if (n_positional_args == 0) {
106 "number of dimensions must be provided");
107 }
else if (n_positional_args == 1) {
109 "minimum value of alpha must be provided");
110 }
else if (n_positional_args == 2) {
112 "maximum value of alpha must be provided");
113 }
else if (n_positional_args == 3) {
115 "alpha increment must be provided");
116 }
else if (n_positional_args > 4) {
118 "unrecognized command line argument '" 123 options.
dim = std::stoi(args[0]);
124 }
catch (
const std::invalid_argument& e) {
126 "invalid number of dimensions '" + args[0] +
"'");
131 }
catch (
const std::invalid_argument& e) {
133 "invalid minimum value for alpha, '" + args[1] +
"'");
138 }
catch (
const std::invalid_argument& e) {
140 "invalid maximum value for alpha, '" + args[2] +
"'");
145 }
catch (
const std::invalid_argument& e) {
147 "invalid alpha increment, '" + args[3] +
"'");
155 std::vector<std::string> positional_args;
158 const std::string opt(argv[i++]);
161 positional_args.push_back(opt);
165 if (opt ==
"-a" || opt ==
"--all-methods") {
171 if (opt ==
"-h" || opt ==
"--help") {
176 if (opt ==
"-p" || opt ==
"--perturbative") {
182 if (opt ==
"-v" || opt ==
"--verbose") {
188 "unrecognized command line argument '" + opt +
"'");
199 using Clock_t = std::chrono::high_resolution_clock;
221 const auto start_time = Clock_t::now();
223 profiler.
solve(potential, false_min, true_min, barrier, dim,
224 Shooting::Solver_options::Compute_action);
226 }
catch (
const Error& e) {
228 result.
info = e.what();
230 const auto stop_time = Clock_t::now();
231 std::chrono::duration<double, std::milli> t_in_ms = stop_time - start_time;
240 using Clock_t = std::chrono::high_resolution_clock;
249 const double action_tol = 1.e-3;
250 const double fields_tol = 1.e-3;
252 std::make_shared<Relative_convergence_tester>(
253 action_tol, fields_tol));
255 auto root_finder = std::make_shared<Root_finder>();
258 Eigen::VectorXd true_vacuum(1);
261 Eigen::VectorXd false_vacuum(1);
269 const auto start_time = Clock_t::now();
273 }
catch (
const Error& e) {
275 result.
info = e.what();
277 const auto stop_time = Clock_t::now();
278 std::chrono::duration<double, std::milli> t_in_ms = stop_time - start_time;
285 const std::string& profiler,
288 if (profiler == shooting_label) {
290 }
else if (profiler == perturbative_label) {
295 "unrecognized profiler '" + profiler +
"'");
301 << std::setw(12) <<
"dim" <<
' ' 302 << std::setw(16) <<
"E" <<
' ' 303 << std::setw(16) <<
"alpha";
304 for (
const auto& profiler : profiler_labels) {
306 << std::setw(16) << profiler +
"_action" <<
' ' 307 << std::setw(16) << profiler +
"_time/ms" <<
' ' 308 << std::setw(12) << profiler +
"_error";
310 std::cout << std::endl;
316 std::vector<std::string> profilers;
317 for (
const auto& x : profiler_data) {
318 profilers.push_back(x.first);
323 const std::size_t n_rows = alpha_data.size();
324 for (std::size_t i = 0; i < n_rows; ++i) {
326 << std::setw(12) << dim <<
' ' 327 << std::setw(16) << std::setprecision(8)
328 << std::scientific << E <<
' ' 329 << std::setw(16) << std::setprecision(8)
330 << std::scientific << alpha_data[i];
332 std::string info =
"";
333 for (
const auto& profiler : profilers) {
334 const auto& data = profiler_data.at(profiler)[i];
336 << std::setw(16) << std::setprecision(8)
337 << std::scientific << data.action <<
' ' 338 << std::setw(16) << std::setprecision(8)
339 << std::scientific << data.time_in_ms <<
' ' 340 << std::setw(12) << data.error;
342 if (!data.info.empty()) {
346 info += profiler +
": " + data.info +
",";
350 std::cout << info << std::endl;
356 int main(
int argc,
const char* argv[])
361 std::cerr <<
"Usage: quartic_tabulate [OPTION] <dim> <min_alpha> <max_alpha> <alpha_step>\n" 362 <<
"Try 'quartic_tabulate --help' for more information." 377 < std::numeric_limits<double>::epsilon()) {
379 "alpha increment too small");
382 const bool forward_stepping = options.
alpha_step > 0.;
384 if ((forward_stepping && start_gt_end) ||
385 (!forward_stepping && !start_gt_end)) {
392 profiler_data[shooting_label] = std::vector<Profiler_result>();
396 profiler_data[perturbative_label] = std::vector<Profiler_result>();
403 alpha_data.push_back(alpha);
404 for (
auto& x : profiler_data) {
405 profiler_data[x.first].push_back(
414 }
catch (
const Error& e) {
415 std::cerr <<
"Error: " << e.what() << std::endl;
416 exit_code = EXIT_FAILURE;
418 std::cerr <<
"Error: unrecognized error occurred." 420 exit_code = EXIT_FAILURE;
void run_profiler(const Bubble_profiler_inputs &input)
Calculates the action and bubble profile for the given potential.
void set_shooting_rel_tol(double tol)
void parse_positional_args(const std::vector< std::string > &args, Fubini_options &options)
void calculate_bubble_profile(Potential &, Observer &)
void set_initial_guesser(std::shared_ptr< Profile_guesser > g)
void set_max_iterations(int i)
void set_false_vacuum_loc(const Eigen::VectorXd &fv)
std::tuple< double, Field_profiles > run_shooting_profiler(const Bubble_profiler_inputs &input)
Calculates the action and bubble profile using the shooting method.
void set_true_vacuum_loc(const Eigen::VectorXd &tv)
Bubble_profiler_inputs parse_cmd_line_args(int argc, const char *argv[])
void solve(const std::function< double(double)> &potential_, const std::function< double(double)> &potential_first_, const std::function< double(double)> &potential_second_, double false_min_, double true_min_, double barrier_, int dim_=3, unsigned int options=(Solver_options::Compute_action|Solver_options::Compute_profile))
void set_root_finder(std::shared_ptr< Root_finder< Eigen::VectorXd > > rf)
double get_euclidean_action() const
Retrieve the action after running calculate_bubble_profile.
void set_bisect_lambda_max(double l)
void write_table(int dim, double E, const std::vector< double > &alpha_data, const Profiler_data &profiler_data)
void set_convergence_tester(std::shared_ptr< Profile_convergence_tester > ct)
double get_global_minimum_location() const
auto abs(const Eigen::MatrixBase< Derived > &m) -> decltype(m.cwiseAbs())
static Logging_manager & get_manager()
double get_euclidean_action() const
std::map< std::string, std::vector< Profiler_result > > Profiler_data
void set_f_y_max(double f)
int main(int argc, const char *argv[])
void set_action_rel_tol(double tol)
void set_minimum_log_level(Log_level level)
void set_f_y_min(double f)
double get_local_maximum_location() const
void write_table_header(const std::vector< std::string > &profiler_labels)
void set_action_arrived_rel(double tol)
void set_action_abs_tol(double tol)
void set_max_periods(double p)
void set_drho_frac(double frac)
double get_local_minimum_location() const
std::tuple< double, Field_profiles > run_perturbative_profiler(const Bubble_profiler_inputs &input, Profiler &profiler)
Calculates the action and bubble profile using the perturbative method.
Solve the one-dimensional problem using the shooting method.
Exception indicating general setup error.
One-dimensional shooting method.
void set_number_of_dimensions(int d)
bool starts_with(const std::string &option, const std::string &prefix)
void set_initial_step_size(double h)
void set_shooting_abs_tol(double tol)
void set_bisection_precision_bits(int b)
Bounce solver using perturbative method.