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
3f55682f
Commit
3f55682f
authored
4 years ago
by
Ian Bell
Browse files
Options
Downloads
Patches
Plain Diff
Add all the virial coefficients up to the n-th, and a tiny test of this
parent
cb867cf4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/teqp/derivs.hpp
+8
-0
8 additions, 0 deletions
include/teqp/derivs.hpp
src/main.cpp
+13
-1
13 additions, 1 deletion
src/main.cpp
with
21 additions
and
1 deletion
include/teqp/derivs.hpp
+
8
−
0
View file @
3f55682f
...
...
@@ -110,6 +110,14 @@ typename ContainerType::value_type get_B2vir(const Model& model, const TType T,
return
B2
;
}
template
<
typename
Model
,
typename
TType
,
typename
ContainerType
>
auto
get_Bnvir
(
const
Model
&
model
,
int
Nderiv
,
const
TType
T
,
const
ContainerType
&
molefrac
)
{
// B_n = lim_rho\to 0 d^{n-1}alphar/drho^{n-1}|T,z
using
fcn_t
=
std
::
function
<
MultiComplex
<
double
>
(
const
MultiComplex
<
double
>&
)
>
;
fcn_t
f
=
[
&
model
,
&
T
,
&
molefrac
](
const
MultiComplex
<
double
>&
rho_
)
->
MultiComplex
<
double
>
{
return
model
.
alphar
(
T
,
rho_
,
molefrac
);
};
return
diff_mcx1
(
f
,
0.0
,
Nderiv
,
true
/* and_val */
);
}
/***
* \brief Calculate the residual entropy (s^+ = -sr/R) from derivatives of alphar
*/
...
...
This diff is collapsed.
Click to expand it.
src/main.cpp
+
13
−
1
View file @
3f55682f
...
...
@@ -34,6 +34,17 @@ void test_vdW() {
std
::
cout
<<
std
::
chrono
::
duration
<
double
>
(
t31
-
t21
).
count
()
<<
" from isochoric"
<<
std
::
endl
;
auto
err
=
pfromderiv
/
pp
-
1.0
;
std
::
cout
<<
"Error (fractional): "
<<
err
<<
std
::
endl
;
std
::
valarray
<
double
>
molefrac
=
{
1.0
};
double
B2
=
get_B2vir
(
vdW
,
T
,
molefrac
);
double
B2exact
=
b
-
a
/
(
R
*
T
);
auto
Bn
=
get_Bnvir
(
vdW
,
8
,
T
,
molefrac
);
std
::
valarray
<
double
>
Bnexact
=
{
0
,
b
-
a
/
(
R
*
T
),
b
*
b
,
2
*
b
*
b
*
b
,
6
*
b
*
b
*
b
*
b
,
24
*
b
*
b
*
b
*
b
*
b
,
120
*
std
::
pow
(
b
,
6
),
720
*
std
::
pow
(
b
,
7
),
5040
*
pow
(
b
,
8
)
};
std
::
valarray
<
double
>
errrr
=
Bnexact
-
std
::
valarray
<
double
>
(
&
(
Bn
[
0
]),
Bn
.
size
());
int
rr
=
0
;
}
void
test_vdwMix
()
{
...
...
@@ -52,7 +63,8 @@ void test_vdwMix() {
auto
fPsir
=
[
&
vdW
](
const
auto
&
T
,
const
auto
&
rhovec
)
{
using
container
=
decltype
(
rhovec
);
auto
rhotot_
=
std
::
accumulate
(
std
::
begin
(
rhovec
),
std
::
end
(
rhovec
),
(
decltype
(
rhovec
[
0
]))
0.0
);
return
vdW
.
alphar
(
T
,
rhovec
)
*
vdW
.
R
*
T
*
rhotot_
;
auto
molefrac
=
rhovec
/
rhotot_
;
return
vdW
.
alphar
(
T
,
rhotot_
,
molefrac
)
*
vdW
.
R
*
T
*
rhotot_
;
};
auto
Psir
=
fPsir
(
T
,
rhovec
);
auto
dPsirdrho0
=
rhovec
[
0
]
*
derivrhoi
(
fPsir
,
T
,
rhovec
,
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