Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
MostafaMollaali
dynamic
Commits
ffcec24b
Commit
ffcec24b
authored
5 years ago
by
renchao.lu
Committed by
Dmitri Naumov
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[CL] Create class PhreeqcIO.
parent
a8cd638f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ChemistryLib/CreatePhreeqcIO.cpp
+117
-0
117 additions, 0 deletions
ChemistryLib/CreatePhreeqcIO.cpp
ChemistryLib/CreatePhreeqcIO.h
+34
-0
34 additions, 0 deletions
ChemistryLib/CreatePhreeqcIO.h
ChemistryLib/PhreeqcIO.h
+59
-0
59 additions, 0 deletions
ChemistryLib/PhreeqcIO.h
with
210 additions
and
0 deletions
ChemistryLib/CreatePhreeqcIO.cpp
0 → 100644
+
117
−
0
View file @
ffcec24b
/**
* \copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include
<fstream>
#include
"BaseLib/ConfigTreeUtil.h"
#include
"BaseLib/Error.h"
#include
"CreateOutput.h"
#include
"CreatePhreeqcIO.h"
#include
"PhreeqcIO.h"
#include
"PhreeqcIOData/AqueousSolution.h"
#include
"PhreeqcIOData/EquilibriumPhase.h"
#include
"PhreeqcIOData/KineticReactant.h"
#include
"PhreeqcIOData/ReactionRate.h"
namespace
ChemistryLib
{
std
::
unique_ptr
<
PhreeqcIO
>
createPhreeqcIO
(
std
::
size_t
const
num_nodes
,
std
::
vector
<
std
::
pair
<
int
,
std
::
string
>>
const
&
process_id_to_component_name_map
,
boost
::
optional
<
BaseLib
::
ConfigTree
>
const
&
config
,
std
::
string
const
&
output_directory
)
{
auto
const
&
num_chemical_systems
=
num_nodes
;
// database
//! \ogs_file_param{prj__chemical_system__database}
auto
const
database
=
config
->
getConfigParameter
<
std
::
string
>
(
"database"
);
auto
path_to_database
=
BaseLib
::
joinPaths
(
BaseLib
::
getProjectDirectory
(),
database
);
if
(
BaseLib
::
IsFileExisting
(
path_to_database
))
{
INFO
(
"Found the specified thermodynamic database: %s"
,
path_to_database
.
c_str
());
}
else
{
OGS_FATAL
(
"Not found the specified thermodynamicdatabase: %s"
,
path_to_database
.
c_str
());
}
// solution
auto
const
aqueous_solution_per_chem_sys
=
createAqueousSolution
(
//! \ogs_file_param{prj__chemical_system__solution}
config
->
getConfigSubtree
(
"solution"
));
auto
const
&
components_per_chem_sys
=
aqueous_solution_per_chem_sys
.
components
;
for
(
auto
const
&
component
:
components_per_chem_sys
)
{
auto
process_id_to_component_name_map_element
=
std
::
find_if
(
process_id_to_component_name_map
.
begin
(),
process_id_to_component_name_map
.
end
(),
[
&
component
](
std
::
pair
<
int
,
std
::
string
>
const
&
map_element
)
{
return
map_element
.
second
==
component
.
name
;
});
if
(
process_id_to_component_name_map_element
==
process_id_to_component_name_map
.
end
())
OGS_FATAL
(
"Component %s given in <solution>/<components> is not found in "
"specified coupled processes (see "
"<process>/<process_variables>/<concentration>)."
,
component
.
name
.
c_str
());
}
if
(
components_per_chem_sys
.
size
()
+
1
!=
process_id_to_component_name_map
.
size
())
OGS_FATAL
(
"The number of components given in <solution>/<components> is not "
"in line with the number of transport processes - 1 which stands "
"for the transport process of hydrogen."
);
std
::
vector
<
AqueousSolution
>
aqueous_solutions
(
num_chemical_systems
,
aqueous_solution_per_chem_sys
);
// equilibrium phases
auto
const
equilibrium_phases_per_chem_sys
=
createEquilibriumPhases
(
//! \ogs_file_param{prj__chemical_system__equilibrium_phases}
config
->
getConfigSubtreeOptional
(
"equilibrium_phases"
));
std
::
vector
<
std
::
vector
<
EquilibriumPhase
>>
equilibrium_phases
(
num_chemical_systems
,
equilibrium_phases_per_chem_sys
);
// kinetic reactants
auto
const
kinetic_reactants_per_chem_sys
=
createKineticReactants
(
//! \ogs_file_param{prj__chemical_system__kinetic_reactants}
config
->
getConfigSubtreeOptional
(
"kinetic_reactants"
));
std
::
vector
<
std
::
vector
<
KineticReactant
>>
kinetic_reactants
(
num_chemical_systems
,
kinetic_reactants_per_chem_sys
);
// rates
auto
reaction_rates
=
createReactionRates
(
//! \ogs_file_param{prj__chemical_system__rates}
config
->
getConfigSubtreeOptional
(
"rates"
));
// output
auto
const
project_file_name
=
BaseLib
::
joinPaths
(
output_directory
,
BaseLib
::
extractBaseNameWithoutExtension
(
config
->
getProjectFileName
()));
auto
output
=
createOutput
(
components_per_chem_sys
,
equilibrium_phases_per_chem_sys
,
kinetic_reactants_per_chem_sys
,
project_file_name
);
return
std
::
make_unique
<
PhreeqcIO
>
(
project_file_name
,
std
::
move
(
path_to_database
),
std
::
move
(
aqueous_solutions
),
std
::
move
(
equilibrium_phases
),
std
::
move
(
kinetic_reactants
),
std
::
move
(
reaction_rates
),
std
::
move
(
output
),
process_id_to_component_name_map
);
}
}
// namespace ChemistryLib
This diff is collapsed.
Click to expand it.
ChemistryLib/CreatePhreeqcIO.h
0 → 100644
+
34
−
0
View file @
ffcec24b
/**
* \copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include
<memory>
#include
"PhreeqcIO.h"
namespace
BaseLib
{
class
ConfigTree
;
}
namespace
ProcessLib
{
class
Process
;
}
namespace
ChemistryLib
{
std
::
unique_ptr
<
PhreeqcIO
>
createPhreeqcIO
(
std
::
size_t
const
num_nodes
,
std
::
vector
<
std
::
pair
<
int
,
std
::
string
>>
const
&
process_id_to_component_name_map
,
boost
::
optional
<
BaseLib
::
ConfigTree
>
const
&
config
,
std
::
string
const
&
output_directory
);
}
// namespace ChemistryLib
This diff is collapsed.
Click to expand it.
ChemistryLib/PhreeqcIO.h
0 → 100644
+
59
−
0
View file @
ffcec24b
/**
* \copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include
<memory>
#include
"MathLib/LinAlg/GlobalMatrixVectorTypes.h"
#include
"Output.h"
#include
"PhreeqcIOData/AqueousSolution.h"
#include
"PhreeqcIOData/EquilibriumPhase.h"
#include
"PhreeqcIOData/KineticReactant.h"
#include
"PhreeqcIOData/ReactionRate.h"
namespace
ChemistryLib
{
class
PhreeqcIO
{
public:
PhreeqcIO
(
std
::
string
const
&
project_file_name
,
std
::
string
&&
database
,
std
::
vector
<
AqueousSolution
>&&
aqueous_solutions
,
std
::
vector
<
std
::
vector
<
EquilibriumPhase
>>&&
equilibrium_phases
,
std
::
vector
<
std
::
vector
<
KineticReactant
>>&&
kinetic_reactants
,
std
::
vector
<
ReactionRate
>&&
reaction_rates
,
std
::
unique_ptr
<
Output
>&&
output
,
std
::
vector
<
std
::
pair
<
int
,
std
::
string
>>
const
&
process_id_to_component_name_map
)
:
_phreeqc_input_file
(
project_file_name
+
"_phreeqc.inp"
),
_database
(
std
::
move
(
database
)),
_aqueous_solutions
(
std
::
move
(
aqueous_solutions
)),
_equilibrium_phases
(
std
::
move
(
equilibrium_phases
)),
_kinetic_reactants
(
std
::
move
(
kinetic_reactants
)),
_reaction_rates
(
std
::
move
(
reaction_rates
)),
_output
(
std
::
move
(
output
)),
_process_id_to_component_name_map
(
process_id_to_component_name_map
)
{
}
std
::
string
const
_phreeqc_input_file
;
private
:
std
::
string
const
_database
;
std
::
vector
<
AqueousSolution
>
_aqueous_solutions
;
std
::
vector
<
std
::
vector
<
EquilibriumPhase
>>
_equilibrium_phases
;
std
::
vector
<
std
::
vector
<
KineticReactant
>>
_kinetic_reactants
;
std
::
vector
<
ReactionRate
>
const
_reaction_rates
;
std
::
unique_ptr
<
Output
>
const
_output
;
std
::
vector
<
std
::
pair
<
int
,
std
::
string
>>
const
&
_process_id_to_component_name_map
;
double
_dt
;
};
}
// namespace ChemistryLib
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