void AtomicCompositionTable::CreateAtomicElementLists(const SpeciesMap& species) { // Recover atomic elements for(unsigned int i=0;i<species.size();i++) { OpenSMOKE::AtomicComposition atomic; species[i].AtomicComposition(&atomic); for(unsigned int k=0;k<atomic.element_names().size();k++) { bool iFound = false; for(unsigned int j=0;j<element_names_list_.size();j++) if ( atomic.element_names()[k] == element_names_list_[j] ) { iFound = true; break; } if (iFound == false) element_names_list_.push_back(atomic.element_names()[k]); } } // Recover atomic weights element_weights_list_.resize(element_names_list_.size()); element_weights_list_.setZero(); for(unsigned int j=0;j<element_names_list_.size();j++) element_weights_list_(j) = OpenSMOKE::AtomicWeights[element_names_list_[j]]; // Recover atomic elements element_coefficients_list_.resize(species.size(), element_names_list_.size()); element_coefficients_list_.setZero(); for(unsigned int i=0;i<species.size();i++) { OpenSMOKE::AtomicComposition atomic; species[i].AtomicComposition(&atomic); for(unsigned int k=0;k<atomic.element_names().size();k++) { bool iFound = false; for(unsigned int j=0;j<element_names_list_.size();j++) if ( atomic.element_names()[k] == element_names_list_[j] ) { element_coefficients_list_(i,j) = atomic.element_coefficients()[k]; break; } } } }
void AtomicCompositionTable::CreateAtomicElementLists(const SpeciesMap& species) { // Recover atomic elements for(unsigned int i=0;i<species.size();i++) { OpenSMOKE::AtomicComposition atomic; species[i].AtomicComposition(&atomic); for(unsigned int k=0;k<atomic.element_names().size();k++) { bool iFound = false; for(unsigned int j=0;j<element_names_list_.size();j++) if ( atomic.element_names()[k] == element_names_list_[j] ) { iFound = true; break; } if (iFound == false) element_names_list_.push_back(atomic.element_names()[k]); } } // Reorder { unsigned current_index = 0; std::vector<std::string> target_elements = { "C", "H", "O", "N" }; for (unsigned int k = 0; k < target_elements.size(); k++) { for (unsigned int j = 0; j < element_names_list_.size(); j++) if (element_names_list_[j] == target_elements[k]) { std::iter_swap(element_names_list_.begin() + current_index, element_names_list_.begin() + j); current_index++; break; } } } // Recover atomic weights element_weights_list_.resize(element_names_list_.size()); element_weights_list_.setZero(); for(unsigned int j=0;j<element_names_list_.size();j++) element_weights_list_(j) = OpenSMOKE::AtomicWeights[element_names_list_[j]]; // Recover atomic elements element_coefficients_list_.resize(species.size(), element_names_list_.size()); element_coefficients_list_.setZero(); for(unsigned int i=0;i<species.size();i++) { OpenSMOKE::AtomicComposition atomic; species[i].AtomicComposition(&atomic); for(unsigned int k=0;k<atomic.element_names().size();k++) { bool iFound = false; for(unsigned int j=0;j<element_names_list_.size();j++) if ( atomic.element_names()[k] == element_names_list_[j] ) { element_coefficients_list_(i,j) = atomic.element_coefficients()[k]; break; } } } }
bool Species::IsGoingExtinct() { return (m_fitness < 0.0 && m_incomingInteractions.size() > 0); }
void Species::MakeInteractionWith(Species* other, double coefficient) { m_incomingInteractions.insert( std::make_pair(other, coefficient) ); m_fitness += coefficient; other->m_outgoingInteractions.insert(this); other->m_cacheReady = false; }
size_t Species::InDegree() const { return m_incomingInteractions.size(); }