Skip to content

Commit

Permalink
update python wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mattldawson committed Apr 24, 2024
1 parent 3aad428 commit e302328
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 0 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pybind11_add_module(musica_python
wrapper.cpp
${PROJECT_SOURCE_DIR}/src/micm/micm.cpp
${PROJECT_SOURCE_DIR}/src/component_versions.c
${PROJECT_SOURCE_DIR}/src/error.cpp
${PROJECT_SOURCE_DIR}/src/util.cpp
${CMAKE_BINARY_DIR}/version.c
)
Expand Down
13 changes: 9 additions & 4 deletions python/wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ PYBIND11_MODULE(musica, m)

m.def("create_micm", [](const char *config_path)
{
MICM* micm = create_micm(config_path);
Error error;
MICM* micm = create_micm(config_path, &error);
return micm; });

m.def("delete_micm", &delete_micm);
Expand All @@ -36,9 +37,11 @@ PYBIND11_MODULE(musica, m)
}
}

Error error;
micm_solve(micm, time_step, temperature, pressure,
concentrations_cpp.size(), concentrations_cpp.data(),
custom_rate_parameters_cpp.size(), custom_rate_parameters_cpp.data());
custom_rate_parameters_cpp.size(), custom_rate_parameters_cpp.data(),
&error);

// Update the concentrations list after solving
for (size_t i = 0; i < concentrations_cpp.size(); ++i) {
Expand All @@ -48,11 +51,13 @@ PYBIND11_MODULE(musica, m)

m.def(
"species_ordering", [](MICM *micm)
{ return micm->get_species_ordering(); },
{ Error error;
return micm->get_species_ordering(&error); },
"Return map of get_species_ordering rates");

m.def(
"user_defined_reaction_rates", [](MICM *micm)
{ return micm->get_user_defined_reaction_rates_ordering(); },
{ Error error;
return micm->get_user_defined_reaction_rates_ordering(&error); },
"Return map of reaction rates");
}

0 comments on commit e302328

Please sign in to comment.