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
Chaofan Chen
ogs
Commits
cf7550b4
Commit
cf7550b4
authored
7 months ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[T/MPL] Extract common central diff derivative
parent
1de971be
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/MaterialLib/TestMPLWaterVapourDensity.cpp
+23
-23
23 additions, 23 deletions
Tests/MaterialLib/TestMPLWaterVapourDensity.cpp
with
23 additions
and
23 deletions
Tests/MaterialLib/TestMPLWaterVapourDensity.cpp
+
23
−
23
View file @
cf7550b4
...
@@ -17,6 +17,23 @@
...
@@ -17,6 +17,23 @@
#include
"MaterialLib/MPL/Properties/Density/CreateWaterVapourDensity.h"
#include
"MaterialLib/MPL/Properties/Density/CreateWaterVapourDensity.h"
#include
"TestMPL.h"
#include
"TestMPL.h"
static
double
centralDifferencesDerivative
(
double
const
value
,
double
MaterialPropertyLib
::
VariableArray
::*
variable
,
double
const
value_increment
,
MaterialPropertyLib
::
Property
const
&
property
,
MaterialPropertyLib
::
VariableArray
variable_array
,
const
auto
&
pos
,
double
const
t
,
double
const
dt
)
{
variable_array
.
*
variable
=
value
-
value_increment
;
double
const
value_minus
=
property
.
template
value
<
double
>(
variable_array
,
pos
,
t
,
dt
);
variable_array
.
*
variable
=
value
+
value_increment
;
double
const
value_plus
=
property
.
template
value
<
double
>(
variable_array
,
pos
,
t
,
dt
);
return
0.5
*
(
value_plus
-
value_minus
)
/
value_increment
;
}
TEST
(
MaterialPropertyLib
,
WaterVapourDensity
)
TEST
(
MaterialPropertyLib
,
WaterVapourDensity
)
{
{
char
const
xml
[]
=
char
const
xml
[]
=
...
@@ -62,17 +79,9 @@ TEST(MaterialPropertyLib, WaterVapourDensity)
...
@@ -62,17 +79,9 @@ TEST(MaterialPropertyLib, WaterVapourDensity)
<<
"for expected water vapour density "
<<
rho_vw_expected
[
i
]
<<
"for expected water vapour density "
<<
rho_vw_expected
[
i
]
<<
" and for computed water vapour density "
<<
rho_vw
;
<<
" and for computed water vapour density "
<<
rho_vw
;
double
const
dT
=
1.0e-4
;
double
const
approximated_drho_wv_dT
=
centralDifferencesDerivative
(
variable_array
.
temperature
=
T_i
-
dT
;
T_i
,
&
MaterialPropertyLib
::
VariableArray
::
temperature
,
1e-4
,
double
const
rho_vw0
=
property
,
variable_array
,
pos
,
t
,
dt
);
property
.
template
value
<
double
>(
variable_array
,
pos
,
t
,
dt
);
variable_array
.
temperature
=
T_i
+
dT
;
double
const
rho_vw1
=
property
.
template
value
<
double
>(
variable_array
,
pos
,
t
,
dt
);
double
const
approximated_drho_wv_dT
=
0.5
*
(
rho_vw1
-
rho_vw0
)
/
dT
;
double
const
analytic_drho_wv_dT
=
property
.
template
dValue
<
double
>(
double
const
analytic_drho_wv_dT
=
property
.
template
dValue
<
double
>(
variable_array
,
MaterialPropertyLib
::
Variable
::
temperature
,
pos
,
variable_array
,
MaterialPropertyLib
::
Variable
::
temperature
,
pos
,
...
@@ -111,18 +120,9 @@ TEST(MaterialPropertyLib, WaterVapourDensity)
...
@@ -111,18 +120,9 @@ TEST(MaterialPropertyLib, WaterVapourDensity)
<<
"for expected water vapour density "
<<
rho_vw_expected
[
i
]
<<
"for expected water vapour density "
<<
rho_vw_expected
[
i
]
<<
" and for computed water vapour density "
<<
rho_vw
;
<<
" and for computed water vapour density "
<<
rho_vw
;
double
const
dp
=
1.0e-3
;
double
const
approximated_drho_wv_dp
=
centralDifferencesDerivative
(
variable_array
.
liquid_phase_pressure
=
p_i
-
dp
;
p_i
,
&
MaterialPropertyLib
::
VariableArray
::
liquid_phase_pressure
,
1e-3
,
property
,
variable_array
,
pos
,
t
,
dt
);
double
const
rho_vw0
=
property
.
template
value
<
double
>(
variable_array
,
pos
,
t
,
dt
);
variable_array
.
liquid_phase_pressure
=
p_i
+
dp
;
double
const
rho_vw1
=
property
.
template
value
<
double
>(
variable_array
,
pos
,
t
,
dt
);
double
const
approximated_drho_wv_dp
=
0.5
*
(
rho_vw1
-
rho_vw0
)
/
dp
;
double
const
analytic_drho_wv_dp
=
property
.
template
dValue
<
double
>(
double
const
analytic_drho_wv_dp
=
property
.
template
dValue
<
double
>(
variable_array
,
variable_array
,
...
...
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