68 "Usage: fubini [OPTION] <u> <v> <m>\n\n" 69 "Calculate action and field profile for one-dimensional binomial\n" 70 "potential characterized by the parameters u, v, and m.\n\n" 71 "Example: fubini -c -o 'output.txt' 1 1 3\n\n" 73 " -c, --calculate-profile calculate field profile as well\n" 74 " -g, --global-minimum=MIN use MIN as location of true vacuum\n" 75 " -h, --help print this help message\n" 76 " -o, --output-file=FILE write results to FILE\n" 77 " -P, --perturbations-file=FILE write perturbations to FILE\n" 78 " -p, --perturbative use the perturbative algorithm\n" 79 " -v, --verbose produce verbose output" 83 bool starts_with(
const std::string& option,
const std::string& prefix)
85 return !option.compare(0, prefix.size(), prefix);
89 const std::string& sep =
"=")
91 std::string value{
""};
92 const auto prefix_end = option.find(sep);
94 if (prefix_end != std::string::npos) {
95 value = option.substr(prefix_end + 1);
104 const auto n_positional_args = args.size();
106 if (n_positional_args == 0) {
108 "value of u must be provided");
109 }
else if (n_positional_args == 1) {
111 "value of v must be provided");
112 }
else if (n_positional_args == 2) {
114 "value of m must be provided");
115 }
else if (n_positional_args > 3) {
117 "unrecognized command line argument '" 122 options.
u = std::stod(args[0]);
123 }
catch (
const std::invalid_argument& e) {
125 "invalid value of u, '" + args[0] +
"'");
129 options.
v = std::stod(args[1]);
130 }
catch (
const std::invalid_argument& e) {
132 "invalid value for v, '" + args[1] +
"'");
136 options.
m = std::stod(args[2]);
137 }
catch (
const std::invalid_argument& e) {
139 "invalid value for m, '" + args[2] +
"'");
147 "'-g' or '--global-minimum' given but no value specified");
152 global_min = std::stod(value);
153 }
catch (
const std::invalid_argument& e) {
155 "invalid global minimum location '" + value +
"'");
158 if (global_min <= 0.) {
160 "explicitly specified true vacuum must be positive");
170 std::vector<std::string> positional_args;
173 const std::string opt(argv[i++]);
176 positional_args.push_back(opt);
180 if (opt ==
"-c" || opt ==
"--calculate-profile") {
188 "'-g' given but no value for true vacuum provided");
190 const std::string value(argv[i++]);
201 if (opt ==
"-h" || opt ==
"--help") {
209 "'-o' given but no output file name provided");
211 const std::string filename(argv[i++]);
212 if (
starts_with(filename,
"-") && filename !=
"-") {
214 "'-o' given but no output file name provided");
222 if (filename.empty()) {
224 "'--output-file=' given but no output file name provided");
233 "'-P' given but no file name provided");
235 const std::string filename(argv[i++]);
236 if (
starts_with(filename,
"-") && filename !=
"-") {
238 "'-P' given but no file name provided");
246 if (filename.empty()) {
248 "'--perturbations-file=' given but no file name provided");
254 if (opt ==
"-p" || opt ==
"--perturbative") {
259 if (opt ==
"-v" || opt ==
"--verbose") {
265 "unrecognized command line argument '" + opt +
"'");
283 = calculate_profile ?
284 (Shooting::Solver_options::Compute_action |
285 Shooting::Solver_options::Compute_profile)
286 : Shooting::Solver_options::Compute_action;
292 profiler.
solve(potential, false_min, true_min, barrier, dim,
295 if ((options & Shooting::Solver_options::Compute_action) != 0) {
299 if ((options & Shooting::Solver_options::Compute_profile) != 0) {
303 return std::make_tuple(action, profile);
308 const std::string& observer_file)
318 const double action_tol = 1.e-3;
319 const double fields_tol = 1.e-3;
321 std::make_shared<Relative_convergence_tester>(
322 action_tol, fields_tol));
324 auto root_finder = std::make_shared<Root_finder>();
329 Eigen::VectorXd true_vacuum(1);
330 true_vacuum << true_min;
332 Eigen::VectorXd false_vacuum(1);
342 if (observer_file.empty()) {
351 return std::make_tuple(action, profile);
358 << std::setw(16) <<
"rho" <<
' ' 359 << std::setw(16) <<
"numeric" <<
' ' 360 << std::setw(16) <<
"exact" << std::endl;
365 "number of grid points do not match in numerical and exact solution");
372 for (
int i = 0; i < n_grid_points; ++i) {
374 << std::setw(16) << std::setprecision(8)
375 << std::scientific << rho_values(i) <<
' ' 376 << std::setw(16) << std::setprecision(8)
377 << std::scientific << numerical_values(i, 0) <<
' ' 378 << std::setw(16) << std::setprecision(8)
379 << std::scientific << exact_values(i, 0) << std::endl;
386 const double rel_diff = (numerical_action - exact_action)
387 / (0.5 * (numerical_action + exact_action));
389 ostr <<
"# Numerical action = " 390 << std::setprecision(8) << std::scientific << numerical_action
392 ostr <<
"# Exact action = " 393 << std::setprecision(8) << std::scientific << exact_action
395 ostr <<
"# Relative error = " 396 << std::setprecision(8) << std::scientific << rel_diff
402 int main(
int argc,
const char* argv[])
407 std::cerr <<
"Usage: fubini [OPTION] <u> <v> <m>\n" 408 <<
"Try 'fubini --help' for more information." 430 if (potential(options.
global_min) > potential(local_min)) {
432 "true minimum of potential greater than false minimum");
435 std::tuple<double, Field_profiles> result;
446 output_file.open(options.
output_file, std::ios::out);
449 std::ostream& output_stream
456 write_profile(output_stream, std::get<1>(result), exact_profile);
459 const double exact_action = potential.
get_action();
460 write_action(output_stream, std::get<0>(result), exact_action);
462 std::cerr <<
"Error: " << e.what() << std::endl;
463 exit_code = EXIT_FAILURE;
465 std::cerr <<
"Error: " << e.what() << std::endl;
466 exit_code = EXIT_FAILURE;
468 std::cerr <<
"Error: " << e.what() << std::endl;
469 exit_code = EXIT_FAILURE;
470 }
catch (
const Error& e) {
471 std::cerr <<
"Error: " << e.what() << std::endl;
472 exit_code = EXIT_FAILURE;
474 std::cerr <<
"Error: unrecognized error occurred." 476 exit_code = EXIT_FAILURE;
contains the definition of the Field_profiles clas
Exception indicating failure to integrate BVP.
void parse_positional_args(const std::vector< std::string > &args, Fubini_options &options)
void calculate_bubble_profile(Potential &, Observer &)
std::tuple< double, Field_profiles > solve_perturbative(Generalized_fubini_potential &potential, double true_min, const std::string &observer_file)
void set_initial_guesser(std::shared_ptr< Profile_guesser > g)
const Eigen::VectorXd & get_spatial_grid() const
Get a vector of the grid point coordinates.
double get_action() const
void set_false_vacuum_loc(const Eigen::VectorXd &fv)
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.
std::string get_option_value(const std::string &option, const std::string &sep="=")
void write_profile(std::ostream &ostr, const Field_profiles &numerical_profile, const Field_profiles &exact_profile)
void set_convergence_tester(std::shared_ptr< Profile_convergence_tester > ct)
static Logging_manager & get_manager()
const Field_profiles & get_bubble_profile() const
double get_euclidean_action() const
int get_number_of_grid_points() const
std::tuple< double, Field_profiles > solve_shooting(const Generalized_fubini_potential &potential, double true_min, bool calculate_profile)
double get_local_maximum_location() const
void set_minimum_log_level(Log_level level)
int main(int argc, const char *argv[])
void write_action(double action, std::ostream &ostr)
Write the value of the action to requested output stream.
double get_local_minimum_location() const
double parse_global_min(const std::string &value)
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)
std::string perturbations_file
bool starts_with(const std::string &option, const std::string &prefix)
void set_initial_step_size(double h)
Exception indicating generic numerical error.
const Field_profiles & get_bubble_profile() const
Retrieve the field profiles after running calculate_bubble_profile.
Discretized set of field profiles.
Bounce solver using perturbative method.
const Eigen::MatrixXd & get_field_profiles() const
Get the field profile data in matrix form.
Field_profiles get_profile(const Eigen::VectorXd &) const