summaryrefslogtreecommitdiffstats
path: root/includes/over51.hpp
blob: c3d0a858f282c9803d5b6e23356454b7bc288465 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
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