preprocessor: Return equation numbers/tags in error message when linear model contains nonzero hessian entries. #419
parent
7695031e77
commit
3695bf4695
|
@ -1731,6 +1731,24 @@ DynamicModel::reform(const string name1) const
|
||||||
return (name);
|
return (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicModel::getNonZeroHessianEquations(map<int, string> &eqs) const
|
||||||
|
{
|
||||||
|
for (second_derivatives_t::const_iterator it = second_derivatives.begin();
|
||||||
|
it != second_derivatives.end(); it++)
|
||||||
|
if (eqs.find(it->first.first) == eqs.end())
|
||||||
|
{
|
||||||
|
eqs[it->first.first] = "";
|
||||||
|
for (size_t i = 0; i < equation_tags.size(); i++)
|
||||||
|
if (equation_tags[i].first == it->first.first)
|
||||||
|
if (equation_tags[i].second.first == "name")
|
||||||
|
{
|
||||||
|
eqs[it->first.first] = equation_tags[i].second.second;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicModel::Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const string &bin_basename, const int &num,
|
DynamicModel::Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const string &bin_basename, const int &num,
|
||||||
int &u_count_int, bool &file_open, bool is_two_boundaries) const
|
int &u_count_int, bool &file_open, bool is_two_boundaries) const
|
||||||
|
|
|
@ -220,6 +220,9 @@ public:
|
||||||
//! Return true if the hessian is equal to zero
|
//! Return true if the hessian is equal to zero
|
||||||
inline bool checkHessianZero() const;
|
inline bool checkHessianZero() const;
|
||||||
|
|
||||||
|
//! Return equations that have non-zero second derivatives
|
||||||
|
void getNonZeroHessianEquations(map<int, string> &eqs) const;
|
||||||
|
|
||||||
//! Adds informations for simulation in a binary file
|
//! Adds informations for simulation in a binary file
|
||||||
void Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const string &bin_basename,
|
void Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const string &bin_basename,
|
||||||
const int &num, int &u_count_int, bool &file_open, bool is_two_boundaries) const;
|
const int &num, int &u_count_int, bool &file_open, bool is_two_boundaries) const;
|
||||||
|
|
|
@ -536,7 +536,17 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xr
|
||||||
|
|
||||||
if (linear && !dynamic_model.checkHessianZero())
|
if (linear && !dynamic_model.checkHessianZero())
|
||||||
{
|
{
|
||||||
cerr << "ERROR: If the model is declared linear the second derivatives must be equal to zero." << endl;
|
map<int, string> eqs;
|
||||||
|
dynamic_model.getNonZeroHessianEquations(eqs);
|
||||||
|
cerr << "ERROR: If the model is declared linear the second derivatives must be equal to zero." << endl
|
||||||
|
<< " The following equations had non-zero second derivatives:" << endl;
|
||||||
|
for (map<int, string >::const_iterator it = eqs.begin(); it != eqs.end(); it++)
|
||||||
|
{
|
||||||
|
cerr << " * Eq # " << it->first+1;
|
||||||
|
if (!it->second.empty())
|
||||||
|
cerr << " [" << it->second << "]";
|
||||||
|
cerr << endl;
|
||||||
|
}
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue