Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dmitri Naumov
ogs
Commits
ffa81a05
Commit
ffa81a05
authored
4 years ago
by
renchao.lu
Browse files
Options
Downloads
Patches
Plain Diff
[CL] Set aqueous solution.
parent
7c0e62f3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ChemistryLib/PhreeqcIO.cpp
+15
-59
15 additions, 59 deletions
ChemistryLib/PhreeqcIO.cpp
ChemistryLib/PhreeqcIO.h
+2
-9
2 additions, 9 deletions
ChemistryLib/PhreeqcIO.h
with
17 additions
and
68 deletions
ChemistryLib/PhreeqcIO.cpp
+
15
−
59
View file @
ffa81a05
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include
"BaseLib/Algorithm.h"
#include
"BaseLib/Algorithm.h"
#include
"BaseLib/ConfigTreeUtil.h"
#include
"BaseLib/ConfigTreeUtil.h"
#include
"MathLib/LinAlg/Eigen/EigenVector.h"
#include
"MathLib/LinAlg/Eigen/EigenVector.h"
#include
"MathLib/LinAlg/LinAlg.h"
#include
"MeshLib/Mesh.h"
#include
"MeshLib/Mesh.h"
#include
"PhreeqcIOData/AqueousSolution.h"
#include
"PhreeqcIOData/AqueousSolution.h"
#include
"PhreeqcIOData/ChemicalSystem.h"
#include
"PhreeqcIOData/ChemicalSystem.h"
...
@@ -116,8 +117,7 @@ void PhreeqcIO::initialize()
...
@@ -116,8 +117,7 @@ void PhreeqcIO::initialize()
void
PhreeqcIO
::
executeInitialCalculation
(
void
PhreeqcIO
::
executeInitialCalculation
(
std
::
vector
<
GlobalVector
>
const
&
interpolated_process_solutions
)
std
::
vector
<
GlobalVector
>
const
&
interpolated_process_solutions
)
{
{
setAqueousSolutionsOrUpdateProcessSolutions
(
setAqueousSolution
(
interpolated_process_solutions
);
process_solutions
,
Status
::
SettingAqueousSolutions
);
writeInputsToFile
();
writeInputsToFile
();
...
@@ -132,8 +132,7 @@ void PhreeqcIO::executeInitialCalculation(
...
@@ -132,8 +132,7 @@ void PhreeqcIO::executeInitialCalculation(
void
PhreeqcIO
::
doWaterChemistryCalculation
(
void
PhreeqcIO
::
doWaterChemistryCalculation
(
std
::
vector
<
GlobalVector
*>&
process_solutions
,
double
const
dt
)
std
::
vector
<
GlobalVector
*>&
process_solutions
,
double
const
dt
)
{
{
setAqueousSolutionsOrUpdateProcessSolutions
(
setAqueousSolution
(
interpolated_process_solutions
);
process_solutions
,
Status
::
SettingAqueousSolutions
);
setAqueousSolutionsPrevFromDumpFile
();
setAqueousSolutionsPrevFromDumpFile
();
...
@@ -147,66 +146,23 @@ void PhreeqcIO::doWaterChemistryCalculation(
...
@@ -147,66 +146,23 @@ void PhreeqcIO::doWaterChemistryCalculation(
process_solutions
,
Status
::
UpdatingProcessSolutions
);
process_solutions
,
Status
::
UpdatingProcessSolutions
);
}
}
void
PhreeqcIO
::
setAqueousSolution
sOrUpdateProcessSolutions
(
void
PhreeqcIO
::
setAqueousSolution
(
std
::
vector
<
GlobalVector
*
>
const
&
process_solutions
,
Status
const
status
)
std
::
vector
<
GlobalVector
>
const
&
interpolated_
process_solutions
)
{
{
std
::
size_t
const
num_chemical_systems
=
_mesh
.
getNumberOfBaseNodes
();
auto
const
chemical_system_map
=
*
_mesh
.
getProperties
().
template
getPropertyVector
<
std
::
size_t
>(
"bulk_node_ids"
,
MeshLib
::
MeshItemType
::
Node
,
1
);
// Loop over chemical systems
auto
&
aqueous_solution
=
_chemical_system
->
aqueous_solution
;
auto
&
aqueous_solution
=
_chemical_system
->
aqueous_solution
;
// components
auto
&
components
=
aqueous_solution
->
components
;
auto
&
components
=
aqueous_solution
->
components
;
for
(
std
::
size_t
local_id
=
0
;
local_id
<
num_chemical_systems
;
++
local_id
)
for
(
unsigned
component_id
=
0
;
component_id
<
components
.
size
();
++
component_id
)
{
{
auto
const
global_id
=
chemical_system_map
[
local_id
];
MathLib
::
LinAlg
::
copy
(
interpolated_process_solutions
[
component_id
+
1
],
// Loop over transport process id map to retrieve component
*
components
[
component_id
].
amount
);
// concentrations from process solutions or to update process solutions
// after chemical calculation by Phreeqc
for
(
unsigned
component_id
=
0
;
component_id
<
components
.
size
();
++
component_id
)
{
auto
&
component
=
components
[
component_id
];
auto
&
transport_process_solution
=
process_solutions
[
component_id
+
1
];
switch
(
status
)
{
case
Status
::
SettingAqueousSolutions
:
// Set component concentrations.
component
.
amount
->
set
(
local_id
,
(
*
transport_process_solution
)[
global_id
]);
break
;
case
Status
::
UpdatingProcessSolutions
:
// Update solutions of component transport processes.
transport_process_solution
->
set
(
global_id
,
(
*
component
.
amount
)[
local_id
]);
break
;
}
}
switch
(
status
)
{
case
Status
::
SettingAqueousSolutions
:
{
// Set pH value by hydrogen concentration.
aqueous_solution
->
pH
->
set
(
local_id
,
-
std
::
log10
((
*
process_solutions
.
back
())[
global_id
]));
break
;
}
case
Status
::
UpdatingProcessSolutions
:
{
// Update hydrogen concentration by pH value.
auto
hydrogen_concentration
=
std
::
pow
(
10
,
-
(
*
aqueous_solution
->
pH
)[
local_id
]);
process_solutions
.
back
()
->
set
(
global_id
,
hydrogen_concentration
);
break
;
}
}
}
}
// pH
MathLib
::
LinAlg
::
copy
(
interpolated_process_solutions
.
back
(),
*
aqueous_solution
->
pH
);
}
}
void
PhreeqcIO
::
setAqueousSolutionsPrevFromDumpFile
()
void
PhreeqcIO
::
setAqueousSolutionsPrevFromDumpFile
()
...
...
This diff is collapsed.
Click to expand it.
ChemistryLib/PhreeqcIO.h
+
2
−
9
View file @
ffa81a05
...
@@ -31,12 +31,6 @@ struct SurfaceSite;
...
@@ -31,12 +31,6 @@ struct SurfaceSite;
struct
Dump
;
struct
Dump
;
struct
UserPunch
;
struct
UserPunch
;
enum
class
Status
{
SettingAqueousSolutions
,
UpdatingProcessSolutions
};
class
PhreeqcIO
final
:
public
ChemicalSolverInterface
class
PhreeqcIO
final
:
public
ChemicalSolverInterface
{
{
public:
public:
...
@@ -60,9 +54,8 @@ public:
...
@@ -60,9 +54,8 @@ public:
std
::
vector
<
GlobalVector
*>&
process_solutions
,
std
::
vector
<
GlobalVector
*>&
process_solutions
,
double
const
dt
)
override
;
double
const
dt
)
override
;
void
setAqueousSolutionsOrUpdateProcessSolutions
(
void
setAqueousSolution
(
std
::
vector
<
GlobalVector
*>
const
&
process_solutions
,
std
::
vector
<
GlobalVector
>
const
&
interpolated_process_solutions
);
Status
const
status
);
void
writeInputsToFile
(
double
const
dt
=
0
);
void
writeInputsToFile
(
double
const
dt
=
0
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment