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
f30e4669
Commit
f30e4669
authored
3 years ago
by
Ian Bell
Browse files
Options
Downloads
Patches
Plain Diff
Add CPA to json builder
parent
75d4530f
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/json_builder.hpp
+6
-1
6 additions, 1 deletion
include/teqp/json_builder.hpp
interface/C/teqpc.cpp
+24
-0
24 additions, 0 deletions
interface/C/teqpc.cpp
with
30 additions
and
1 deletion
include/teqp/json_builder.hpp
+
6
−
1
View file @
f30e4669
...
@@ -2,13 +2,15 @@
...
@@ -2,13 +2,15 @@
#include
"teqp/models/vdW.hpp"
#include
"teqp/models/vdW.hpp"
#include
"teqp/models/cubics.hpp"
#include
"teqp/models/cubics.hpp"
#include
"teqp/models/CPA.hpp"
#include
"nlohmann/json.hpp"
#include
"nlohmann/json.hpp"
using
vad
=
std
::
valarray
<
double
>
;
using
vad
=
std
::
valarray
<
double
>
;
using
cub
=
decltype
(
canonical_PR
(
vad
{},
vad
{},
vad
{}));
using
cub
=
decltype
(
canonical_PR
(
vad
{},
vad
{},
vad
{}));
using
cpatype
=
decltype
(
CPA
::
CPAfactory
(
nlohmann
::
json
{}));
// The type returned by the factory function
using
AllowedModels
=
std
::
variant
<
vdWEOS1
,
cub
>
;
using
AllowedModels
=
std
::
variant
<
vdWEOS1
,
cub
,
cpatype
>
;
AllowedModels
build_model
(
const
nlohmann
::
json
&
json
)
{
AllowedModels
build_model
(
const
nlohmann
::
json
&
json
)
{
...
@@ -27,6 +29,9 @@ AllowedModels build_model(const nlohmann::json& json) {
...
@@ -27,6 +29,9 @@ AllowedModels build_model(const nlohmann::json& json) {
std
::
valarray
<
double
>
Tc_K
=
spec
.
at
(
"Tcrit / K"
),
pc_Pa
=
spec
.
at
(
"pcrit / Pa"
),
acentric
=
spec
.
at
(
"acentric"
);
std
::
valarray
<
double
>
Tc_K
=
spec
.
at
(
"Tcrit / K"
),
pc_Pa
=
spec
.
at
(
"pcrit / Pa"
),
acentric
=
spec
.
at
(
"acentric"
);
return
canonical_SRK
(
Tc_K
,
pc_Pa
,
acentric
);
return
canonical_SRK
(
Tc_K
,
pc_Pa
,
acentric
);
}
}
else
if
(
kind
==
"CPA"
)
{
return
CPA
::
CPAfactory
(
spec
);
}
else
{
else
{
throw
teqpcException
(
30
,
"Unknown kind:"
+
kind
);
throw
teqpcException
(
30
,
"Unknown kind:"
+
kind
);
}
}
...
...
This diff is collapsed.
Click to expand it.
interface/C/teqpc.cpp
+
24
−
0
View file @
f30e4669
...
@@ -168,6 +168,30 @@ TEST_CASE("Use of C interface with simple models") {
...
@@ -168,6 +168,30 @@ TEST_CASE("Use of C interface with simple models") {
REQUIRE
(
e3
==
0
);
REQUIRE
(
e3
==
0
);
return
val
;
return
val
;
};
};
BENCHMARK
(
"CPA"
)
{
nlohmann
::
json
water
=
{
{
"a0i / Pa m^6/mol^2"
,
0.12277
},
{
"bi / m^3/mol"
,
0.000014515
},
{
"c1"
,
0.67359
},
{
"Tc / K"
,
647.096
},
{
"epsABi / J/mol"
,
16655.0
},
{
"betaABi"
,
0.0692
},
{
"class"
,
"4C"
}
};
nlohmann
::
json
jCPA
=
{
{
"cubic"
,
"SRK"
},
{
"pures"
,
{
water
}},
{
"R_gas / J/mol/K"
,
8.3144598
}
};
nlohmann
::
json
j
=
{
{
"kind"
,
"CPA"
},
{
"model"
,
jCPA
}
};
std
::
string
jstring
=
j
.
dump
();
int
e1
=
build_model
(
jstring
.
c_str
(),
uuid
,
errmsg
,
errmsg_length
);
int
e2
=
get_Arxy
(
uuid
,
0
,
1
,
300
,
3.0e-6
,
&
(
molefrac
[
0
]),
molefrac
.
size
(),
&
val
,
errmsg
,
errmsg_length
);
int
e3
=
free_model
(
uuid
,
errmsg
,
errmsg_length
);
REQUIRE
(
e1
==
0
);
REQUIRE
(
e2
==
0
);
REQUIRE
(
e3
==
0
);
return
val
;
};
}
}
#else
#else
int
main
()
{
int
main
()
{
...
...
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