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
bc145abb
Commit
bc145abb
authored
4 years ago
by
Ian Bell
Browse files
Options
Downloads
Patches
Plain Diff
Start work on virial coefficients. Perplexing for mixtures.
Fix bug in Ar10
parent
182939a8
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
include/teqp/derivs.hpp
+29
-2
29 additions, 2 deletions
include/teqp/derivs.hpp
with
29 additions
and
2 deletions
include/teqp/derivs.hpp
+
29
−
2
View file @
bc145abb
...
@@ -81,7 +81,34 @@ typename ContainerType::value_type get_pr(const Model& model, const TType T, con
...
@@ -81,7 +81,34 @@ typename ContainerType::value_type get_pr(const Model& model, const TType T, con
template
<
typename
Model
,
typename
TType
,
typename
ContainerType
>
template
<
typename
Model
,
typename
TType
,
typename
ContainerType
>
typename
ContainerType
::
value_type
get_Ar10
(
const
Model
&
model
,
const
TType
T
,
const
ContainerType
&
rhovec
){
typename
ContainerType
::
value_type
get_Ar10
(
const
Model
&
model
,
const
TType
T
,
const
ContainerType
&
rhovec
){
return
T
*
derivT
([
&
model
](
const
auto
&
T
,
const
auto
&
rhovec
)
{
return
model
.
alphar
(
T
,
rhovec
);
},
T
,
rhovec
);
return
-
T
*
derivT
([
&
model
](
const
auto
&
T
,
const
auto
&
rhovec
)
{
return
model
.
alphar
(
T
,
rhovec
);
},
T
,
rhovec
);
}
template
<
typename
Model
,
typename
TType
,
typename
ContainerType
>
typename
ContainerType
::
value_type
get_Ar01
(
const
Model
&
model
,
const
TType
T
,
const
ContainerType
&
rhovec
)
{
auto
rhotot_
=
std
::
accumulate
(
std
::
begin
(
rhovec
),
std
::
end
(
rhovec
),
(
decltype
(
rhovec
[
0
]))
0.0
);
decltype
(
rhovec
[
0
]
*
T
)
Ar01
=
0.0
;
for
(
auto
i
=
0
;
i
<
rhovec
.
size
();
++
i
)
{
Ar01
+=
rhovec
[
i
]
*
derivrhoi
([
&
model
](
const
auto
&
T
,
const
auto
&
rhovec
)
{
return
model
.
alphar
(
T
,
rhovec
);
},
T
,
rhovec
,
i
);
}
return
Ar01
;
}
template
<
typename
Model
,
typename
TType
,
typename
ContainerType
>
typename
ContainerType
::
value_type
get_B2vir
(
const
Model
&
model
,
const
TType
T
,
const
ContainerType
&
molefrac
)
{
auto
rhovec
=
0.0
*
molefrac
;
double
max_mole_frac
=
*
std
::
max_element
(
std
::
begin
(
molefrac
),
std
::
end
(
molefrac
));
if
(
max_mole_frac
!=
1.0
)
{
std
::
cout
<<
"The value for B_2 is incorrect when not pure!"
<<
std
::
endl
;
}
decltype
(
molefrac
[
0
]
*
T
)
B2
=
0.0
;
for
(
auto
i
=
0
;
i
<
rhovec
.
size
();
++
i
)
{
auto
dalphar_drhoi__constTrhoj
=
derivrhoi
([
&
model
](
const
auto
&
T
,
const
auto
&
rhovec
)
{
return
model
.
alphar
(
T
,
rhovec
);
},
T
,
rhovec
,
i
);
B2
+=
molefrac
[
i
]
*
dalphar_drhoi__constTrhoj
;
}
return
B2
;
}
}
/***
/***
...
@@ -106,7 +133,7 @@ template <> void setval<std::valarray<std::valarray<double>>, std::size_t, doubl
...
@@ -106,7 +133,7 @@ template <> void setval<std::valarray<std::valarray<double>>, std::size_t, doubl
/***
/***
* \brief Calculate the Hessian of Psir = ar*rho w.r.t. the molar concentrations
* \brief Calculate the Hessian of Psir = ar*rho w.r.t. the molar concentrations
*
*
* Requires the use of
multicomplex
derivatives to calculate second partial derivatives
* Requires the use of
autodiff
derivatives to calculate second partial derivatives
*/
*/
template
<
typename
Model
,
typename
TType
,
typename
RhoType
>
template
<
typename
Model
,
typename
TType
,
typename
RhoType
>
auto
build_Psir_Hessian_autodiff
(
const
Model
&
model
,
const
TType
T
,
const
RhoType
&
rho
)
{
auto
build_Psir_Hessian_autodiff
(
const
Model
&
model
,
const
TType
T
,
const
RhoType
&
rho
)
{
...
...
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