Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
teqp_fork_old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Sven Michael Pohl
teqp_fork_old
Commits
4d46df0e
Commit
4d46df0e
authored
3 years ago
by
Ian Bell
Browse files
Options
Downloads
Patches
Plain Diff
Add benchmarking script with Catch2
parent
ebefc8d2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/bench.cpp
+88
-0
88 additions, 0 deletions
src/bench.cpp
with
88 additions
and
0 deletions
src/bench.cpp
0 → 100644
+
88
−
0
View file @
4d46df0e
#define CATCH_CONFIG_ENABLE_BENCHMARKING
#define CATCH_CONFIG_MAIN
#include
<catch/catch.hpp>
#include
"teqp/models/eos.hpp"
#include
"teqp/models/pcsaft.hpp"
#include
"teqp/derivs.hpp"
TEST_CASE
(
"vdW derivatives"
,
"[vdW]"
)
{
double
Omega_b
=
1.0
/
8
,
Omega_a
=
27.0
/
64
;
double
Tcrit
=
150.687
,
pcrit
=
4863000.0
;
// Argon
double
R
=
get_R_gas
<
double
>
();
// Universal gas constant
double
b
=
Omega_b
*
R
*
Tcrit
/
pcrit
;
double
ba
=
Omega_b
/
Omega_a
/
Tcrit
/
R
;
double
a
=
b
/
ba
;
auto
model
=
vdWEOS1
(
a
,
b
);
double
T
=
300
,
rho
=
2
;
std
::
valarray
<
double
>
z
(
2
,
1.0
);
using
tdx
=
TDXDerivatives
<
decltype
(
model
),
double
,
decltype
(
z
)
>
;
BENCHMARK
(
"alphar"
)
{
return
model
.
alphar
(
T
,
rho
,
z
);
};
BENCHMARK
(
"alphar via get_Ar00"
)
{
return
tdx
::
get_Ar00
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"rho*dalphar/drho w/ autodiff"
)
{
return
tdx
::
get_Ar01
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"rho*dalphar/drho w/ multicomplex"
)
{
return
tdx
::
get_Ar01
<
ADBackends
::
multicomplex
>
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"rho*dalphar/drho w/ complex step"
)
{
return
tdx
::
get_Ar01
<
ADBackends
::
complex_step
>
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"rho^2*d^2alphar/drho^2 w/ autodiff"
)
{
return
tdx
::
get_Ar02
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"rho^2*d^2alphar/drho^2 w/ multicomplex"
)
{
return
tdx
::
get_Ar02
<
ADBackends
::
multicomplex
>
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"(1/T)*dalphar/d(1/T) w/ autodiff"
)
{
return
tdx
::
get_Ar10
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"(1/T)*dalphar/d(1/T) w/ mcx"
)
{
return
tdx
::
get_Ar10
<
ADBackends
::
multicomplex
>
(
model
,
T
,
rho
,
z
);
};
}
TEST_CASE
(
"PCSAFT derivatives"
,
"[PCSAFT]"
)
{
std
::
vector
<
std
::
string
>
names
=
{
"Methane"
,
"Ethane"
};
auto
model
=
PCSAFTMixture
(
names
);
double
T
=
300
,
rho
=
2
;
Eigen
::
ArrayX
<
double
>
z
(
2
);
z
.
fill
(
1.0
);
using
tdx
=
TDXDerivatives
<
decltype
(
model
),
double
,
decltype
(
z
)
>
;
BENCHMARK
(
"alphar"
)
{
return
model
.
alphar
(
T
,
rho
,
z
);
};
BENCHMARK
(
"alphar via get_Ar00"
)
{
return
tdx
::
get_Ar00
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"rho*dalphar/drho w/ autodiff"
)
{
return
tdx
::
get_Ar01
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"rho*dalphar/drho w/ multicomplex"
)
{
return
tdx
::
get_Ar01
<
ADBackends
::
multicomplex
>
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"rho*dalphar/drho w/ complex step"
)
{
return
tdx
::
get_Ar01
<
ADBackends
::
complex_step
>
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"rho^2*d^2alphar/drho^2 w/ autodiff"
)
{
return
tdx
::
get_Ar02
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"rho^2*d^2alphar/drho^2 w/ multicomplex"
)
{
return
tdx
::
get_Ar02
<
ADBackends
::
multicomplex
>
(
model
,
T
,
rho
,
z
);
};
BENCHMARK
(
"(1/T)*dalphar/d(1/T) w/ autodiff"
)
{
return
tdx
::
get_Ar10
(
model
,
T
,
rho
,
z
);
};
/*BENCHMARK("(1/T)*dalphar/d(1/T) w/ mcx") {
return tdx::get_Ar10<ADBackends::multicomplex>(model, T, rho, z);
};*/
}
\ No newline at end of file
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