Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122026969
database.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jul 15, 09:35
Size
1 KB
Mime Type
text/x-c
Expires
Thu, Jul 17, 09:35 (2 d)
Engine
blob
Format
Raw Data
Handle
27425352
Attached To
rSPECMICP SpecMiCP / ReactMiCP
database.cpp
View Options
/*-------------------------------------------------------
- Module : database
- File : database.cpp
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget, Princeton University
---------------------------------------------------------*/
#include "database.hpp"
#include <iostream>
#include "selector.hpp"
#include "canonicalizer.hpp"
#include "switch_basis.hpp"
namespace specmicp {
namespace database {
void Database::make_canonical()
{
canonicalize_database(data);
}
void Database::change_basis(std::vector<int>& new_basis)
{
BasisSwitcher(data).change_basis(new_basis);
}
// this is a proxy to a DatabaseSelector
void Database::remove_components(const std::vector<int>& id_components_to_remove)
{
DatabaseSelector selector(data);
selector.remove_component(id_components_to_remove);
}
void Database::swap_components(std::map<std::string, std::string>& swap_to_make)
{
std::vector<int> id_swap;
id_swap.reserve(data->nb_component);
for (int i=0; i<data->nb_component; ++i)
{
id_swap.push_back(i);
}
for (auto it=swap_to_make.begin(); it!=swap_to_make.end(); ++it)
{
if (it->first == "H2O") {
throw std::invalid_argument("Basis switch : water cannot be swapped from basis");
}
const int idc = label_to_id(it->first, data->labels_basis);
const int idaq = data->nb_component + label_to_id(it->second, data->labels_aqueous);
id_swap[idc] = idaq;
}
change_basis(id_swap);
}
} // end namespace database
} // end namespace specmicp
Event Timeline
Log In to Comment