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
e975a7bc
Commit
e975a7bc
authored
3 years ago
by
Ian Bell
Browse files
Options
Downloads
Patches
Plain Diff
Add VLE method for pures
See #2
parent
fc5262ae
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/teqp/algorithms/VLE.hpp
+23
-0
23 additions, 0 deletions
include/teqp/algorithms/VLE.hpp
src/tests/catch_tests.cxx
+2
-0
2 additions, 0 deletions
src/tests/catch_tests.cxx
with
25 additions
and
0 deletions
include/teqp/algorithms/VLE.hpp
+
23
−
0
View file @
e975a7bc
...
...
@@ -61,3 +61,26 @@ public:
return
J
;
}
};
template
<
typename
Residual
,
typename
Scalar
>
auto
do_pure_VLE
(
Residual
&
resid
,
Scalar
T
,
Scalar
rhoL
,
Scalar
rhoV
)
{
auto
rhovec
=
(
Eigen
::
ArrayXd
(
2
)
<<
rhoL
,
rhoV
).
finished
();
auto
r0
=
resid
.
call
(
rhovec
);
auto
J
=
resid
.
Jacobian
(
rhovec
);
for
(
int
iter
=
0
;
iter
<
100
;
++
iter
){
if
(
iter
>
0
)
{
r0
=
resid
.
call
(
rhovec
);
J
=
resid
.
Jacobian
(
rhovec
);
}
auto
v
=
J
.
matrix
().
colPivHouseholderQr
().
solve
(
-
r0
.
matrix
()).
array
().
eval
();
auto
rhovecnew
=
(
rhovec
+
v
).
eval
();
// If the solution has stopped improving, stop. The change in rhovec is equal to v in infinite precision, but
// not when finite precision is involved, so use the minimum non-denormal float as the determination of whether
// the values are done changing
if
(((
rhovecnew
-
rhovec
).
cwiseAbs
()
<
std
::
numeric_limits
<
Scalar
>::
min
()).
all
())
{
break
;
}
rhovec
+=
v
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/tests/catch_tests.cxx
+
2
−
0
View file @
e975a7bc
...
...
@@ -242,4 +242,6 @@ TEST_CASE("Test pure VLE", "") {
auto
rhovec1
=
rhovec
+
v
;
auto
r1
=
resid
.
call
(
rhovec1
);
CHECK
((
r0
.
cwiseAbs
()
>
r1
.
cwiseAbs
()).
eval
().
all
());
do_pure_VLE
(
resid
,
T
,
22834.056386882046
,
1025.106554560764
);
}
\ 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