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
Özgür Ozan Sen
ogs
Commits
c8f17f12
Commit
c8f17f12
authored
9 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[T] material class test
parent
ec28eecc
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/MathLib/TestNonlinear1D_Zeolite.cpp
+82
-0
82 additions, 0 deletions
Tests/MathLib/TestNonlinear1D_Zeolite.cpp
with
82 additions
and
0 deletions
Tests/MathLib/TestNonlinear1D_Zeolite.cpp
0 → 100644
+
82
−
0
View file @
c8f17f12
#include
<gtest/gtest.h>
#include
<cstdio>
#include
"MathLib/Nonlinear/Root1D.h"
#include
"MaterialsLib/adsorption/adsorption.h"
using
namespace
Ads
;
namespace
{
const
double
T
=
303.15
;
// K
const
double
R
=
8.314
;
// J/mol/K
const
double
M
=
0.018
;
// kg/mol
const
double
phi
=
0.4
;
const
double
rho_SR0
=
1160.0
;
// kg/m^3
// const double k = 6e-3; // s^-1
const
double
C0
=
0.0
;
const
double
pV0
=
1e2
;
Adsorption
*
ads
=
Adsorption
::
newInstance
(
SolidReactiveSystem
::
Z13XBF_Hauer
);
double
f
(
const
double
pV
)
{
const
double
C
=
ads
->
get_equilibrium_loading
(
pV
,
T
,
M
);
return
(
phi
-
1
)
/
phi
*
(
C
-
C0
)
*
rho_SR0
*
R
*
T
/
M
+
pV0
-
pV
;
}
double
f2
(
const
double
pV
)
{
const
double
C
=
ads
->
get_equilibrium_loading
(
pV
,
T
,
M
);
// return (phi-1)/phi * (C - C0) * rho_SR0 * R*T/M + pV0 - pV;
return
(
pV
-
pV0
)
*
M
/
R
/
T
*
phi
+
(
1
-
phi
)
*
(
C
-
C0
)
*
rho_SR0
;
}
}
// anonymous namespace
template
<
typename
T
>
class
RegulaFalsiTestZeolite
:
public
::
testing
::
Test
{
};
using
namespace
MathLib
::
Nonlinear
;
typedef
::
testing
::
Types
<
Unmodified
,
Illinois
,
Pegasus
,
AndersonBjorck
>
RegulaFalsiTypes
;
TYPED_TEST_CASE
(
RegulaFalsiTestZeolite
,
RegulaFalsiTypes
);
TYPED_TEST
(
RegulaFalsiTestZeolite
,
Zeolite
)
{
auto
rf
=
makeRegulaFalsi
<
TypeParam
>
(
f
,
1e-8
,
pV0
);
std
::
printf
(
" 0 -- x ~ %14.7g, range = %14.7g
\n
"
,
rf
.
get_result
(),
rf
.
get_range
());
for
(
unsigned
n
=
0
;
n
<
10
;
++
n
)
{
rf
.
step
(
1
);
std
::
printf
(
"%2i -- x ~ %14.7g, range = %14.7g
\n
"
,
n
+
1
,
rf
.
get_result
(),
rf
.
get_range
());
}
}
TYPED_TEST
(
RegulaFalsiTestZeolite
,
Zeolite2
)
{
// auto rf = MakeRegulaFalsi<TypeParam>::create(f2, 1e-8, pV0);
auto
rf
=
makeRegulaFalsi
<
TypeParam
>
(
f2
,
1e-8
,
pV0
);
std
::
printf
(
" 0 -- x ~ %14.7g, range = %14.7g
\n
"
,
rf
.
get_result
(),
rf
.
get_range
());
for
(
unsigned
n
=
0
;
n
<
10
;
++
n
)
{
rf
.
step
(
1
);
std
::
printf
(
"%2i -- x ~ %14.7g, range = %14.7g
\n
"
,
n
+
1
,
rf
.
get_result
(),
rf
.
get_range
());
}
}
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