void Window_Profiles::Plot_Selectivities() { // Find the right x variable, together with the x axis lable QVector<double> axis_x; QString axis_x_title; FindXVariable(axis_x, axis_x_title); // XY Plot XYPlot* xyplot; xyplot = new XYPlot(this); xyplot->SetXTitle(axis_x_title); xyplot->SetYTitle("selectivity [-]"); // Find the species for the conversion unsigned int index_species_conversion = data_->list_of_conversion_species_[ui.comboBox_Conversion->currentIndex()]; // If the conversion is too small, the sensitivity coefficient is badly defined // Therefore the calculation is skipped in those points const double eta_threshold = 1.e-6; QVector<double> omega_conversion = data_->omega[index_species_conversion]; QVector<double> eta_x; for(unsigned int i=0;i<data_->number_of_abscissas_;i++) { const double conversion = (omega_conversion[0] - omega_conversion[i])/omega_conversion[0]; if (conversion > eta_threshold) eta_x.push_back(axis_x[i]); } xyplot->SetAbscissas(eta_x); // Reconstruct the profiles { QList<QListWidgetItem*> selected_species_selectivity = ui.listWidget_Species_Selectivity->selectedItems(); unsigned int n_selected_species = selected_species_selectivity.size(); if (n_selected_species == 0) { QMessageBox msgBox; msgBox.setText(QString::fromStdString("At least one species must be selected in the Species (Selectivity) Panel")); msgBox.exec(); return; } for(unsigned int j=0;j<n_selected_species;j++) { for(unsigned int k=0;k<data_->string_list_massfractions_sorted.size();k++) if (selected_species_selectivity[j]->text() == data_->string_list_massfractions_sorted[k]) { unsigned int index_selectivity = data_->sorted_index[k]; QVector<double> sigma; for(unsigned int i=0;i<data_->number_of_abscissas_;i++) { const double conversion = (omega_conversion[0] - omega_conversion[i])/omega_conversion[0]; if (conversion > eta_threshold) sigma.push_back(data_->omega[index_selectivity][i]/omega_conversion[0]/conversion); } if (ui.radioButton_Selectivity_Mole->isChecked() == true) { const double mw_conversion = data_->mw_species_[index_species_conversion]; const double mw_selectivity = data_->mw_species_[index_selectivity]; for(unsigned int i=0;i<sigma.size();i++) sigma[i] *= mw_conversion/mw_selectivity; } if (ui.radioButton_Selectivity_Element->isChecked() == true) { const double n_conversion = data_->thermodynamicsMapXML->atomic_composition()(index_species_conversion, ui.comboBox_Elements->currentIndex()); const double n_selectivity = data_->thermodynamicsMapXML->atomic_composition()(index_selectivity, ui.comboBox_Elements->currentIndex()); if (n_conversion > 0) { const double mw_conversion = data_->mw_species_[index_species_conversion]; const double mw_selectivity = data_->mw_species_[index_selectivity]; for(unsigned int i=0;i<sigma.size();i++) sigma[i] *= mw_conversion/mw_selectivity *n_selectivity/n_conversion; } else { QMessageBox msgBox; msgBox.setText(QString::fromStdString("The selected element is not present in the selected species (conversion side)")); msgBox.exec(); return; } } xyplot->AddGraph(selected_species_selectivity[j]->text().toStdString(), sigma); break; } } // Plot xyplot->Plot(); } }