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
187b8c98
Commit
187b8c98
authored
2 years ago
by
Ian Bell
Browse files
Options
Downloads
Patches
Plain Diff
Simplify and expand the Arxy method wrapping
parent
29157420
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
interface/pybind11_wrapper.hpp
+19
-5
19 additions, 5 deletions
interface/pybind11_wrapper.hpp
with
19 additions
and
5 deletions
interface/pybind11_wrapper.hpp
+
19
−
5
View file @
187b8c98
...
@@ -16,6 +16,24 @@
...
@@ -16,6 +16,24 @@
namespace
py
=
pybind11
;
namespace
py
=
pybind11
;
using
namespace
teqp
;
using
namespace
teqp
;
template
<
typename
Model
,
int
iT
,
int
iD
,
typename
Class
>
void
add_res_deriv_impl
(
Class
&
cls
)
{
using
idx
=
TDXDerivatives
<
Model
>
;
using
RAX
=
Eigen
::
Ref
<
Eigen
::
ArrayXd
>
;
const
std
::
string
fname
=
"get_Ar"
+
std
::
to_string
(
iT
)
+
std
::
to_string
(
iD
);
cls
.
def
(
fname
.
c_str
(),
[](
const
Model
&
m
,
const
double
T
,
const
double
rho
,
const
RAX
molefrac
)
{
return
idx
::
template
get_Arxy
<
iT
,
iD
,
ADBackends
::
autodiff
>(
m
,
T
,
rho
,
molefrac
);
},
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
()
);
}
template
<
typename
Model
,
typename
Class
>
void
add_res_derivatives
(
Class
&
cls
)
{
add_res_deriv_impl
<
Model
,
0
,
0
>
(
cls
);
add_res_deriv_impl
<
Model
,
0
,
1
>
(
cls
);
add_res_deriv_impl
<
Model
,
0
,
2
>
(
cls
);
add_res_deriv_impl
<
Model
,
0
,
3
>
(
cls
);
add_res_deriv_impl
<
Model
,
0
,
4
>
(
cls
);
add_res_deriv_impl
<
Model
,
1
,
0
>
(
cls
);
add_res_deriv_impl
<
Model
,
1
,
1
>
(
cls
);
add_res_deriv_impl
<
Model
,
1
,
2
>
(
cls
);
add_res_deriv_impl
<
Model
,
1
,
3
>
(
cls
);
add_res_deriv_impl
<
Model
,
1
,
4
>
(
cls
);
add_res_deriv_impl
<
Model
,
2
,
0
>
(
cls
);
add_res_deriv_impl
<
Model
,
2
,
1
>
(
cls
);
add_res_deriv_impl
<
Model
,
2
,
2
>
(
cls
);
add_res_deriv_impl
<
Model
,
2
,
3
>
(
cls
);
add_res_deriv_impl
<
Model
,
2
,
4
>
(
cls
);
}
template
<
typename
Model
,
typename
Wrapper
>
template
<
typename
Model
,
typename
Wrapper
>
void
add_derivatives
(
py
::
module
&
m
,
Wrapper
&
cls
)
{
void
add_derivatives
(
py
::
module
&
m
,
Wrapper
&
cls
)
{
...
@@ -75,11 +93,7 @@ void add_derivatives(py::module &m, Wrapper &cls) {
...
@@ -75,11 +93,7 @@ void add_derivatives(py::module &m, Wrapper &cls) {
cls
.
def
(
"get_R"
,
[](
const
Model
&
m
,
const
RAX
molefrac
)
{
return
m
.
R
(
molefrac
);
},
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_R"
,
[](
const
Model
&
m
,
const
RAX
molefrac
)
{
return
m
.
R
(
molefrac
);
},
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_Ar00"
,
&
tdx
::
get_Ar00
,
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_Ar00"
,
&
tdx
::
get_Ar00
,
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_Ar01"
,
&
(
tdx
::
template
get_Ar01
<
ADBackends
::
autodiff
>),
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
add_res_derivatives
<
Model
>
(
cls
);
// All the residual derivatives
cls
.
def
(
"get_Ar10"
,
&
(
tdx
::
template
get_Ar10
<
ADBackends
::
autodiff
>),
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_Ar11"
,
&
(
tdx
::
template
get_Ar11
<
ADBackends
::
autodiff
>),
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_Ar12"
,
&
(
tdx
::
template
get_Ar12
<
ADBackends
::
autodiff
>),
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_Ar20"
,
&
(
tdx
::
template
get_Ar20
<
ADBackends
::
autodiff
>),
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_Ar01n"
,
&
(
tdx
::
template
get_Ar0n
<
1
>),
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_Ar01n"
,
&
(
tdx
::
template
get_Ar0n
<
1
>),
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_Ar02n"
,
&
(
tdx
::
template
get_Ar0n
<
2
>),
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
cls
.
def
(
"get_Ar02n"
,
&
(
tdx
::
template
get_Ar0n
<
2
>),
py
::
arg
(
"T"
),
py
::
arg
(
"rho"
),
py
::
arg
(
"molefrac"
).
noconvert
());
...
...
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