Loading...
Searching...
No Matches
CommandLine.cpp File Reference
#include "eon/CommandLine.h"
#include "eon/Matter.h"
#include "eon/Parameters.h"
#include "eon/Potential.h"
#include "version.h"
#include <argum.h>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <memory>
#include <optional>
#include <sstream>
#include <string>

Go to the source code of this file.

Namespaces

namespace  eonc
 RAII resource manager for the ARTn C library with global synchronization.

Functions

BasicColorizer< char > colorizer (colorScheme)
void singlePoint (std::unique_ptr< Matter > matter)
void minimize (std::unique_ptr< Matter > matter, const std::string &confileout)
void printFeatures ()
void eonc::commandLine (int argc, char **argv)

Variables

constexpr auto colorScheme = basicDefaultColorScheme<char>

Function Documentation

◆ colorizer()

BasicColorizer< char > colorizer ( colorScheme )

◆ minimize()

void minimize ( std::unique_ptr< Matter > matter,
const std::string & confileout )

Definition at line 47 of file CommandLine.cpp.

47 {
48 matter->relax(false, false);
49 if (!confileout.empty()) {
50 std::cout << "Saving relaxed structure to " << confileout << std::endl;
51 } else {
52 std::cout << "No output file specified, not saving" << std::endl;
53 }
54 if (!eonc::io::io_ok(matter->matter2con(confileout))) {
55 std::cerr << "Failed to write " << confileout << std::endl;
56 }
57}
constexpr bool io_ok(IoStatus s) noexcept
Definition ConFileIO.h:38

◆ printFeatures()

void printFeatures ( )

Definition at line 59 of file CommandLine.cpp.

59 {
60 std::cout << colorizer.heading("Compile-time features:") << std::endl;
61 // Parse FEATURES_STRING and colorize enabled/disabled
62 std::istringstream stream(FEATURES_STRING);
63 std::string line;
64 while (std::getline(stream, line)) {
65 if (line.find(": enabled") != std::string::npos) {
66 // Extract feature name and colorize "enabled" with warning (yellow)
67 size_t colonPos = line.find(": ");
68 if (colonPos != std::string::npos) {
69 std::string featureName = line.substr(0, colonPos + 2);
70 std::string status = line.substr(colonPos + 2);
71 std::cout << featureName << colorizer.warning(status) << std::endl;
72 } else {
73 std::cout << line << std::endl;
74 }
75 } else if (line.find(": disabled") != std::string::npos) {
76 // Extract feature name and colorize "disabled" with error (red)
77 size_t colonPos = line.find(": ");
78 if (colonPos != std::string::npos) {
79 std::string featureName = line.substr(0, colonPos + 2);
80 std::string status = line.substr(colonPos + 2);
81 std::cout << featureName << colorizer.error(status) << std::endl;
82 } else {
83 std::cout << line << std::endl;
84 }
85 } else {
86 std::cout << line << std::endl;
87 }
88 }
89}
BasicColorizer< char > colorizer(colorScheme)

◆ singlePoint()

void singlePoint ( std::unique_ptr< Matter > matter)

Definition at line 39 of file CommandLine.cpp.

39 {
40 std::cout << "Energy: " << std::fixed << std::setprecision(15)
41 << matter->getPotentialEnergy() << std::endl;
42 std::cout << "(free) Forces: \n" << matter->getForcesFree() << "\n";
43 std::cout << "Max atom force: " << std::scientific << matter->maxForce()
44 << std::endl;
45}

Variable Documentation

◆ colorScheme

auto colorScheme = basicDefaultColorScheme<char>
constexpr

Definition at line 36 of file CommandLine.cpp.