deltaFlow
Argparse.H
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Saud Zahir
3 *
4 * This file is part of deltaFlow.
5 *
6 * deltaFlow is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * deltaFlow is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public
17 * License along with deltaFlow. If not, see
18 * <https://www.gnu.org/licenses/>.
19 */
20
29#ifndef ARGPARSE_H
30#define ARGPARSE_H
31
32#include <string>
33
34struct PowerFlowOptions;
35
43enum class SolverType {
46};
47
52enum class InputFormat {
53 IEEE,
54 PSSE
55};
56
64class ArgumentParser final {
65 public:
71 ArgumentParser(int argc, char* argv[]);
72
76 ~ArgumentParser() = default;
77
78 // Deleted copy/move semantics
81 ArgumentParser(const ArgumentParser&&) = delete;
83
88 std::string getInputFile() const noexcept;
89
94 std::string getJobName() const noexcept;
95
100 double getTolerance() const noexcept;
101
106 int getMaxIterations() const noexcept;
107
112 double getRelaxationCoefficient() const noexcept;
113
118 SolverType getSolverType() const noexcept;
119
124 InputFormat getInputFormat() const noexcept;
125
133 PowerFlowOptions getOptions() const noexcept;
134
135 private:
136 std::string inputFile;
137 std::string jobName;
138 double tolerance = 1E-8;
139 int maxIterations = 1024;
140 double relaxation = 1.0;
143
149 void parse_args(int argc, char* argv[]);
150
154 void help() const noexcept;
155
156};
157
158#endif
InputFormat
Supported input file formats.
Definition Argparse.H:52
@ IEEE
IEEE Common Data Format (.cdf, .txt)
@ PSSE
PSS/E Raw Data Format (.raw)
SolverType
Types of solvers supported by deltaFlow.
Definition Argparse.H:43
@ GaussSeidel
Gauss-Seidel iterative method.
Parses and stores command-line arguments for deltaFlow.
Definition Argparse.H:64
~ArgumentParser()=default
Destructor (default).
InputFormat getInputFormat() const noexcept
Get the input file format.
Definition Argparse.C:155
double relaxation
Relaxation coefficient ($$ \omega $$)
Definition Argparse.H:140
std::string inputFile
Path to input CDF file.
Definition Argparse.H:136
std::string jobName
Job name (defaults to input filename)
Definition Argparse.H:137
ArgumentParser & operator=(const ArgumentParser &)=delete
ArgumentParser & operator=(ArgumentParser &&)=delete
std::string getJobName() const noexcept
Get the job name.
Definition Argparse.C:135
PowerFlowOptions getOptions() const noexcept
Get all parsed options as a plain data struct (ISP).
Definition Argparse.C:159
double getTolerance() const noexcept
Get the convergence tolerance ($$ \epsilon $$).
Definition Argparse.C:139
void parse_args(int argc, char *argv[])
Parse the provided arguments.
Definition Argparse.C:41
void help() const noexcept
Print help message to stdout.
Definition Argparse.C:171
double tolerance
Convergence tolerance ($$ \epsilon $$)
Definition Argparse.H:138
ArgumentParser(const ArgumentParser &&)=delete
SolverType getSolverType() const noexcept
Get the solver type.
Definition Argparse.C:151
std::string getInputFile() const noexcept
Get the input CDF file path.
Definition Argparse.C:131
double getRelaxationCoefficient() const noexcept
Get the relaxation coefficient ($$ \omega $$).
Definition Argparse.C:147
ArgumentParser(const ArgumentParser &)=delete
SolverType method
Solver type.
Definition Argparse.H:141
int maxIterations
Maximum number of iterations ($$ N_{max} $$)
Definition Argparse.H:139
int getMaxIterations() const noexcept
Get the maximum number of iterations ($$ N_{max} $$).
Definition Argparse.C:143
InputFormat format
Input file format.
Definition Argparse.H:142
Newton-Raphson power flow solver implementing the ISolver interface.
Plain data holder for parsed command-line options.