Repository navigation
Expand file tree
/
Copy pathEquationErrors.cc
More file actions
139 lines (123 loc) · 6.42 KB
/
Copy pathEquationErrors.cc
File metadata and controls
139 lines (123 loc) · 6.42 KB
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
/***
DEVSIM
Copyright 2013 DEVSIM LLC
SPDX-License-Identifier: Apache-2.0
***/
#include "EquationErrors.hh"
#include "GeneralErrors.hh"
#include "GeometryStream.hh"
#include "ErrorHelpers.hh"
#include "ContactEquation.hh"
#include "InterfaceEquation.hh"
#include "Equation.hh"
#include "Region.hh"
#include "Device.hh"
#ifdef DEVSIM_EXTENDED_PRECISION
#include "Float128.hh"
#endif
#include <sstream>
#include <string>
namespace dsErrors {
std::string MissingEquationModel(const Region ®ion, const std::string &equation_name, const std::string &model_name, ModelInfo::ModelType model_type, OutputStream::OutputType error_level) {
std::ostringstream os;
os << FormatEquationOnRegionName(region, equation_name)
<< " " <<
FormatModelNameAndType(model_name, model_type)
<< " MISSING\n";
GeometryStream::WriteOut(error_level, region, os.str());
return os.str();
}
std::string MissingEquationIndex(const Region ®ion, const std::string &equation_name, const std::string &variable_name, OutputStream::OutputType error_level)
{
std::ostringstream os;
os << FormatEquationOnRegionName(region, equation_name);
if (variable_name.empty())
{
os << " Cannot find equation associated with variable " << variable_name << "\n";
}
else
{
os << " Cannot find equation index.\n";
}
GeometryStream::WriteOut(error_level, region, os.str());
return os.str();
}
template <typename DoubleType>
std::string MissingContactEquationModel(const Region ®ion, const ContactEquation<DoubleType> &contact_equation, const std::string &model_name, ModelInfo::ModelType model_type, OutputStream::OutputType error_level) {
std::ostringstream os;
os << FormatContactEquationOnContactName(region, contact_equation.GetContact(), contact_equation.GetName())
<< " " <<
FormatModelNameAndType(model_name, model_type)
<< " MISSING\n";
GeometryStream::WriteOut(error_level, contact_equation.GetContact(), os.str());
return os.str();
}
std::string MissingContactEquationIndex(const Region ®ion, const Contact &contact, const std::string &equation_name, OutputStream::OutputType error_level)
{
std::ostringstream os;
os << FormatContactEquationOnContactName(region, contact, equation_name)
<< " Cannot find equation index associated with Equation\n";
GeometryStream::WriteOut(error_level, contact, os.str());
return os.str();
}
template <typename DoubleType>
std::string SolutionVariableNonPositive(const Region ®ion, const std::string &equation_name, const std::string &variable, DoubleType value, OutputStream::OutputType error_level)
{
std::ostringstream os;
os << FormatEquationOnRegionName(region, equation_name)
<< "Variable: " << variable << " "
<< "Solution Variable has negative or zero value before update. " << value << "\n";
GeometryStream::WriteOut(error_level, region, os.str());
return os.str();
}
template <typename DoubleType>
std::string MissingCircuitNodeOnContactEquation(const ContactEquation<DoubleType> &contact_equation, const std::string &circuit_node, OutputStream::OutputType error_level)
{
std::ostringstream os;
os << FormatContactEquationOnContactName(contact_equation.GetRegion(), contact_equation.GetContact(), contact_equation.GetName());
os << " Circuit node \"" << circuit_node << "\" does not exist\n";
GeometryStream::WriteOut(error_level, contact_equation.GetContact(), os.str());
return os.str();
}
std::string EquationMathErrorInfo(const Equation<double> &equation, OutputStream::OutputType error_level)
{
std::ostringstream os;
os << "Device: " << equation.GetRegion().GetDevice()->GetName() << "\t"
<< "Region: " << equation.GetRegion().GetName() << "\t"
<< "Equation: " << equation.GetName() << "\t"
<< "RelError: " << equation.GetRelError() << "\t"
<< "AbsError: " << equation.GetAbsError() << "\n";
GeometryStream::WriteOut(error_level, equation.GetRegion(), os.str());
return os.str();
}
std::string CreateModelOnRegion(const Region ®ion, const std::string &model_name, OutputStream::OutputType error_level)
{
std::ostringstream os;
os << "Device: " << region.GetDevice()->GetName() << "\t"
<< "Region: " << region.GetName() << "\t"
<< "Creating: " << model_name << "\n";
GeometryStream::WriteOut(error_level, region, os.str());
return os.str();
}
template <typename DoubleType>
std::string MissingInterfaceEquationModel(const Region ®ion, const InterfaceEquation<DoubleType> &interface_equation, const std::string &model_name, OutputStream::OutputType error_level)
{
std::ostringstream os;
os << FormatInterfaceEquationOnInterfaceName(region, interface_equation.GetInterface(), interface_equation.GetName())
<< " " <<
FormatModelNameAndType(model_name, ModelInfo::INTERFACE)
<< " MISSING\n";
GeometryStream::WriteOut(error_level, interface_equation.GetInterface(), os.str());
return os.str();
}
template std::string MissingContactEquationModel(const Region ®ion, const ContactEquation<double> &contact_equation, const std::string &model_name, ModelInfo::ModelType model_type, OutputStream::OutputType error_level);
template std::string SolutionVariableNonPositive(const Region ®ion, const std::string &equation_name, const std::string &variable, double value, OutputStream::OutputType error_level);
template std::string MissingInterfaceEquationModel(const Region ®ion, const InterfaceEquation<double> &interface_equation, const std::string &model_name, OutputStream::OutputType error_level);
template std::string MissingCircuitNodeOnContactEquation(const ContactEquation<double> &/*contact_equation*/, const std::string &/*circuit_node*/, OutputStream::OutputType /*error_level*/);
#ifdef DEVSIM_EXTENDED_PRECISION
template std::string MissingContactEquationModel(const Region ®ion, const ContactEquation<float128> &contact_equation, const std::string &model_name, ModelInfo::ModelType model_type, OutputStream::OutputType error_level);
template std::string SolutionVariableNonPositive(const Region ®ion, const std::string &equation_name, const std::string &variable, float128 value, OutputStream::OutputType error_level);
template std::string MissingInterfaceEquationModel(const Region ®ion, const InterfaceEquation<float128> &interface_equation, const std::string &model_name, OutputStream::OutputType error_level);
template std::string MissingCircuitNodeOnContactEquation(const ContactEquation<float128> &/*contact_equation*/, const std::string &/*circuit_node*/, OutputStream::OutputType /*error_level*/);
#endif
}