68 "Usage: logarithmic [OPTION] <m> <w>\n\n" 69 "Calculate action and field profile for one-dimensional logarthmic\n" 70 "potential characterized by the parameters m and w.\n\n" 71 "Example: logarithmic -c -o 'output.txt' 1 1\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 m must be provided");
109 }
else if (n_positional_args == 1) {
111 "value of w must be provided");
112 }
else if (n_positional_args > 2) {
114 "unrecognized command line argument '" 119 options.
m = std::stod(args[0]);
120 }
catch (
const std::invalid_argument& e) {
122 "invalid value of m, '" + args[0] +
"'");
126 options.
w = std::stod(args[1]);
127 }
catch (
const std::invalid_argument& e) {
129 "invalid value for w, '" + args[1] +
"'");
137 "'-g' or '--global-minimum' given but no value specified");
142 global_min = std::stod(value);
143 }
catch (
const std::invalid_argument& e) {
145 "invalid global minimum location '" + value +
"'");
148 if (global_min <= 0.) {
150 "explicitly specified true vacuum must be positive");
160 std::vector<std::string> positional_args;
163 const std::string opt(argv[i++]);
166 positional_args.push_back(opt);
170 if (opt ==
"-c" || opt ==
"--calculate-profile") {
178 "'-g' given but no value for true vacuum provided");
180 const std::string value(argv[i++]);
191 if (opt ==
"-h" || opt ==
"--help") {
199 "'-o' given but no output file name provided");
201 const std::string filename(argv[i++]);
202 if (
starts_with(filename,
"-") && filename !=
"-") {
204 "'-o' given but no output file name provided");
212 if (filename.empty()) {
214 "'--output-file=' given but no output file name provided");
223 "'-P' given but no file name provided");
225 const std::string filename(argv[i++]);
226 if (
starts_with(filename,
"-") && filename !=
"-") {
228 "'-P' given but no file name provided");
236 if (filename.empty()) {
238 "'--perturbations-file=' given but no file name provided");
244 if (opt ==
"-p" || opt ==
"--perturbative") {
249 if (opt ==
"-v" || opt ==
"--verbose") {
255 "unrecognized command line argument '" + opt +
"'");
273 = calculate_profile ?
274 (Shooting::Solver_options::Compute_action |
275 Shooting::Solver_options::Compute_profile)
276 : Shooting::Solver_options::Compute_action;
282 profiler.
solve(potential, false_min, true_min, barrier, dim,
285 if ((options & Shooting::Solver_options::Compute_action) != 0) {
289 if ((options & Shooting::Solver_options::Compute_profile) != 0) {
293 return std::make_tuple(action, profile);
298 const std::string& observer_file)
308 const double action_tol = 1.e-3;
309 const double fields_tol = 1.e-3;
311 std::make_shared<Relative_convergence_tester>(
312 action_tol, fields_tol));
314 auto root_finder = std::make_shared<Root_finder>();
319 Eigen::VectorXd true_vacuum(1);
320 true_vacuum << true_min;
322 Eigen::VectorXd false_vacuum(1);
332 if (observer_file.empty()) {
341 return std::make_tuple(action, profile);
348 << std::setw(16) <<
"rho" <<
' ' 349 << std::setw(16) <<
"numeric" <<
' ' 350 << std::setw(16) <<
"exact" << std::endl;
355 "number of grid points do not match in numerical and exact solution");
362 for (
int i = 0; i < n_grid_points; ++i) {
364 << std::setw(16) << std::setprecision(8)
365 << std::scientific << rho_values(i) <<
' ' 366 << std::setw(16) << std::setprecision(8)
367 << std::scientific << numerical_values(i, 0) <<
' ' 368 << std::setw(16) << std::setprecision(8)
369 << std::scientific << exact_values(i, 0) << std::endl;
373 void write_action(std::ostream& ostr,
double numerical_action,
376 const double rel_diff = (numerical_action - exact_action)
377 / (0.5 * (numerical_action + exact_action));
379 ostr <<
"# Numerical action = " 380 << std::setprecision(8) << std::scientific << numerical_action
382 ostr <<
"# Exact action = " 383 << std::setprecision(8) << std::scientific << exact_action
385 ostr <<
"# Relative error = " 386 << std::setprecision(8) << std::scientific << rel_diff
392 int main(
int argc,
const char* argv[])
397 std::cerr <<
"Usage: logarithmic [OPTION] <m> <w>\n" 398 <<
"Try 'logarithmic --help' for more information." 420 if (potential(options.
global_min) > potential(local_min)) {
422 "true minimum of potential greater than false minimum");
425 std::tuple<double, Field_profiles> result;
436 output_file.open(options.
output_file, std::ios::out);
439 std::ostream& output_stream
446 write_profile(output_stream, std::get<1>(result), exact_profile);
449 const double exact_action = potential.
get_action();
450 write_action(output_stream, std::get<0>(result), exact_action);
452 std::cerr <<
"Error: " << e.what() << std::endl;
453 exit_code = EXIT_FAILURE;
455 std::cerr <<
"Error: " << e.what() << std::endl;
456 exit_code = EXIT_FAILURE;
458 std::cerr <<
"Error: " << e.what() << std::endl;
459 exit_code = EXIT_FAILURE;
460 }
catch (
const Error& e) {
461 std::cerr <<
"Error: " << e.what() << std::endl;
462 exit_code = EXIT_FAILURE;
464 std::cerr <<
"Error: unrecognized error occurred." 466 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.
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)
auto abs(const Eigen::MatrixBase< Derived > &m) -> decltype(m.cwiseAbs())
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_minimum_location() const
void set_minimum_log_level(Log_level level)
void write_action(double action, std::ostream &ostr)
Write the value of the action to requested output stream.
double get_action() const
Field_profiles get_profile(const Eigen::VectorXd &) const
int main(int argc, const char *argv[])
std::string perturbations_file
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)
double get_local_maximum_location() const
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.