summaryrefslogtreecommitdiffstats
path: root/includes/over51.hpp
diff options
context:
space:
mode:
authorAngelo Rossi <angelo.rossi.homelab@gmail.com>2023-06-21 12:04:16 +0000
committerAngelo Rossi <angelo.rossi.homelab@gmail.com>2023-06-21 12:04:16 +0000
commitb18347ffc9db9641e215995edea1c04c363b2bdf (patch)
treef3908dc911399f1a21e17d950355ee56dc0919ee /includes/over51.hpp
Initial commit.
Diffstat (limited to 'includes/over51.hpp')
-rw-r--r--includes/over51.hpp199
1 files changed, 199 insertions, 0 deletions
diff --git a/includes/over51.hpp b/includes/over51.hpp
new file mode 100644
index 0000000..c3d0a85
--- /dev/null
+++ b/includes/over51.hpp
@@ -0,0 +1,199 @@
+//-*- mode: c++; indent-tabs-mode: nil; coding: utf-8; show-trailing-whitespace: t -*-
+
+// file over51.hpp
+
+#ifndef _OVER51_HPP
+#define _OVER51_HPP
+
+#include <iostream>
+#include <iomanip>
+#include <string>
+#include <sstream>
+#include <limits>
+#include <exception>
+#include <stdexcept>
+
+#include "blkcom.hpp"
+#include "time.hpp"
+
+namespace emtp {
+
+ // Classes.
+ class storage_exceeded_error : public std::runtime_error
+ {
+ public:
+ storage_exceeded_error () : std::runtime_error ("")
+ {
+ }
+
+ public:
+ const char *what (void) const noexcept
+ {
+ std::stringstream ss;
+ //
+ ss << std::string (5, ' ');
+ ss << "Storage exceeded for list number ";
+ ss << std::setw(2) << std::setfill('0') << blkcom::sLStat[ 15 ];
+ ss << ". See dimensioned limit in tabulation below.\n";
+ ss << std::string(5, '-');
+ ss << "The problem being inputted is simply too big for the program as currently dimensioned. Since there usually are\n";
+ ss << std::string(5, ' ');
+ ss << "ways of circumventing this difficulty, it is suggested that the user consult his friendly neighborhood program\n";
+ ss << std::string(5, ' ');
+ ss << "maintenance man.\n";
+ return ss.str().c_str();
+ }
+ };
+
+ class time_error : public std::runtime_error
+ {
+ public:
+ time_error () : std::runtime_error ("")
+ {
+ }
+
+ public:
+ const char *what (void) const noexcept
+ {
+ std::stringstream ss;
+ //
+ if (blkcom::nT >= 0.0) {
+ ss << std::string (5, '-');
+ ss << "Time-step size 'deltat' as read from columns 1-8 of the first miscellaneous data card is not positive. The\n";
+ ss << std::string (5, '-');
+ ss << "user punched a value of ";
+ ss << std::setw (14) << std::setprecision (4) << blkcom::sFLStat[ 15 ];
+ ss << ". Unlike Jules Verne, you are not allowed to stop or decrease time during\n";
+ ss << std::string (5, '-');
+ ss << "a simulation, my friend. Don't try riding out of an active volcano on a raft floating on molten lava, either,\n";
+ ss << std::string (5, '-');
+ ss << "although that's another story.\n";
+ } else {
+ ss << std::string (5, '-');
+ ss << "The starting time 't' as read from the floating-point miscellaneous data card is negative, which is\n";
+ ss << std::string (5, '-');
+ ss << "illegal. A value of";
+ ss << std::setw (15) << std::setprecision (5) << blkcom::nT;
+ ss << " was read from the data field of columns 49-56.\n";
+ }
+ return ss.str ().c_str ();
+ }
+ };
+
+ class branch_card_illegal_type_code_error : public std::runtime_error
+ {
+ public:
+ branch_card_illegal_type_code_error () : std::runtime_error ("")
+ {
+ }
+
+ public:
+ const char *what (void) const noexcept
+ {
+ std::stringstream ss;
+ //
+ ss << std::string (5, '-');
+ ss << "Illegal type code read from columns 1-2 of last branch card. The user punched a value of ";
+ ss << std::setw (2) << blkcom::sLStat[ 15 ];
+ ss << ". Either\n";
+ ss << std::string (5, '-');
+ ss << "the punched number itself is patently illegal (always an error, under any circumstances), or the card in question\n";
+ ss << std::string (5, '-');
+ ss << "his out of sequence in relation to the preceding data card which was inputted. As an example of the latter\n";
+ ss << std::string (5, '-');
+ ss << "case, consider a '-3' punch, with the preceeding card not bearing a '-2' punch. In any case, open up the user's\n";
+ ss << std::string (5, ' ');
+ ss << "manual, and reread the rules for the data type that you have been trying to input, my friend.\n";
+ ss << std::string (5, ' ');
+ ss << "Yet, in case this general advice does not seem to apply, consider the possible trouble which can arise from a\n";
+ ss << std::string (5, ' ');
+ ss << "preceding faulty use of the reference-branch capability. This feature has the EMTP looking for a certain number\n";
+ ss << std::string (5, ' ');
+ ss << "and type of branch cards, based on properties of the component to which reference has been made. If the user's\n";
+ ss << std::string (5, ' ');
+ ss << "data cards do not in structure match those of the reference component, an error stop of the present type may very";
+ ss << std::string (5, ' ');
+ ss << "be expected. Remember that in cases where two or more branches from reference bus 'bus3' to reference bus\n";
+ ss << std::string (5, ' ');
+ ss << "'bus4' (ordered pair of names, read from columns 15-24 as 2a6 information) exist, the EMTP will always pick\n";
+ ss << std::string (5, ' ');
+ ss << "the first one that it finds (in order of branch input) for reference purposes.\n";
+ return ss.str ().c_str ();
+ }
+ };
+
+ class last_branch_zero_impedance_error : public std::runtime_error
+ {
+ public:
+ last_branch_zero_impedance_error () :std::runtime_error ("")
+ {
+ }
+
+ public:
+ const char *what (void) const noexcept
+ {
+ std::stringstream ss;
+ //
+ ss << std::string (5, ' ');
+ ss << "Last branch was zero impedance (R, L, C fields of columns 27-44 were all zero). If you really want a short\n";
+ ss << std::string (5, ' ');
+ ss << "circuit, you must punch a very small value for R or L. Or better yet, why not do away with one of the node\n";
+ ss << std::string (5, ' ');
+ ss << "names of this branch, treating both ends as the same bus (a perfect short circuit).\n";
+ return ss.str ().c_str ();
+ }
+ };
+
+ class non_monotone_increasing_characteristic_error : public std::runtime_error
+ {
+ public:
+ non_monotone_increasing_characteristic_error () : std::runtime_error ("")
+ {
+ }
+
+ public:
+ const char *what (void) const noexcept
+ {
+ std::stringstream ss;
+ //
+ ss << std::string (5, ' ');
+ ss << "The user has been inputting pairs of points which define a nonlinear (or pseudo-nonlinear) element characteristic.\n";
+ ss << std::string (5, ' ');
+ ss << "These must be in order, moving ever to the right and upward in the x-y plane. But the user's just-inputted\n";
+ ss << std::string (5, ' ');
+ ss << "characteristic is not monotone increasing as it should be. A decrease in one of the two coordinate points\n";
+ ss << std::string (5, ' ');
+ ss << "has been detected on the last data card which was read. Shape up or ship out, Jack.\n";
+ return ss.str ().c_str ();
+ }
+ };
+
+ class dummy_function_called_error : public std::runtime_error
+ {
+ public:
+ dummy_function_called_error () : std::runtime_error ("")
+ {
+ }
+
+ public:
+ const char *what (void) const noexcept
+ {
+ std::stringstream ss;
+ //
+ ss << std::string (5, ' ');
+ ss << "Dummy function is called, something wrong with this version of EMTP++.\n";
+ return ss.str ().c_str ();
+ }
+ };
+
+}
+
+namespace over51 {
+
+ // Prototypes.
+ void subr51(void);
+ void over51(void);
+
+}
+
+#endif // _OVER51_HPP