Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91056347
database_switch.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
Thu, Nov 7, 09:55
Size
3 KB
Mime Type
text/x-c
Expires
Sat, Nov 9, 09:55 (2 d)
Engine
blob
Format
Raw Data
Handle
22187451
Attached To
rSPECMICP SpecMiCP / ReactMiCP
database_switch.cpp
View Options
#include "catch.hpp"
#include "database/reader.hpp"
#include "database/switch_basis.hpp"
#include "str_database.hpp"
#include "utils/timer.hpp"
#include <iostream>
#include <sstream>
using
namespace
specmicp
;
using
namespace
specmicp
::
database
;
TEST_CASE
(
"Switch basis"
)
{
std
::
istringstream
input
(
good_test_database
);
DataReader
reader
(
input
);
auto
data
=
reader
.
get_database
();
SECTION
(
"switch basis"
)
{
Timer
timer
;
BasisSwitcher
switcher
(
data
);
std
::
map
<
std
::
string
,
std
::
string
>
swapping
=
{{
"C3"
,
"A3[-]"
}};
switcher
.
swap_components
(
swapping
);
timer
.
stop
();
std
::
cout
<<
"Switching basis : "
<<
timer
.
elapsed_time
()
*
1000
<<
" ms (Ref 0.020ms)"
<<
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
->
is_valid
());
// Basis
CHECK
(
data
->
nb_component
()
==
5
);
CHECK
(
data
->
components
.
get_id
(
"C3"
)
==
no_species
);
CHECK
(
data
->
components
.
get_id
(
"A3[-]"
)
==
4
);
// Aqueous
CHECK
(
data
->
nb_aqueous
()
==
3
);
CHECK
(
data
->
aqueous
.
get_id
(
"A3[-]"
)
==
no_species
);
CHECK
(
data
->
aqueous
.
get_id
(
"C3"
)
==
2
);
CHECK
(
data
->
nu_aqueous
(
2
,
0
)
==
0.0
);
CHECK
(
data
->
nu_aqueous
(
2
,
1
)
==
0.0
);
CHECK
(
data
->
nu_aqueous
(
2
,
2
)
==
-
1.0
);
CHECK
(
data
->
nu_aqueous
(
2
,
3
)
==
0.0
);
CHECK
(
data
->
nu_aqueous
(
2
,
4
)
==
1.0
);
CHECK
(
data
->
logk_aqueous
(
2
)
==
2.0
);
// Mineral
CHECK
(
data
->
nb_mineral
()
==
2
);
CHECK
(
data
->
nu_mineral
(
1
,
0
)
==
0.0
);
CHECK
(
data
->
nu_mineral
(
1
,
1
)
==
0.0
);
CHECK
(
data
->
nu_mineral
(
1
,
2
)
==
1.0
);
CHECK
(
data
->
nu_mineral
(
1
,
3
)
==
2.0
);
CHECK
(
data
->
nu_mineral
(
1
,
4
)
==
1.0
);
CHECK
(
data
->
logk_mineral
(
1
)
==
-
10.0
);
CHECK
(
data
->
molar_volume_mineral
(
1
)
==
1e-6
*
20.0
);
// Kinetic mineral
CHECK
(
data
->
nb_mineral_kinetic
()
==
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
)
==
-
5.0
);
CHECK
(
data
->
molar_volume_mineral_kinetic
(
0
)
==
1e-6
*
30.0
);
// gas
CHECK
(
data
->
nb_gas
()
==
1
);
CHECK
(
data
->
nu_gas
(
0
,
0
)
==
0.0
);
CHECK
(
data
->
nu_gas
(
0
,
1
)
==
0.0
);
CHECK
(
data
->
nu_gas
(
0
,
2
)
==
-
1.0
);
CHECK
(
data
->
nu_gas
(
0
,
3
)
==
0.0
);
CHECK
(
data
->
nu_gas
(
0
,
4
)
==
1.0
);
CHECK
(
data
->
logk_gas
(
0
)
==
5.0
);
// Sorbed
CHECK
(
data
->
nb_sorbed
()
==
1
);
CHECK
(
data
->
sorbed
.
get_label
(
0
)
==
"S1"
);
CHECK
(
data
->
nu_sorbed
(
0
,
0
)
==
0.0
);
CHECK
(
data
->
nu_sorbed
(
0
,
1
)
==
0.0
);
CHECK
(
data
->
nu_sorbed
(
0
,
2
)
==
-
1.0
);
CHECK
(
data
->
nu_sorbed
(
0
,
3
)
==
0.0
);
CHECK
(
data
->
nu_sorbed
(
0
,
4
)
==
1.0
);
CHECK
(
data
->
logk_sorbed
(
0
)
==
-
4
);
}
}
Event Timeline
Log In to Comment