Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97522104
database_selector.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
Sat, Jan 4, 21:27
Size
3 KB
Mime Type
text/x-c
Expires
Mon, Jan 6, 21:27 (2 d)
Engine
blob
Format
Raw Data
Handle
23328471
Attached To
rSPECMICP SpecMiCP / ReactMiCP
database_selector.cpp
View Options
#include "catch.hpp"
#include "database/reader.hpp"
#include "database/selector.hpp"
#include "database/mineral_selector.hpp"
#include "str_database.hpp"
#include "utils/timer.hpp"
#include <iostream>
#include <sstream>
using
namespace
specmicp
;
using
namespace
specmicp
::
database
;
TEST_CASE
(
"DatabaseSelector"
,
"[Database, Component]"
)
{
std
::
istringstream
input
(
good_test_database
);
DataReader
reader
(
input
);
auto
data
=
reader
.
get_database
();
SECTION
(
"Remove a component"
)
{
Timer
timer
;
DatabaseSelector
selector
(
data
);
selector
.
remove_component
({
data
->
components
.
get_id
(
"C3"
)});
timer
.
stop
();
std
::
cout
<<
"Removing a component : "
<<
timer
.
elapsed_time
()
*
1000
<<
" ms (Ref 0.010ms)"
<<
std
::
endl
;
CHECK
(
data
->
components
.
is_valid
());
CHECK
(
data
->
aqueous
.
is_valid
());
CHECK
(
data
->
minerals
.
is_valid
());
CHECK
(
data
->
minerals_kinetic
.
is_valid
());
CHECK
(
data
->
gas
.
is_valid
());
CHECK
(
data
->
is_valid
());
// basis
CHECK
(
data
->
nb_component
()
==
4
);
CHECK
(
data
->
components
.
get_id
(
"C3"
)
==
no_species
);
// aqueous
CHECK
(
data
->
nb_aqueous
()
==
2
);
CHECK
(
data
->
aqueous
.
get_id
(
"A3"
)
==
no_species
);
// minerals
CHECK
(
data
->
nb_mineral
()
==
1
);
CHECK
(
data
->
minerals
.
get_id
(
"M2"
)
==
no_species
);
// minerals_kinetic
CHECK
(
data
->
nb_mineral_kinetic
()
==
0
);
CHECK
(
data
->
minerals_kinetic
.
get_id
(
"MK1"
)
==
no_species
);
// Gas
CHECK
(
data
->
nb_gas
()
==
0
);
CHECK
(
data
->
gas
.
get_id
(
"G1"
)
==
no_species
);
// Sorbed
CHECK
(
data
->
nb_sorbed
()
==
0
);
CHECK
(
data
->
sorbed
.
get_id
(
"S1"
)
==
no_species
);
}
}
TEST_CASE
(
"MineralSelector"
,
"[Select,minerals]"
)
{
std
::
istringstream
input
(
good_test_database
);
auto
data
=
DataReader
(
input
).
get_database
();
SECTION
(
"Mineral selector"
)
{
MineralSelector
(
data
).
keep_only
({
"M1"
});
CHECK
(
data
->
minerals
.
is_valid
());
CHECK
(
data
->
minerals_kinetic
.
is_valid
());
CHECK
(
data
->
is_valid
());
// Mineral
// -------
CHECK
(
data
->
nb_mineral
()
==
1
);
CHECK
(
data
->
minerals
.
get_id
(
"M2"
)
==
no_species
);
CHECK
(
data
->
nu_mineral
(
0
,
0
)
==
0.0
);
CHECK
(
data
->
nu_mineral
(
0
,
1
)
==
0.0
);
CHECK
(
data
->
nu_mineral
(
0
,
2
)
==
1.0
);
CHECK
(
data
->
nu_mineral
(
0
,
3
)
==
1.0
);
CHECK
(
data
->
nu_mineral
(
0
,
4
)
==
0.0
);
CHECK
(
data
->
logk_mineral
(
0
)
==
-
7
);
CHECK
(
data
->
molar_volume_mineral
(
0
)
==
1e-6
*
10.0
);
// Mineral kinetic
// ---------------
CHECK
(
data
->
nb_mineral_kinetic
()
==
2
);
CHECK
(
data
->
minerals_kinetic
.
get_id
(
"M2"
)
==
1
);
CHECK
(
data
->
nu_mineral_kinetic
(
0
,
0
)
==
0.0
);
CHECK
(
data
->
nu_mineral_kinetic
(
0
,
1
)
==
0.0
);
CHECK
(
data
->
nu_mineral_kinetic
(
0
,
2
)
==
1.0
);
CHECK
(
data
->
nu_mineral_kinetic
(
0
,
3
)
==
1.0
);
CHECK
(
data
->
nu_mineral_kinetic
(
0
,
4
)
==
2.0
);
CHECK
(
data
->
logk_mineral_kinetic
(
0
)
==
-
9
);
CHECK
(
data
->
molar_volume_mineral_kinetic
(
0
)
==
1e-6
*
30.0
);
CHECK
(
data
->
nu_mineral_kinetic
(
1
,
0
)
==
0.0
);
CHECK
(
data
->
nu_mineral_kinetic
(
1
,
1
)
==
0.0
);
CHECK
(
data
->
nu_mineral_kinetic
(
1
,
2
)
==
2.0
);
CHECK
(
data
->
nu_mineral_kinetic
(
1
,
3
)
==
2.0
);
CHECK
(
data
->
nu_mineral_kinetic
(
1
,
4
)
==
1.0
);
CHECK
(
data
->
logk_mineral_kinetic
(
1
)
==
-
6
+
data
->
logk_aqueous
(
1
)
+
data
->
logk_aqueous
(
2
));
CHECK
(
data
->
molar_volume_mineral_kinetic
(
1
)
==
1e-6
*
20.0
);
}
}
Event Timeline
Log In to Comment