Skip to content

Commit 40e9b2d

Browse files
committed
python binding for friction coeff
1 parent 84e5221 commit 40e9b2d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/differentiable/adjoint.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ void define_adjoint(py::module_ &m)
3838
},
3939
py::arg("solver"));
4040

41+
m.def(
42+
"friction_coefficient_derivative",
43+
[](State &state) {
44+
Eigen::VectorXd term;
45+
if (state.problem->is_time_dependent())
46+
AdjointTools::dJ_friction_transient_adjoint_term(state, state.get_adjoint_mat(1), state.get_adjoint_mat(0), term);
47+
else
48+
log_and_throw_adjoint_error(
49+
"Friction coefficient derivative is only supported for transient problems!");
50+
51+
return term(0);
52+
},
53+
py::arg("solver"));
54+
4155
m.def(
4256
"initial_velocity_derivative",
4357
[](State &state) {

src/state/state.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,11 @@ void define_solver(py::module_ &m)
539539
},
540540
"updates obstacle displacement", py::arg("oid"), py::arg("val"),
541541
py::arg("interp") = std::string(""))
542+
.def(
543+
"set_friction_coefficient", [](State &self, const double mu) {
544+
self.args["contact"]["friction_coefficient"] = mu;
545+
},
546+
"set friction coefficient", py::arg("mu"))
542547
.def(
543548
"set_initial_velocity",
544549
[](State &self, const int body_id, const Eigen::VectorXd &velocity) {

0 commit comments

Comments
 (0)