Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F71460950
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
Thu, Jul 11, 23:25
Size
2 KB
Mime Type
text/x-c
Expires
Sat, Jul 13, 23:25 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
18912739
Attached To
rSPECMICP SpecMiCP / ReactMiCP
variables.cpp
View Options
#include "catch.hpp"
#include "utils.hpp"
#include "reactmicp/systems/saturated_diffusion/variables.hpp"
#include "reactmicp/meshes/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
;
std
::
shared_ptr
<
mesh
::
Mesh1D
>
themesh
=
std
::
make_shared
<
mesh
::
Mesh1D
>
(
nb_nodes
-
1
,
1e-3
,
0.001
);
auto
parameters
=
std
::
make_shared
<
SaturatedDiffusionTransportParameters
>
(
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
)
==
composition
.
molality_component
(
1
));
REQUIRE
(
variables
.
total_mobile_concentration
(
1
,
1
)
==
composition
.
total_aqueous_concentration_component
(
1
));
}
}
Event Timeline
Log In to Comment