Skip to content

Commit

Permalink
Merge pull request #21 from 3MAH/dfa_pywrap
Browse files Browse the repository at this point in the history
Add python wrappers for DFA equivalent stress
  • Loading branch information
ylgrst authored Nov 18, 2024
2 parents 5ec4cec + 0cdd3e6 commit 040f446
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ double Ani_stress(const pybind11::array_t<double> &input, const pybind11::array_

//This function returns the derivative of the Ani equivalent stress.
pybind11::array_t<double> dAni_stress(const pybind11::array_t<double> &input, const pybind11::array_t<double> &props, const bool &copy=true);

//This function returns the DFA equivalent stress.
double DFA_stress(const pybind11::array_t<double> &input, const pybind11::array_t<double> &props);

//This function returns the derivative of the DFA equivalent stress.
pybind11::array_t<double> dDFA_stress(const pybind11::array_t<double> &input, const pybind11::array_t<double> &props, const bool &copy=true);

//This function computes the selected equivalent stress function
double Eq_stress(const pybind11::array_t<double> &input, const std::string &criteria, const pybind11::array_t<double> &props);

//This function computes the deriavtive of the selected equivalent stress function
pybind11::array_t<double> dEq_stress(const pybind11::array_t<double> &input, const std::string &criteria, const pybind11::array_t<double> &props, const bool &copy=true);

} //namespace simpy
} //namespace simpy
Original file line number Diff line number Diff line change
Expand Up @@ -57,36 +57,51 @@ py::array_t<double> P_Hill(const py::array_t<double> &props, const bool &copy) {
return carma::mat_to_arr(t, copy);
}

//This function returns the Tresca equivalent stress.
//This function returns the Hill equivalent stress.
double Hill_stress(const py::array_t<double> &input, const py::array_t<double> &props) {
vec v = carma::arr_to_col(input);
vec props_cpp = carma::arr_to_col(props);
return simcoon::Hill_stress(v, props_cpp);
}

//This function returns the derivative of the Tresca equivalent stress.
//This function returns the derivative of the Hill equivalent stress.
py::array_t<double> dHill_stress(const py::array_t<double> &input, const py::array_t<double> &props, const bool &copy) {
vec v = carma::arr_to_col(input);
vec props_cpp = carma::arr_to_col(props);
vec t = simcoon::dHill_stress(v, props_cpp);
return carma::col_to_arr(t, copy);
}

//This function returns the Tresca equivalent stress.
//This function returns the anisotropic equivalent stress.
double Ani_stress(const py::array_t<double> &input, const py::array_t<double> &props) {
vec v = carma::arr_to_col(input);
vec props_cpp = carma::arr_to_col(props);
return simcoon::Ani_stress(v, props_cpp);
}

//This function returns the derivative of the Tresca equivalent stress.
//This function returns the derivative of the anisotropic equivalent stress.
py::array_t<double> dAni_stress(const py::array_t<double> &input, const py::array_t<double> &props, const bool &copy) {
vec v = carma::arr_to_col(input);
vec props_cpp = carma::arr_to_col(props);
vec t = simcoon::dAni_stress(v, props_cpp);
return carma::col_to_arr(t, copy);
}

//This function returns the DFA equivalent stress.
double DFA_stress(const py::array_t<double> &input, const py::array_t<double> &props) {
vec v = carma::arr_to_col(input);
vec props_cpp = carma::arr_to_col(props);
return simcoon::DFA_stress(v, props_cpp);
}

//This function returns the derivative of the DFA equivalent stress.
py::array_t<double> dDFA_stress(const py::array_t<double> &input, const py::array_t<double> &props, const bool &copy) {
vec v = carma::arr_to_col(input);
vec props_cpp = carma::arr_to_col(props);
vec t = simcoon::dDFA_stress(v, props_cpp);
return carma::col_to_arr(t, copy);
}

//This function computes the selected equivalent stress function
double Eq_stress(const py::array_t<double> &input, const string &criteria, const py::array_t<double> &props) {
vec v = carma::arr_to_col(input);
Expand All @@ -102,4 +117,4 @@ py::array_t<double> dEq_stress(const py::array_t<double> &input, const string &c
return carma::col_to_arr(t, copy);
}

} //namepsace simpy
} //namepsace simpy

0 comments on commit 040f446

Please sign in to comment.