Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110623329
test_specmicp.py
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
Sun, Apr 27, 05:14
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Apr 29, 05:14 (2 d)
Engine
blob
Format
Raw Data
Handle
25804278
Attached To
rSPECMICP SpecMiCP / ReactMiCP
test_specmicp.py
View Options
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
unittest
as
ut
import
sys
lib_directory
=
"@python_module_path@"
database_path
=
b
"@database_path@"
sys
.
path
.
insert
(
0
,
lib_directory
)
import
specmicp.database
as
database
import
specmicp.constraints
as
constraints
import
specmicp.solver
as
solver
class
TestSpecmicp
(
ut
.
TestCase
):
def
setUp
(
self
):
self
.
db
=
database
.
DatabaseManager
(
database_path
)
swapping
=
{
b
"H[+]"
:
b
"HO[-]"
,
}
self
.
db
.
swap_components
(
swapping
)
def
test_solver
(
self
):
formulation
=
constraints
.
SpecMiCPFormulation
(
self
.
db
)
formulation
.
set_mass_solution
(
0.5
)
formulation
.
add_mineral
(
b
"Portlandite"
,
10
)
formulation
.
add_aqueous_species
(
b
"CO2"
,
0.5
)
formulation
.
initialize_system
()
the_solver
=
solver
.
SpecMiCPSolver
(
self
.
db
,
formulation
,
None
)
the_solver
.
set_length_unit
(
"decimeter"
)
the_solver
.
solve
()
the_solution
=
the_solver
.
get_solution
()
self
.
assertTrue
(
abs
(
the_solution
.
pH
()
-
12.487998
)
<
1e-3
)
def
test_solver_fail
(
self
):
formulation
=
constraints
.
SpecMiCPFormulation
(
self
.
db
)
formulation
.
set_mass_solution
(
0.5
)
formulation
.
add_mineral
(
b
"Portlandite"
,
10000
)
formulation
.
add_aqueous_species
(
b
"CO2"
,
0.5
)
formulation
.
initialize_system
()
the_solver
=
solver
.
SpecMiCPSolver
(
self
.
db
,
formulation
,
None
)
the_solver
.
set_length_unit
(
"decimeter"
)
self
.
assertRaises
(
RuntimeError
,
the_solver
.
solve
)
if
__name__
==
'__main__'
:
ut
.
main
()
Event Timeline
Log In to Comment