Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F81249940
variables.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
Wed, Sep 4, 23:33
Size
2 KB
Mime Type
text/x-c
Expires
Fri, Sep 6, 23:33 (2 d)
Engine
blob
Format
Raw Data
Handle
20536908
Attached To
rSPECMICP SpecMiCP / ReactMiCP
variables.cpp
View Options
#include "catch.hpp"
#include "utils.hpp"
#include "reactmicp/systems/saturated_diffusion/variables.hpp"
#include "reactmicp/systems/saturated_diffusion/transport_parameters.hpp"
#include "dfpm/meshes/uniform_mesh1d.hpp"
using namespace specmicp;
using namespace specmicp::reactmicp;
using namespace specmicp::reactmicp::systems::siasaturated;
TEST_CASE("SIA Variables", "[Variables, Secondary variables, SIA]") {
std::shared_ptr<database::DataContainer> database = get_test_carbo_database();
int nb_nodes = 5;
mesh::Mesh1DPtr themesh = mesh::uniform_mesh1d(nb_nodes, 1e-3, 0.001);
auto parameters = std::make_shared<SaturatedDiffusionTransportParameters>(nb_nodes, 1e-6, 0.2);
SECTION("Initialization") {
SIASaturatedVariables variables(database, themesh, parameters);
REQUIRE_NOTHROW( variables.component_concentration(0, 2) );
REQUIRE_NOTHROW( variables.component_concentration(2, 2) );
REQUIRE_NOTHROW( variables.component_concentration(4, 4) );
REQUIRE_NOTHROW( variables.component_concentration(3, 1) );
REQUIRE_NOTHROW( variables.log_component_concentration(3, 3) );
REQUIRE_NOTHROW( variables.log_gamma_component(4, 2) );
}
SECTION("Ionic strength computation") {
SIASaturatedVariables variables(database, themesh, parameters);
database::Database database_handler(database);
variables.log_component_concentration(1, database_handler.component_label_to_id("Ca[2+]")) = -3;
variables.log_component_concentration(1, database_handler.component_label_to_id("HO[-]")) = -3;
variables.log_component_concentration(1, database_handler.component_label_to_id("HCO3[-]")) = -3;
variables.log_component_concentration(1, database_handler.component_label_to_id("SiO(OH)3[-]")) = -3;
variables.nodal_ionic_strength(1);
REQUIRE( variables.ionic_strength(1) == (4*1e-3 +3*1e-3)*0.5 );
variables.secondary_concentration(1, database_handler.aqueous_label_to_id("CO3[2-]")) = 1e-2;
variables.nodal_ionic_strength(1);
REQUIRE( variables.ionic_strength(1) == (4*1e-3 +3*1e-3 + 4*1e-2)*0.5 );
variables.secondary_concentration(1, database_handler.aqueous_label_to_id("CO2")) = 1e-1;
variables.nodal_ionic_strength(1);
REQUIRE( variables.ionic_strength(1) == (4*1e-3 +3*1e-3 + 4*1e-2)*0.5 );
}
SECTION("Update") {
SIASaturatedVariables variables(database, themesh, parameters);
EquilibriumState composition = sample_carbo_composition(database);
variables.update_composition(1, composition);
REQUIRE(variables.component_concentration(1, 1) == Approx(composition.molality_component(1)).epsilon(1e-7));
REQUIRE(variables.total_mobile_concentration(1, 1) == Approx(composition.total_aqueous_concentration_component(1)).epsilon(1e-7));
}
}
Event Timeline
Log In to Comment