create_fort_files now also creates a cautions report for non-convergence

This commit is contained in:
caes 2016-06-14 21:16:44 -04:00
parent 7f4bc149e3
commit 6b4849f75c
2 changed files with 49 additions and 13 deletions

View File

@ -45,7 +45,7 @@ struct cloudy_line_data {
typedef std::map<std::string,cloudy_line_data> cloudy_line_output; typedef std::map<std::string,cloudy_line_data> cloudy_line_output;
struct cloudy_result { struct cloudy_result {
std::string header, footer; std::string header, footer;
std::list<std::string> emergent_line_raw_text; std::list<std::string> emergent_line_raw_text;
std::list<std::string> cautions; std::list<std::string> cautions;
@ -60,7 +60,7 @@ struct cloudy_result {
iterations(0), iterations(0),
phi(0), phi(0),
hden(0), hden(0),
colden(0) colden(0)
{} {}
}; };
@ -70,7 +70,7 @@ cloudy_grid read_cloudy_grid(std::ifstream&);
// Operator<< prints general info about the run result. // Operator<< prints general info about the run result.
std::ostream& operator<< (std::ostream&, cloudy_result); std::ostream& operator<< (std::ostream&, cloudy_result);
// Seeks an instream to the line after the first occurrence of seek_string. // Seeks an instream to the line after the first occurrence of seek_string.
void seek_to(std::string,std::istream&); void seek_to(std::string,std::istream&);
} // end namespace agn } // end namespace agn
@ -123,7 +123,7 @@ void agn::seek_to(std::string seek_string,std::istream& stream) {
std::string agn::format_table1d(agn::table1d table) { std::string agn::format_table1d(agn::table1d table) {
std::stringstream output; std::stringstream output;
output output
<< std::scientific << std::scientific
<< std::setprecision(5); << std::setprecision(5);
agn::table1d::iterator x=table.begin(); agn::table1d::iterator x=table.begin();
@ -272,7 +272,7 @@ agn::cloudy_grid agn::read_cloudy_grid(std::ifstream& inputfile) {
} }
} }
point.colden = colden; point.colden = colden;
if(agn::debug) std::cout if(agn::debug) std::cout
<< " Grabbing emission lines."; << " Grabbing emission lines.";
agn::seek_to("Emergent line intensities",inputfile); agn::seek_to("Emergent line intensities",inputfile);
std::list<std::string> emergent_line_raw_text; std::list<std::string> emergent_line_raw_text;
@ -321,7 +321,7 @@ agn::cloudy_grid agn::read_cloudy_grid(std::ifstream& inputfile) {
} }
linetext_it++; linetext_it++;
} }
if(agn::debug) std::cout if(agn::debug) std::cout
<< " Grabbing footer."; << " Grabbing footer.";
while (inputline == "") while (inputline == "")
getline(inputfile,inputline); getline(inputfile,inputline);
@ -332,9 +332,9 @@ agn::cloudy_grid agn::read_cloudy_grid(std::ifstream& inputfile) {
footer.append("\n"); footer.append("\n");
getline(inputfile,inputline); getline(inputfile,inputline);
} }
if(agn::debug) std::cout if(agn::debug) std::cout
<< "\nAdding point to grid: " << "\nAdding point to grid: "
<< point << point
<< std::endl; << std::endl;
grid[*coords] = point; grid[*coords] = point;
coords++; coords++;

View File

@ -19,8 +19,8 @@ int main(int argc, char const *argv[]) {
std::ifstream line_list_file; std::ifstream line_list_file;
line_list_file.open(argv[2]); line_list_file.open(argv[2]);
agn::line_list lines_to_print = agn::read_line_list(line_list_file); agn::line_list lines_to_print = agn::read_line_list(line_list_file);
std::cout std::cout
<< "Compiling table2ds for " << "Compiling table2ds for "
<< lines_to_print.size() << lines_to_print.size()
<< " emission lines.\n"; << " emission lines.\n";
std::list<agn::eqwidth_table> tables = agn::compile_eqwidth_tables(grid,lines_to_print,1215.00); std::list<agn::eqwidth_table> tables = agn::compile_eqwidth_tables(grid,lines_to_print,1215.00);
@ -43,10 +43,46 @@ int main(int argc, char const *argv[]) {
fortfilenum++; fortfilenum++;
} }
int num_unconverged = 0;
agn::cloudy_grid::iterator result_it = grid.begin();
std::ofstream cautionreportfile;
cautionreportfile.open("cautions");
cautionreportfile
<< "The following solutions probably did not converge."
<< std::endl << std::endl;
while(result_it != grid.end()) {
if (result_it->second.iterations >= 40) {
num_unconverged++;
cautionreportfile
<< "hden = "
<< std::fixed
<< std::setprecision(3)
<< result_it->second.hden
<< ", phi = "
<< result_it->second.phi
<< std::endl
<< "───────────────────────────"
<< std::endl;
std::list<std::string>::iterator caution_it = result_it->second.cautions.begin();
while(caution_it != result_it->second.cautions.end()) {
cautionreportfile
<< *caution_it
<< std::endl;
caution_it++;
}
cautionreportfile << std::endl << std::endl;
}
result_it++;
}
std::cout
<< "Saved cautions for "
<< num_unconverged
<< " unconverged solutions."
<< std::endl;
cautionreportfile.close();
std::cout << "Done.\n"; std::cout << "Done.\n";
return 0; return 0;
} }