Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79494886
secondary.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
Mon, Aug 26, 17:23
Size
2 KB
Mime Type
text/x-c
Expires
Wed, Aug 28, 17:23 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20193897
Attached To
rSPECMICP SpecMiCP / ReactMiCP
secondary.cpp
View Options
#include "catch.hpp"
#include "utils.hpp"
#include "test_database.hpp"
#include "reactmicp/systems/diffusion/diffusion_secondary.hpp"
#include "database/database.hpp"
using
namespace
specmicp
;
using
namespace
specmicp
::
reactmicp
::
systems
::
diffusion
;
TEST_CASE
(
"Secondary variables"
,
"[Secondary, Diffusion]"
)
{
DiffusionSecondaryVariables
::
Variables
var
;
std
::
shared_ptr
<
database
::
DataContainer
>
database
=
get_test_carbo_database
();
EquilibriumState
comp_bc
;
comp_bc
=
blank_composition
(
database
);
BoundaryCondition
bc_node0
;
bc_node0
.
node
=
0
;
bc_node0
.
composition
=
comp_bc
;
bc_node0
.
fix_all
();
ListBoundaryCondition
bcs
=
{
bc_node0
,};
DiffusionNumbering
numberer
(
5
,
database
,
bcs
,
var
);
SECTION
(
"Initialization"
)
{
DiffusionSecondaryVariables
secondary
(
5
,
database
,
numberer
);
CHECK
(
secondary
.
secondary_concentration
(
2
,
2
)
==
0
);
CHECK
(
secondary
.
secondary_concentration
(
2
,
3
)
==
0
);
CHECK
(
secondary
.
secondary_concentration
(
2
,
4
)
==
0
);
CHECK
(
secondary
.
loggamma_component
(
2
,
3
)
==
0
);
CHECK
(
secondary
.
loggamma_secondary
(
2
,
3
)
==
0
);
}
SECTION
(
"Ionic strength computation"
)
{
DiffusionSecondaryVariables
secondary
(
5
,
database
,
numberer
);
database
::
Database
database_handler
(
database
);
var
.
displacement
(
numberer
.
get_dof_massbalance
(
1
,
database_handler
.
component_label_to_id
(
"Ca[2+]"
)))
=
-
3
;
var
.
displacement
(
numberer
.
get_dof_massbalance
(
1
,
database_handler
.
component_label_to_id
(
"HO[-]"
)))
=
-
3
;
var
.
displacement
(
numberer
.
get_dof_massbalance
(
1
,
database_handler
.
component_label_to_id
(
"HCO3[-]"
)))
=
-
3
;
var
.
displacement
(
numberer
.
get_dof_massbalance
(
1
,
database_handler
.
component_label_to_id
(
"SiO(OH)3[-]"
)))
=
-
3
;
secondary
.
nodal_ionic_strength
(
1
,
var
);
REQUIRE
(
secondary
.
ionic_strength
(
1
)
==
(
4
*
1e-3
+
3
*
1e-3
)
*
0.5
);
secondary
.
secondary_concentration
(
1
,
database_handler
.
aqueous_label_to_id
(
"CO3[2-]"
))
=
1e-2
;
secondary
.
nodal_ionic_strength
(
1
,
var
);
REQUIRE
(
secondary
.
ionic_strength
(
1
)
==
(
4
*
1e-3
+
3
*
1e-3
+
4
*
1e-2
)
*
0.5
);
secondary
.
secondary_concentration
(
1
,
database_handler
.
aqueous_label_to_id
(
"CO2"
))
=
1e-1
;
secondary
.
nodal_ionic_strength
(
1
,
var
);
REQUIRE
(
secondary
.
ionic_strength
(
1
)
==
(
4
*
1e-3
+
3
*
1e-3
+
4
*
1e-2
)
*
0.5
);
}
SECTION
(
"Aqueous concentration"
)
{
DiffusionSecondaryVariables
secondary
(
5
,
database
,
numberer
);
secondary
.
ionic_strength
(
0
)
=
comp_bc
.
ionic_strength
();
secondary
.
nodal_loggamma
(
0
);
secondary
.
nodal_secondary_concentrations
(
0
,
var
);
for
(
int
aq:
database
->
range_aqueous
())
{
REQUIRE
(
std
::
pow
(
10.0
,
secondary
.
loggamma_secondary
(
0
,
aq
))
==
comp_bc
.
activity_coefficient_secondary
(
aq
));
REQUIRE
(
std
::
abs
(
secondary
.
secondary_concentration
(
0
,
aq
)
-
comp_bc
.
molality_secondary
()[
aq
])
<
1e-7
);
}
}
}
Event Timeline
Log In to Comment